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

Resample time-resolved streamlines into discrete Lagrangian particle positions at successive time steps, simulating repeated particle injections. More...

#include <vtkvmtkStreamlineToParticlesFilter.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkStreamlineToParticlesFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetNumberOfInjections (int)
virtual int GetNumberOfInjections ()
virtual void SetNumberOfParticlesPerInjection (int)
virtual int GetNumberOfParticlesPerInjection ()
virtual void SetInjectionStart (double)
virtual double GetInjectionStart ()
virtual void SetInjectionEnd (double)
virtual double GetInjectionEnd ()
virtual void SetTracingEnd (double)
virtual double GetTracingEnd ()
virtual void SetDeltaT (double)
virtual double GetDeltaT ()
virtual void SetIntegrationTimeArrayName (const char *)
virtual char * GetIntegrationTimeArrayName ()
virtual void SetTimeArrayName (const char *)
virtual char * GetTimeArrayName ()
virtual void SetVelocityArrayName (const char *)
virtual char * GetVelocityArrayName ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkStreamlineToParticlesFilter ()
 ~vtkvmtkStreamlineToParticlesFilter ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

int NumberOfInjections
int NumberOfParticlesPerInjection
double InjectionStart
double InjectionEnd
double TracingEnd
double DeltaT
char * IntegrationTimeArrayName
char * TimeArrayName
char * VelocityArrayName

Detailed Description

Resample time-resolved streamlines into discrete Lagrangian particle positions at successive time steps, simulating repeated particle injections.

Given input streamlines (polylines) carrying a per-point integration-time array (IntegrationTimeArrayName), simulates NumberOfInjections separate particle injections evenly spaced between InjectionStart and InjectionEnd (in the same time units as the streamline integration time), each releasing NumberOfParticlesPerInjection particles that are then advected along their streamlines up to TracingEnd, sampled at a fixed time increment DeltaT. The output is a point cloud of particle positions at each sampled time, useful for visualizing pulsatile/ unsteady flow as a particle animation rather than static streamlines.

Definition at line 38 of file vtkvmtkStreamlineToParticlesFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkStreamlineToParticlesFilter::Superclass

Definition at line 41 of file vtkvmtkStreamlineToParticlesFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkStreamlineToParticlesFilter()

vtkvmtkStreamlineToParticlesFilter::vtkvmtkStreamlineToParticlesFilter ( )
protected

Definition at line 39 of file vtkvmtkStreamlineToParticlesFilter.cxx.

◆ ~vtkvmtkStreamlineToParticlesFilter()

vtkvmtkStreamlineToParticlesFilter::~vtkvmtkStreamlineToParticlesFilter ( )
protected

Definition at line 52 of file vtkvmtkStreamlineToParticlesFilter.cxx.

53{
55 {
56 delete[] this->IntegrationTimeArrayName;
57 this->IntegrationTimeArrayName = NULL;
58 }
59 if (this->TimeArrayName)
60 {
61 delete[] this->TimeArrayName;
62 this->TimeArrayName = NULL;
63 }
64 if (this->VelocityArrayName)
65 {
66 delete[] this->VelocityArrayName;
67 this->VelocityArrayName = NULL;
68 }
69}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkStreamlineToParticlesFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkStreamlineToParticlesFilter * vtkvmtkStreamlineToParticlesFilter::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 223 of file vtkvmtkStreamlineToParticlesFilter.cxx.

224{
225 this->Superclass::PrintSelf(os,indent);
226}

◆ New()

vtkvmtkStreamlineToParticlesFilter * vtkvmtkStreamlineToParticlesFilter::New ( )
static

◆ SetNumberOfInjections()

virtual void vtkvmtkStreamlineToParticlesFilter::SetNumberOfInjections ( int )
virtual

Set/Get the number of separate particle injections simulated, evenly spaced between InjectionStart and InjectionEnd. Default: 10.

◆ GetNumberOfInjections()

