VTK-m  2.0
EulerIntegrator.h
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // Copyright (c) Kitware, Inc.
4 // All rights reserved.
5 // See LICENSE.txt for details.
6 //
7 // This software is distributed WITHOUT ANY WARRANTY; without even
8 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9 // PURPOSE. See the above copyright notice for more information.
10 //
11 //=============================================================================
12 
13 #ifndef vtk_m_filter_flow_worklet_EulerIntegrator_h
14 #define vtk_m_filter_flow_worklet_EulerIntegrator_h
15 
18 
19 namespace vtkm
20 {
21 namespace worklet
22 {
23 namespace flow
24 {
25 
26 template <typename EvaluatorType>
28 {
29 public:
31  ExecEulerIntegrator(const EvaluatorType& evaluator)
32  : Evaluator(evaluator)
33  {
34  }
35 
36  template <typename Particle>
38  vtkm::FloatDefault stepLength,
39  vtkm::Vec3f& velocity) const
40  {
41  auto time = particle.GetTime();
42  auto inpos = particle.GetEvaluationPosition(stepLength);
44  GridEvaluatorStatus evalStatus = this->Evaluator.Evaluate(inpos, time, vectors);
45  if (evalStatus.CheckFail())
46  return IntegratorStatus(evalStatus, false);
47 
48  velocity = particle.Velocity(vectors, stepLength);
49 
50  return IntegratorStatus(
51  evalStatus, vtkm::MagnitudeSquared(velocity) <= vtkm::Epsilon<vtkm::FloatDefault>());
52  }
53 
54 private:
55  EvaluatorType Evaluator;
56 };
57 
58 template <typename EvaluatorType>
60 {
61 private:
62  EvaluatorType Evaluator;
63 
64 public:
65  EulerIntegrator() = default;
66 
67  VTKM_CONT
68  EulerIntegrator(const EvaluatorType& evaluator)
69  : Evaluator(evaluator)
70  {
71  }
72 
74  vtkm::cont::Token& token) const
75  -> ExecEulerIntegrator<decltype(this->Evaluator.PrepareForExecution(device, token))>
76  {
77  auto evaluator = this->Evaluator.PrepareForExecution(device, token);
78  using ExecEvaluatorType = decltype(evaluator);
80  }
81 }; //EulerIntegrator
82 
83 }
84 }
85 } //vtkm::worklet::flow
86 
87 #endif // vtk_m_filter_flow_worklet_EulerIntegrator_h
vtkm::MagnitudeSquared
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type MagnitudeSquared(const T &x)
Returns the square of the magnitude of a vector.
Definition: VectorAnalysis.h:64
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::EulerIntegrator::Evaluator
EvaluatorType Evaluator
Definition: EulerIntegrator.h:62
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::Particle
Definition: Particle.h:90
vtkm::Particle::GetEvaluationPosition
VTKM_EXEC_CONT vtkm::Vec3f GetEvaluationPosition(const vtkm::FloatDefault &deltaT) const
Definition: Particle.h:155
GridEvaluatorStatus.h
vtkm::worklet::flow::GridEvaluatorStatus::CheckFail
VTKM_EXEC_CONT bool CheckFail() const
Definition: GridEvaluatorStatus.h:39
vtkm::worklet::flow::EulerIntegrator::PrepareForExecution
VTKM_CONT auto PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const -> ExecEulerIntegrator< decltype(this->Evaluator.PrepareForExecution(device, token))>
Definition: EulerIntegrator.h:73
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::worklet::flow::EulerIntegrator
Definition: EulerIntegrator.h:59
vtkm::worklet::flow::EulerIntegrator::EulerIntegrator
VTKM_CONT EulerIntegrator(const EvaluatorType &evaluator)
Definition: EulerIntegrator.h:68
vtkm::VecVariable
A short variable-length array with maximum length.
Definition: VecVariable.h:30
vtkm::worklet::flow::IntegratorStatus
Definition: IntegratorStatus.h:33
vtkm::Particle::GetTime
VTKM_EXEC_CONT vtkm::FloatDefault GetTime() const
Definition: Particle.h:141
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Particle::Velocity
VTKM_EXEC_CONT vtkm::Vec3f Velocity(const vtkm::VecVariable< vtkm::Vec3f, 2 > &vectors, const vtkm::FloatDefault &vtkmNotUsed(length))
Definition: Particle.h:145
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::Vec< vtkm::FloatDefault, 3 >
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::worklet::flow::EulerIntegrator::EulerIntegrator
EulerIntegrator()=default
vtkm::worklet::flow::ExecEulerIntegrator::Evaluator
EvaluatorType Evaluator
Definition: EulerIntegrator.h:55
vtkm::worklet::flow::ExecEulerIntegrator::CheckStep
VTKM_EXEC IntegratorStatus CheckStep(Particle &particle, vtkm::FloatDefault stepLength, vtkm::Vec3f &velocity) const
Definition: EulerIntegrator.h:37
IntegratorStatus.h
vtkm::worklet::flow::ExecEulerIntegrator
Definition: EulerIntegrator.h:27
vtkm::worklet::flow::ExecEulerIntegrator::ExecEulerIntegrator
VTKM_EXEC_CONT ExecEulerIntegrator(const EvaluatorType &evaluator)
Definition: EulerIntegrator.h:31
vtkm::worklet::flow::GridEvaluatorStatus
Definition: GridEvaluatorStatus.h:23