File: vtkTemporalStreamTracer.h

package info (click to toggle)
paraview 3.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 124,600 kB
  • ctags: 133,728
  • sloc: cpp: 958,817; ansic: 509,658; tcl: 45,787; xml: 23,401; python: 19,574; perl: 3,112; yacc: 1,787; java: 1,517; sh: 665; asm: 471; lex: 400; makefile: 168; objc: 28
file content (354 lines) | stat: -rw-r--r-- 12,578 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: vtkTemporalStreamTracer.h,v $

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkTemporalStreamTracer - A Parallel Particle tracer for unsteady vector fields
// .SECTION Description
// vtkTemporalStreamTracer is a filter that integrates a vector field to generate
// 
//
// .SECTION See Also
// vtkRibbonFilter vtkRuledSurfaceFilter vtkInitialValueProblemSolver 
// vtkRungeKutta2 vtkRungeKutta4 vtkRungeKutta45 vtkStreamTracer

#ifndef __vtkTemporalStreamTracer_h
#define __vtkTemporalStreamTracer_h

#include "vtkSmartPointer.h" // For protected ivars.
#include "vtkStreamTracer.h"

//BTX
#include <vtkstd/vector> // I'll remove these soon.
#include <vtkstd/list> // I'll remove these soon.
//ETX

class vtkMultiProcessController;

class vtkCompositeDataSet;
class vtkDataArray;
class vtkDoubleArray;
class vtkGenericCell;
class vtkIntArray;
class vtkTemporalInterpolatedVelocityField;
class vtkPoints;
class vtkCellArray;
class vtkDoubleArray;
class vtkFloatArray;
class vtkIntArray;
class vtkAbstractParticleWriter;

//BTX
namespace vtkTemporalStreamTracerNamespace
{
  typedef struct { double x[4]; } Position;
  typedef struct {
    // These are used during iteration
    int           Counter;
    int           Index;
    bool          Wrap;
    Position      CurrentPosition;
    int           CachedDataSet[2];
    vtkIdType     CachedCellId[2];
    // These are computed scalars we might display
    int           SourceID;
    int           InjectedPointId;      
    float         UniqueParticleId;
    // these are needed across time steps to compute vorticity
    float         rotation;
    float         angularVel;
    float         time;
  } ParticleInformation;

  typedef vtkstd::vector<ParticleInformation>  ParticleList;
  typedef vtkstd::list<ParticleInformation>    ParticleDataList;
  typedef ParticleDataList::iterator           ParticleIterator;

  class vtkTemporalStreamTracerInternals {
  public:
  };
};

//ETX

class VTK_PARALLEL_EXPORT vtkTemporalStreamTracer : public vtkStreamTracer
{
public:

    vtkTypeRevisionMacro(vtkTemporalStreamTracer,vtkStreamTracer);
    void PrintSelf(ostream& os, vtkIndent indent);

    // Description:
    // Construct object using 2nd order Runge Kutta 
    static vtkTemporalStreamTracer *New();

    // Description:
    // Set/Get the TimeStep. This is the primary means of advancing 
    // the particles. The TimeStep should be animated and this will drive
    // the pipeline forcing timesteps to be fetched from upstream.
    vtkSetMacro(TimeStep,unsigned int);
    vtkGetMacro(TimeStep,unsigned int);

    // Description:
    // To get around problems with the Paraview Animation controls
    // we can just animate the time step and ignore the TIME_ requests
    vtkSetMacro(IgnorePipelineTime, int);
    vtkGetMacro(IgnorePipelineTime, int);
    vtkBooleanMacro(IgnorePipelineTime, int);

    // Description:
    // If the data source does not have the correct time values 
    // present on each time step - setting this value to non unity can
    // be used to adjust the time step size from 1s pre step to
    // 1x_TimeStepResolution : Not functional in this version. 
    // Broke it @todo, put back time scaling
    vtkSetMacro(TimeStepResolution,double);
    vtkGetMacro(TimeStepResolution,double);

    // Description:
    // When animating particles, it is nice to inject new ones every Nth step
    // to produce a continuous flow. Setting ForceReinjectionEveryNSteps to a 
    // non zero value will cause the particle source to reinject particles
    // every Nth step even if it is otherwise unchanged.
    // Note that if the particle source is also animated, this flag will be
    // redundant as the particles will be reinjected whenever the source changes 
    // anyway
    vtkSetMacro(ForceReinjectionEveryNSteps,int);
    vtkGetMacro(ForceReinjectionEveryNSteps,int);

