VTK-m  2.0
worklet/ParticleAdvection.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 
11 #ifndef vtk_m_filter_flow_worklet_ParticleAdvection_h
12 #define vtk_m_filter_flow_worklet_ParticleAdvection_h
13 
14 #include <vtkm/cont/Invoker.h>
16 
17 namespace vtkm
18 {
19 namespace worklet
20 {
21 namespace flow
22 {
23 
24 namespace detail
25 {
26 class CopyToParticle : public vtkm::worklet::WorkletMapField
27 {
28 public:
29  using ControlSignature =
30  void(FieldIn pt, FieldIn id, FieldIn time, FieldIn step, FieldOut particle);
31  using ExecutionSignature = void(_1, _2, _3, _4, _5);
32  using InputDomain = _1;
33 
34  template <typename ParticleType>
35  VTKM_EXEC void operator()(const vtkm::Vec3f& pt,
36  const vtkm::Id& id,
37  const vtkm::FloatDefault& time,
38  const vtkm::Id& step,
39  ParticleType& particle) const
40  {
41  particle.SetPosition(pt);
42  particle.SetID(id);
43  particle.SetTime(time);
44  particle.SetNumberOfSteps(step);
45  particle.GetStatus().SetOk();
46  }
47 };
48 
49 } //detail
50 
51 template <typename ParticleType>
53 {
55  : Particles()
56  {
57  }
58 
60  : Particles(p)
61  {
62  }
63 
65 };
66 
68 {
69 public:
71 
72  template <typename IntegratorType, typename ParticleType, typename ParticleStorage>
73  void Run2(const IntegratorType& it,
75  vtkm::Id MaxSteps,
77  {
79 
80  worklet.Run(it, particles, MaxSteps);
81  result = ParticleAdvectionResult<ParticleType>(particles);
82  }
83 
84  template <typename IntegratorType, typename ParticleType, typename ParticleStorage>
86  const IntegratorType& it,
88  vtkm::Id MaxSteps)
89  {
91 
92  worklet.Run(it, particles, MaxSteps);
93  return ParticleAdvectionResult<ParticleType>(particles);
94  }
95 
96  template <typename IntegratorType, typename ParticleType, typename PointStorage>
98  const IntegratorType& it,
100  vtkm::Id MaxSteps)
101  {
103 
107  vtkm::cont::Invoker invoke;
108 
109  vtkm::Id numPts = points.GetNumberOfValues();
113 
114  //Copy input to vtkm::Particle
115  vtkm::cont::ArrayCopy(s, step);
116  vtkm::cont::ArrayCopy(t, time);
117  vtkm::cont::ArrayCopy(id, ids);
118  invoke(detail::CopyToParticle{}, points, ids, time, step, particles);
119 
120  worklet.Run(it, particles, MaxSteps);
121  return ParticleAdvectionResult<ParticleType>(particles);
122  }
123 };
124 
125 template <typename ParticleType>
127 {
129  : Particles()
130  , Positions()
131  , PolyLines()
132  {
133  }
134 
137  const vtkm::cont::CellSetExplicit<>& lines)
138  : Particles(part)
139  , Positions(pos)
140  , PolyLines(lines)
141  {
142  }
143 
147 };
148 
150 {
151 public:
153 
154  template <typename IntegratorType, typename ParticleType, typename ParticleStorage>
156  const IntegratorType& it,
158  vtkm::Id MaxSteps)
159  {
161 
164 
165  worklet.Run(it, particles, MaxSteps, positions, polyLines);
166 
167  return StreamlineResult<ParticleType>(particles, positions, polyLines);
168  }
169 };
170 
171 }
172 }
173 } // vtkm::worklet::flow
174 
175 #endif // vtk_m_filter_flow_worklet_ParticleAdvection_h
vtkm::cont::ArrayHandle::GetNumberOfValues
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
vtkm::cont::ArrayHandle< ParticleType >
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::flow::ParticleAdvectionWorklet
Definition: ParticleAdvectionWorklets.h:91
vtkm::worklet::flow::Streamline
Definition: worklet/ParticleAdvection.h:149
vtkm::worklet::flow::Streamline::Streamline
Streamline()
Definition: worklet/ParticleAdvection.h:152
vtkm::worklet::flow::Particles
Definition: Particles.h:112
vtkm::worklet::flow::ParticleAdvectionResult
Definition: worklet/ParticleAdvection.h:52
ParticleAdvectionWorklets.h
vtkm::worklet::flow::Streamline::Run
StreamlineResult< ParticleType > Run(const IntegratorType &it, vtkm::cont::ArrayHandle< ParticleType, ParticleStorage > &particles, vtkm::Id MaxSteps)
Definition: worklet/ParticleAdvection.h:155
vtkm::worklet::flow::ParticleAdvection
Definition: worklet/ParticleAdvection.h:67
vtkm::worklet::flow::ParticleAdvectionResult::Particles
vtkm::cont::ArrayHandle< ParticleType > Particles
Definition: worklet/ParticleAdvection.h:64
Invoker.h
vtkm::worklet::flow::StreamlineResult
Definition: worklet/ParticleAdvection.h:126
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::flow::ParticleAdvection::Run
ParticleAdvectionResult< ParticleType > Run(const IntegratorType &it, const vtkm::cont::ArrayHandle< vtkm::Vec3f, PointStorage > &points, vtkm::Id MaxSteps)
Definition: worklet/ParticleAdvection.h:97
vtkm::worklet::flow::StreamlineWorklet::Run
void Run(const IntegratorType &it, vtkm::cont::ArrayHandle< ParticleType, PointStorage > &particles, vtkm::Id &MaxSteps, vtkm::cont::ArrayHandle< vtkm::Vec3f, PointStorage2 > &positions, vtkm::cont::CellSetExplicit<> &polyLines)
Definition: ParticleAdvectionWorklets.h:176
vtkm::worklet::flow::StreamlineWorklet
Definition: ParticleAdvectionWorklets.h:172
vtkm::worklet::flow::ParticleAdvection::ParticleAdvection
ParticleAdvection()
Definition: worklet/ParticleAdvection.h:70
vtkm::worklet::flow::StreamlineResult::StreamlineResult
StreamlineResult(const vtkm::cont::ArrayHandle< ParticleType > &part, const vtkm::cont::ArrayHandle< vtkm::Vec3f > &pos, const vtkm::cont::CellSetExplicit<> &lines)
Definition: worklet/ParticleAdvection.h:135
vtkm::cont::ArrayHandleCounting< vtkm::Id >
vtkm::cont::Invoker
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
vtkm::cont::ArrayCopy
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
vtkm::cont::ArrayHandleConstant
An array handle with a constant value.
Definition: ArrayHandleConstant.h:63
vtkm::worklet::flow::StreamlineResult::StreamlineResult
StreamlineResult()
Definition: worklet/ParticleAdvection.h:128
vtkm::Vec< vtkm::FloatDefault, 3 >
vtkm::worklet::flow::StreamlineResult::Particles
vtkm::cont::ArrayHandle< ParticleType > Particles
Definition: worklet/ParticleAdvection.h:144
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::worklet::flow::ParticleAdvection::Run2
void Run2(const IntegratorType &it, vtkm::cont::ArrayHandle< ParticleType, ParticleStorage > &particles, vtkm::Id MaxSteps, ParticleAdvectionResult< ParticleType > &result)
Definition: worklet/ParticleAdvection.h:73
vtkm::cont::CellSetExplicit
Definition: CastAndCall.h:36
vtkm::worklet::flow::StreamlineResult::PolyLines
vtkm::cont::CellSetExplicit PolyLines
Definition: worklet/ParticleAdvection.h:146
vtkm::worklet::flow::ParticleAdvectionResult::ParticleAdvectionResult
ParticleAdvectionResult()
Definition: worklet/ParticleAdvection.h:54
vtkm::worklet::flow::ParticleAdvection::Run
ParticleAdvectionResult< ParticleType > Run(const IntegratorType &it, vtkm::cont::ArrayHandle< ParticleType, ParticleStorage > &particles, vtkm::Id MaxSteps)
Definition: worklet/ParticleAdvection.h:85
vtkm::worklet::flow::ParticleAdvectionResult::ParticleAdvectionResult
ParticleAdvectionResult(const vtkm::cont::ArrayHandle< ParticleType > &p)
Definition: worklet/ParticleAdvection.h:59
vtkm::worklet::flow::ParticleAdvectionWorklet::Run
void Run(const IntegratorType &integrator, vtkm::cont::ArrayHandle< ParticleType > &particles, vtkm::Id &MaxSteps)
Definition: ParticleAdvectionWorklets.h:98
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::worklet::flow::StreamlineResult::Positions
vtkm::cont::ArrayHandle< vtkm::Vec3f > Positions
Definition: worklet/ParticleAdvection.h:145