VTK-m  2.0
ParticleAdvector.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_internal_ParticleAdvector_h
12 #define vtk_m_filter_flow_internal_ParticleAdvector_h
13 
18 
19 namespace vtkm
20 {
21 namespace filter
22 {
23 namespace flow
24 {
25 namespace internal
26 {
27 
28 template <typename DSIType>
29 class ParticleAdvector
30 {
31 public:
32  ParticleAdvector(const vtkm::filter::flow::internal::BoundsMap& bm,
33  const std::vector<DSIType>& blocks,
34  const bool& useThreaded,
36  : Blocks(blocks)
37  , BoundsMap(bm)
38  , ResultType(parType)
39  , UseThreadedAlgorithm(useThreaded)
40  {
41  }
42 
44  vtkm::FloatDefault stepSize,
45  const vtkm::cont::UnknownArrayHandle& seeds)
46  {
48 
50  seeds.CastAndCallForTypes<ParticleTypeList, VTKM_DEFAULT_STORAGE_LIST>(
51  [&](const auto& concreteSeeds) {
52  result = this->Execute(numSteps, stepSize, concreteSeeds);
53  });
54 
55  return result;
56  }
57 
58 private:
59  template <typename AlgorithmType, typename ParticleType>
61  vtkm::FloatDefault stepSize,
63  {
64  AlgorithmType algo(this->BoundsMap, this->Blocks);
65  algo.Execute(numSteps, stepSize, seeds);
66  return algo.GetOutput();
67  }
68 
69  template <typename ParticleType>
71  vtkm::FloatDefault stepSize,
73  {
74  if (!this->UseThreadedAlgorithm)
75  {
77  {
78  using AlgorithmType = vtkm::filter::flow::internal::
79  AdvectAlgorithm<DSIType, vtkm::worklet::flow::ParticleAdvectionResult, ParticleType>;
80 
81  return this->RunAlgo<AlgorithmType, ParticleType>(numSteps, stepSize, seeds);
82  }
83  else
84  {
85  using AlgorithmType = vtkm::filter::flow::internal::
86  AdvectAlgorithm<DSIType, vtkm::worklet::flow::StreamlineResult, ParticleType>;
87 
88  return this->RunAlgo<AlgorithmType, ParticleType>(numSteps, stepSize, seeds);
89  }
90  }
91  else
92  {
94  {
95  using AlgorithmType = vtkm::filter::flow::internal::AdvectAlgorithmThreaded<
96  DSIType,
98  ParticleType>;
99 
100  return this->RunAlgo<AlgorithmType, ParticleType>(numSteps, stepSize, seeds);
101  }
102  else
103  {
104  using AlgorithmType = vtkm::filter::flow::internal::
105  AdvectAlgorithmThreaded<DSIType, vtkm::worklet::flow::StreamlineResult, ParticleType>;
106 
107  return this->RunAlgo<AlgorithmType, ParticleType>(numSteps, stepSize, seeds);
108  }
109  }
110  }
111 
112 
113  std::vector<DSIType> Blocks;
114  vtkm::filter::flow::internal::BoundsMap BoundsMap;
115  FlowResultType ResultType;
116  bool UseThreadedAlgorithm;
117 };
118 
119 }
120 }
121 }
122 } //vtkm::filter::flow::internal
123 
124 
125 #endif //vtk_m_filter_flow_internal_ParticleAdvector_h
vtkm::cont::UnknownArrayHandle::CastAndCallForTypes
VTKM_CONT void CastAndCallForTypes(Functor &&functor, Args &&... args) const
Call a functor using the underlying array type.
vtkm::cont::ArrayHandle< ParticleType >
BoundsMap.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:406
vtkm::worklet::flow::ParticleAdvectionResult
Definition: worklet/ParticleAdvection.h:52
DataSetIntegrator.h
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::filter::flow::FlowResultType
FlowResultType
Definition: FlowTypes.h:31
AdvectAlgorithm.h
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::List
Definition: List.h:34
AdvectAlgorithmThreaded.h
vtkm::filter::flow::PARTICLE_ADVECT_TYPE
@ PARTICLE_ADVECT_TYPE
Definition: FlowTypes.h:34
vtkm::cont::PartitionedDataSet
Definition: PartitionedDataSet.h:25