    // Description:
    // Specify an alternative Geometry object as the source of particles
    // This method exists so that in the ParaView GUI we can either
    // select a widget as source, or by using this input, a dataset generated
    // during the session.
    // Old style. Do not use.
    void SetSource2(vtkDataSet *source);
    vtkDataSet *GetSource2();

    // Description:
    // Specify an alternative Geometry object as the source of particles
    // This method exists so that in the ParaView GUI we can either
    // select a widget as source, or by using this input, a dataset generated
    // during the session.
    // New Style. Do use.
    void SetSource2Connection(vtkAlgorithmOutput* algOutput);

    // Description:
    vtkSetMacro(EnableSource1,int);
    vtkGetMacro(EnableSource1,int);
    vtkBooleanMacro(EnableSource1,int);

    // Description:
    vtkSetMacro(EnableSource2,int);
    vtkGetMacro(EnableSource2,int);
    vtkBooleanMacro(EnableSource2,int);

    // Description:
    // Set/Get the controller used when sending particles between processes
    // The controller must be an instance of vtkMPIController.
    // If VTK was compiled without VTK_USE_MPI on, then the Controller is simply
    // ignored.
    virtual void SetController(vtkMultiProcessController* controller);
    vtkGetObjectMacro(Controller, vtkMultiProcessController);

    // Description:
    // Set/Get the Writer associated with this Particle Tracer
    // Ideally a parallel IO capable vtkH5PartWriter should be used
    // which will collect particles from all parallel processes
    // and write them to a single HDF5 file.
    virtual void SetParticleWriter(vtkAbstractParticleWriter *pw);
    vtkGetObjectMacro(ParticleWriter, vtkAbstractParticleWriter);

    // Description:
    // Set/Get the filename to be used with the particle writer when
    // dumping particles to disk    
    vtkSetStringMacro(ParticleFileName);
    vtkGetStringMacro(ParticleFileName);

    // Description:
    // Set/Get the filename to be used with the particle writer when
    // dumping particles to disk    
    vtkSetMacro(EnableParticleWriting,int);
    vtkGetMacro(EnableParticleWriting,int);
    vtkBooleanMacro(EnableParticleWriting,int);

  protected:

     vtkTemporalStreamTracer();
    ~vtkTemporalStreamTracer();

    //
    // Make sure the pipeline knows what type we expect as input
    //
    virtual int FillInputPortInformation(int port, vtkInformation* info);

    //
    // The usual suspects
    //
    virtual int ProcessRequest(vtkInformation* request,
                               vtkInformationVector** inputVector,
                               vtkInformationVector* outputVector);

    //
    // Store any information we need in the output and fetch what we can
    // from the input
    //
    virtual int RequestInformation(vtkInformation* request,
                                  vtkInformationVector** inputVector,
                                  vtkInformationVector* outputVector);

    //
    // Compute input time steps given the output step
    //
    virtual int RequestUpdateExtent(vtkInformation* request,
                                    vtkInformationVector** inputVector,
                                    vtkInformationVector* outputVector);

    //
    // Generate output
    //
    virtual int RequestData(vtkInformation* request,
                            vtkInformationVector** inputVector,
                            vtkInformationVector* outputVector);


    int InitializeInterpolator();
    int SetupInputs(vtkInformation* inInfo, vtkInformation* outInfo);

//
//BTX
//
    // Description : Tests points to see if they are inside this region
    // Pass in either a source object or an input list, one
    // parameter should be valid, the other NULL
    void InjectSeeds(vtkDataSet *source, int sourceID, int injectionID, 
      vtkTemporalStreamTracerNamespace::ParticleList *inputlist,
      vtkTemporalStreamTracerNamespace::ParticleList &candidates, vtkTemporalStreamTracerNamespace::ParticleList *outofdomain);

    void UpdateSeeds(vtkTemporalStreamTracerNamespace::ParticleList &candidates);

    void TransmitReceiveParticles(
      vtkTemporalStreamTracerNamespace::ParticleList &outofdomain, vtkTemporalStreamTracerNamespace::ParticleList &received, bool removeself);