virtual int vtkvmtkStreamlineToParticlesFilter::GetNumberOfInjections ( )
virtual

Set/Get the number of separate particle injections simulated, evenly spaced between InjectionStart and InjectionEnd. Default: 10.

◆ SetNumberOfParticlesPerInjection()

virtual void vtkvmtkStreamlineToParticlesFilter::SetNumberOfParticlesPerInjection ( int )
virtual

Set/Get the number of particles released per injection, subsampled from the input streamlines (one particle roughly every GetNumberOfCells()/NumberOfParticlesPerInjection streamlines). Default: 10.

◆ GetNumberOfParticlesPerInjection()

virtual int vtkvmtkStreamlineToParticlesFilter::GetNumberOfParticlesPerInjection ( )
virtual

Set/Get the number of particles released per injection, subsampled from the input streamlines (one particle roughly every GetNumberOfCells()/NumberOfParticlesPerInjection streamlines). Default: 10.

◆ SetInjectionStart()

virtual void vtkvmtkStreamlineToParticlesFilter::SetInjectionStart ( double )
virtual

Set/Get the integration time (in the same units as IntegrationTimeArrayName) of the first injection. Default: 0.0.

◆ GetInjectionStart()

virtual double vtkvmtkStreamlineToParticlesFilter::GetInjectionStart ( )
virtual

Set/Get the integration time (in the same units as IntegrationTimeArrayName) of the first injection. Default: 0.0.

◆ SetInjectionEnd()

virtual void vtkvmtkStreamlineToParticlesFilter::SetInjectionEnd ( double )
virtual

Set/Get the integration time of the last injection; the NumberOfInjections injections are spaced evenly between InjectionStart and InjectionEnd. Default: 1.0.

◆ GetInjectionEnd()

virtual double vtkvmtkStreamlineToParticlesFilter::GetInjectionEnd ( )
virtual

Set/Get the integration time of the last injection; the NumberOfInjections injections are spaced evenly between InjectionStart and InjectionEnd. Default: 1.0.

◆ SetTracingEnd()

virtual void vtkvmtkStreamlineToParticlesFilter::SetTracingEnd ( double )
virtual

Set/Get the integration time at which particle tracing stops for every injection. Default: 1.0.

◆ GetTracingEnd()

virtual double vtkvmtkStreamlineToParticlesFilter::GetTracingEnd ( )
virtual

Set/Get the integration time at which particle tracing stops for every injection. Default: 1.0.

◆ SetDeltaT()

virtual void vtkvmtkStreamlineToParticlesFilter::SetDeltaT ( double )
virtual

Set/Get the time increment at which each particle's position is sampled along its streamline. Default: 1E-2.

◆ GetDeltaT()

virtual double vtkvmtkStreamlineToParticlesFilter::GetDeltaT ( )
virtual

Set/Get the time increment at which each particle's position is sampled along its streamline. Default: 1E-2.

◆ SetIntegrationTimeArrayName()

virtual void vtkvmtkStreamlineToParticlesFilter::SetIntegrationTimeArrayName ( const char * )
virtual

Set/Get the name of the point data array of the input streamlines holding the cumulative integration time at each point. Required input.

◆ GetIntegrationTimeArrayName()

virtual char * vtkvmtkStreamlineToParticlesFilter::GetIntegrationTimeArrayName ( )
virtual

Set/Get the name of the point data array of the input streamlines holding the cumulative integration time at each point. Required input.

◆ SetTimeArrayName()

virtual void vtkvmtkStreamlineToParticlesFilter::SetTimeArrayName ( const char * )
virtual

Set/Get the name of the output point data array where each sampled particle position's absolute time (injection offset plus elapsed integration time) is stored.

◆ GetTimeArrayName()

virtual char * vtkvmtkStreamlineToParticlesFilter::GetTimeArrayName ( )
virtual

Set/Get the name of the output point data array where each sampled particle position's absolute time (injection offset plus elapsed integration time) is stored.

◆ SetVelocityArrayName()