    void IntegrateParticle(
      vtkTemporalStreamTracerNamespace::ParticleIterator &it, 
      double currenttime, double terminationtime,
      vtkInitialValueProblemSolver* integrator);

    void GenerateOutputLines(vtkPolyData *output);
    bool DoParticleSendTasks(vtkTemporalStreamTracerNamespace::ParticleInformation &info, double point1[4], double velocity[3], double delT);
    bool DoParticleSendTasks(vtkTemporalStreamTracerNamespace::ParticleInformation &info, double point1[4], double delT);
    bool ComputeDomainExitLocation(
      double pos[4], double p2[4], double intersection[4],
      vtkGenericCell *cell);
    void AddParticleToMPISendList(vtkTemporalStreamTracerNamespace::ParticleInformation &info);
//
//ETX
//

    // Mostly useful for debugging parallel operation
    int           UpdatePiece;
    int           UpdateNumPieces;

    // Turn on/off sources
    int           EnableSource1;      
    int           EnableSource2;

    // Important for Caching of Cells/Ids/Weights etc
    int           AllFixedGeometry;
    int           NoFixedGeometry;

    // internal data variables
    int           MaxCellSize;

    // Support pipeline time 
    unsigned int  TimeStep;
    unsigned int  ActualTimeStep;
    unsigned int  NumberOfInputTimeSteps;
//BTX
    vtkstd::vector<double>  InputTimeValues;
    vtkstd::vector<double>  OutputTimeValues;
//ETX

    double        EarliestTime;
    double        CurrentTimeSteps[2];
    double        TimeStepResolution;
    int           ForceReinjectionEveryNSteps;
    bool          ReinjectionFlag;  
    int           ReinjectionCounter;
    int           IgnorePipelineTime;
    //
    vtkAbstractParticleWriter *ParticleWriter;
    char                      *ParticleFileName; 
    int                        EnableParticleWriting;
    //
    vtkTimeStamp  ParticleInjectionTime;
    vtkTimeStamp  SeedInjectionTime;

//BTX
    unsigned int                                        NumberOfParticles;
    vtkTemporalStreamTracerNamespace::ParticleDataList  ParticleHistories;
//ETX

//BTX
    vtkSmartPointer<vtkPoints>        OutputCoordinates;
    vtkSmartPointer<vtkCellArray>     ParticleCells;
    //
    // Scalar arrays that are generated as each particle is updated
    //
    vtkSmartPointer<vtkIntArray>      ParticleIds;
    vtkSmartPointer<vtkIntArray>      ParticleSourceIds;
    vtkSmartPointer<vtkIntArray>      InjectedPointIds;
    vtkSmartPointer<vtkDoubleArray>   cellVectors;
    vtkSmartPointer<vtkFloatArray>    ParticleTime;
    vtkSmartPointer<vtkFloatArray>    ParticleVorticity;
    vtkSmartPointer<vtkFloatArray>    ParticleRotation;
    vtkSmartPointer<vtkFloatArray>    ParticleAngularVel;
    vtkSmartPointer<vtkPointData>     OutputPointData;
    vtkSmartPointer<vtkPointData>     OutputPointDataT1;
    vtkSmartPointer<vtkPointData>     OutputPointDataT2;
    //
    vtkTemporalStreamTracerNamespace::ParticleList MPISendList;
    //
    vtkSmartPointer<vtkTemporalInterpolatedVelocityField>  Interpolator;
    vtkCompositeDataSet                                   *InputDataT[2];
    vtkDataSet                                            *DataReferenceT[2];

    // info about each dataset we will use repeatedly
    typedef struct {
      double b[6];
    } bounds;
    vtkstd::vector<bounds> CachedBounds[2];
    vtkstd::vector<bool>   GeometryFixed[2];

    bool InsideBounds(double point[]);

    //
//ETX

  vtkMultiProcessController* Controller;
  static vtkIdType UniqueIdCounter;

private:
  // Description:
  // Hide this because we require a new interpolator type
  void SetInterpolatorPrototype(vtkInterpolatedVelocityField*) {};

private:
  vtkTemporalStreamTracer(const vtkTemporalStreamTracer&);  // Not implemented.
  void operator=(const vtkTemporalStreamTracer&);  // Not implemented.
};


#endif