virtual void vtkvmtkStreamlineToParticlesFilter::SetVelocityArrayName ( const char * )
virtual

Set/Get the name of the 3-component point data array of the input streamlines holding the velocity field, copied onto each sampled particle position.

◆ GetVelocityArrayName()

virtual char * vtkvmtkStreamlineToParticlesFilter::GetVelocityArrayName ( )
virtual

Set/Get the name of the 3-component point data array of the input streamlines holding the velocity field, copied onto each sampled particle position.

◆ RequestData()

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

Definition at line 71 of file vtkvmtkStreamlineToParticlesFilter.cxx.

75{
76 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
77 vtkInformation *outInfo = outputVector->GetInformationObject(0);
78
79 vtkPolyData *input = vtkPolyData::SafeDownCast(
80 inInfo->Get(vtkDataObject::DATA_OBJECT()));
81 vtkPolyData *output = vtkPolyData::SafeDownCast(
82 outInfo->Get(vtkDataObject::DATA_OBJECT()));
83
84 if (input->GetNumberOfPoints() < 1)
85 {
86 return 1;
87 }
88
89 if (!this->IntegrationTimeArrayName)
90 {
91 vtkErrorMacro("Error: IntegrationTimeArrayName not specified");
92 return 1;
93 }
94
95 vtkDataArray* integrationTimeArray = input->GetPointData()->GetArray(this->IntegrationTimeArrayName);
96
97 if (!integrationTimeArray)
98 {
99 vtkErrorMacro("Error: IntegrationTimeArray with name specified does not exist");
100 return 1;
101 }
102
103 vtkDataArray* velocityArray = NULL;
104
105 if (this->VelocityArrayName)
106 {
107 velocityArray = input->GetPointData()->GetArray(this->VelocityArrayName);
108
109 if (!velocityArray)
110 {
111 vtkErrorMacro("Error: VelocityArray with name specified does not exist");
112 return 1;
113 }
114 }
115
116 int numberOfCells = input->GetNumberOfCells();
117
118 vtkPoints* outputPoints = vtkPoints::New();
119 vtkCellArray* outputVerts = vtkCellArray::New();
120
121 vtkDoubleArray* outputTimeArray = vtkDoubleArray::New();
122 outputTimeArray->SetName(this->TimeArrayName);
123
124 vtkDoubleArray* outputVelocityArray = vtkDoubleArray::New();
125 outputVelocityArray->SetName(this->VelocityArrayName);
126 outputVelocityArray->SetNumberOfComponents(3);
127
128 int i;
129 for (i=0; i<this->NumberOfInjections; i++)
130 {
131 double injectionOffset = this->InjectionStart + i * (this->InjectionEnd - this->InjectionStart) / this->NumberOfInjections;
132
133 vtkMaskPolyData* mask = vtkMaskPolyData::New();
134 mask->SetInputData(input);
135 mask->SetOnRatio(numberOfCells/this->NumberOfParticlesPerInjection);
136 mask->SetOffset(i);
137 mask->Update();
138
139 mask->GetOutput()->GetPointData()->SetActiveScalars(this->IntegrationTimeArrayName);
140
141 vtkPolyData* subset = mask->GetOutput();
142
143 int numberOfSubsetCells = subset->GetNumberOfCells();
144 int j;
145 for (j=0; j<numberOfSubsetCells; j++)
146 {
147 vtkPolyLine* polyLine = vtkPolyLine::SafeDownCast(subset->GetCell(j));
148 if (!polyLine)
149 {
150 continue;
151 }
152
153 vtkIdList* pointIds = polyLine->GetPointIds();
154 int numberOfPointIds = pointIds->GetNumberOfIds();
155
156 double integrationTime = injectionOffset;
157 int k;
158 for (k=0; k<numberOfPointIds-1; k++)
159 {
160 double time0 = integrationTimeArray->GetTuple1(pointIds->GetId(k));
161 double time1 = integrationTimeArray->GetTuple1(pointIds->GetId(k+1));
162 if (time0 < integrationTime && time1 < integrationTime)
163 {
164 continue;
165 }
166 if (time0 > integrationTime && time1 > integrationTime)
167 {
168 break;
169 }
170 bool valid = true;
171 while (valid)
172 {
173 double pcoord = (integrationTime - time0) / (time1 - time0);
174 double interpolatedPoint[3];
175 vtkvmtkCenterlineUtilities::InterpolatePoint(subset,j,k,pcoord,interpolatedPoint);
176 vtkIdType pointId = outputPoints->InsertNextPoint(interpolatedPoint);
177 outputVerts->InsertNextCell(1);
178 outputVerts->InsertCellPoint(pointId);
179 outputTimeArray->InsertNextValue(integrationTime + injectionOffset);
180 if (velocityArray)
181 {
182 double velocity[3];
184 outputVelocityArray->InsertNextTuple(velocity);
185 }
186 integrationTime += this->DeltaT;
187 if (integrationTime > time1)
188 {
189 valid = false;
190 }
191 if (integrationTime + injectionOffset > this->TracingEnd)
192 {
193 break;
194 }
195 }
196 if (integrationTime + injectionOffset > this->TracingEnd)
197 {
198 break;
199 }
200 }
201 }
202 }
203
204 output->SetPoints(outputPoints);
205 output->SetVerts(outputVerts);
206 output->GetPointData()->AddArray(outputTimeArray);
207 if (velocityArray)
208 {
209 output->GetPointData()->AddArray(outputVelocityArray);
210 }
211
212 outputPoints->Delete();
213 outputVerts->Delete();
214 outputTimeArray->Delete();
215 if (velocityArray)
216 {
217 outputVelocityArray->Delete();
218 }
219
220 return 1;
221}
static void InterpolatePoint(vtkPolyData *centerlines, int cellId, int subId, double pcoord, double interpolatedPoint[3])
static void InterpolateTuple3(vtkPolyData *centerlines, const char *arrayName, int cellId, int subId, double pcoord, double interpolatedTuple3[3])

Member Data Documentation

◆ NumberOfInjections

int vtkvmtkStreamlineToParticlesFilter::NumberOfInjections
protected

Definition at line 133 of file vtkvmtkStreamlineToParticlesFilter.h.

◆ NumberOfParticlesPerInjection

int vtkvmtkStreamlineToParticlesFilter::NumberOfParticlesPerInjection
protected

Definition at line 134 of file vtkvmtkStreamlineToParticlesFilter.h.

◆ InjectionStart

double vtkvmtkStreamlineToParticlesFilter::InjectionStart
protected

Definition at line 136 of file vtkvmtkStreamlineToParticlesFilter.h.

◆ InjectionEnd

double vtkvmtkStreamlineToParticlesFilter::InjectionEnd
protected

Definition at line 137 of file vtkvmtkStreamlineToParticlesFilter.h.

◆ TracingEnd

double vtkvmtkStreamlineToParticlesFilter::TracingEnd
protected

Definition at line 138 of file vtkvmtkStreamlineToParticlesFilter.h.

◆ DeltaT

double vtkvmtkStreamlineToParticlesFilter::DeltaT
protected

Definition at line 139 of file vtkvmtkStreamlineToParticlesFilter.h.

◆ IntegrationTimeArrayName

char* vtkvmtkStreamlineToParticlesFilter::IntegrationTimeArrayName
protected

Definition at line 141 of file vtkvmtkStreamlineToParticlesFilter.h.

◆ TimeArrayName

char* vtkvmtkStreamlineToParticlesFilter::TimeArrayName
protected

Definition at line 142 of file vtkvmtkStreamlineToParticlesFilter.h.

◆ VelocityArrayName

char* vtkvmtkStreamlineToParticlesFilter::VelocityArrayName
protected

Definition at line 143 of file vtkvmtkStreamlineToParticlesFilter.h.


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