VTK-m  2.0
GradientOutput.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_worklet_gradient_GradientOutput_h
12 #define vtk_m_worklet_gradient_GradientOutput_h
13 
14 #include <vtkm/VecTraits.h>
15 
18 
21 
25 
26 namespace vtkm
27 {
28 namespace exec
29 {
30 
31 template <typename T>
33 {
36 
39 
41 
43  vtkm::Id size,
45  vtkm::cont::Token& token)
46  {
47  this->GradientPortal = gradient.PrepareForOutput(size, device, token);
48  }
49 
51  VTKM_EXEC
52  void Set(vtkm::Id index, const vtkm::Vec<T, 3>& value) const
53  {
54  this->GradientPortal.Set(index, value);
55  }
56 
58 };
59 
60 template <typename T>
62 {
65 
68  vtkm::cont::Token& token) const
69  {
71  this->Gradient, this->Size, device, token);
72  }
73 
75  bool,
76  bool,
77  bool,
82  vtkm::Id size)
83  : Size(size)
84  , Gradient(gradient)
85  {
86  }
89 };
90 
91 template <typename T>
93 {
96 
97  template <typename FieldType>
99 
101 
103  bool d,
104  bool v,
105  bool q,
110  vtkm::Id size,
112  vtkm::cont::Token& token)
113  {
114  this->SetGradient = g;
115  this->SetDivergence = d;
116  this->SetVorticity = v;
117  this->SetQCriterion = q;
118 
119  if (g)
120  {
121  this->GradientPortal = gradient.PrepareForOutput(size, device, token);
122  }
123  if (d)
124  {
125  this->DivergencePortal = divergence.PrepareForOutput(size, device, token);
126  }
127  if (v)
128  {
129  this->VorticityPortal = vorticity.PrepareForOutput(size, device, token);
130  }
131  if (q)
132  {
133  this->QCriterionPortal = qcriterion.PrepareForOutput(size, device, token);
134  }
135  }
136 
138  VTKM_EXEC
139  void Set(vtkm::Id index, const vtkm::Vec<T, 3>& value) const
140  {
141  if (this->SetGradient)
142  {
143  this->GradientPortal.Set(index, value);
144  }
145  if (this->SetDivergence)
146  {
148  BaseTType output;
149  divergence(value, output);
150  this->DivergencePortal.Set(index, output);
151  }
152  if (this->SetVorticity)
153  {
155  T output;
156  vorticity(value, output);
157  this->VorticityPortal.Set(index, output);
158  }
159  if (this->SetQCriterion)
160  {
162  BaseTType output;
163  qc(value, output);
164  this->QCriterionPortal.Set(index, output);
165  }
166  }
167 
172 
177 };
178 
179 template <typename T>
181 {
184 
187  vtkm::cont::Token& token) const
188  {
190  this->D,
191  this->V,
192  this->Q,
193  this->Gradient,
194  this->Divergence,
195  this->Vorticity,
196  this->Qcriterion,
197  this->Size,
198  device,
199  token);
200  }
201 
202  GradientVecOutput() = default;
203 
205  bool d,
206  bool v,
207  bool q,
212  vtkm::Id size)
213  {
214  this->G = g;
215  this->D = d;
216  this->V = v;
217  this->Q = q;
218  this->Gradient = gradient;
219  this->Divergence = divergence;
220  this->Vorticity = vorticity;
221  this->Qcriterion = qcriterion;
222  this->Size = size;
223  }
224 
225  bool G;
226  bool D;
227  bool V;
228  bool Q;
234 };
235 
236 template <typename T>
238 {
240 };
241 
242 template <>
243 struct GradientOutput<vtkm::Vec3f_32> : public GradientVecOutput<vtkm::Vec3f_32>
244 {
246 };
247 
248 template <>
249 struct GradientOutput<vtkm::Vec3f_64> : public GradientVecOutput<vtkm::Vec3f_64>
250 {
252 };
253 }
254 } // namespace vtkm::exec
255 
256 
257 namespace vtkm
258 {
259 namespace cont
260 {
261 namespace arg
262 {
263 
270 {
271 };
272 
273 template <typename ContObjectType, typename Device>
274 struct Transport<vtkm::cont::arg::TransportTagGradientOut, ContObjectType, Device>
275 {
277  using ExecObjectType = decltype(
278  std::declval<ExecObjectFactoryType>().PrepareForExecution(Device(),
279  std::declval<vtkm::cont::Token&>()));
280 
281  template <typename InputDomainType>
282  VTKM_CONT ExecObjectType operator()(ContObjectType object,
283  const InputDomainType& vtkmNotUsed(inputDomain),
284  vtkm::Id vtkmNotUsed(inputRange),
285  vtkm::Id outputRange,
286  vtkm::cont::Token& token) const
287  {
288  ExecObjectFactoryType ExecutionObjectFactory = object.PrepareForOutput(outputRange);
289  return ExecutionObjectFactory.PrepareForExecution(Device(), token);
290  }
291 };
292 }
293 }
294 } // namespace vtkm::cont::arg
295 
296 
297 namespace vtkm
298 {
299 namespace worklet
300 {
301 namespace gradient
302 {
303 
304 
306 {
310 };
311 }
312 }
313 } // namespace vtkm::worklet::gradient
314 
315 #endif
vtkm::exec::GradientScalarOutputExecutionObject::GradientScalarOutputExecutionObject
GradientScalarOutputExecutionObject()=default
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
vtkm::exec::GradientVecOutput::V
bool V
Definition: GradientOutput.h:227
vtkm::exec::GradientVecOutput::PrepareForExecution
VTKM_CONT vtkm::exec::GradientVecOutputExecutionObject< T > PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Definition: GradientOutput.h:185
vtkm::exec::GradientVecOutputExecutionObject::DivergencePortal
PortalType< BaseTType > DivergencePortal
Definition: GradientOutput.h:174
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::exec::GradientVecOutputExecutionObject::BaseTType
typename vtkm::VecTraits< T >::BaseComponentType BaseTType
Definition: GradientOutput.h:95
vtkm::exec::GradientVecOutputExecutionObject::SetDivergence
bool SetDivergence
Definition: GradientOutput.h:169
vtkm::exec::arg::FetchTagArrayDirectOut
Fetch tag for setting array values with direct indexing.
Definition: FetchTagArrayDirectOut.h:29
TransportTagArrayOut.h
vtkm::exec::GradientVecOutputExecutionObject::SetGradient
bool SetGradient
Definition: GradientOutput.h:168
vtkm::exec::GradientScalarOutput::Gradient
vtkm::cont::ArrayHandle< ValueType > Gradient
Definition: GradientOutput.h:88
vtkm::exec::GradientScalarOutputExecutionObject::GradientScalarOutputExecutionObject
GradientScalarOutputExecutionObject(vtkm::cont::ArrayHandle< ValueType > gradient, vtkm::Id size, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: GradientOutput.h:42
vtkm::exec::GradientVecOutput::G
bool G
Definition: GradientOutput.h:225
vtkm::exec::GradientScalarOutputExecutionObject::GradientPortal
PortalType GradientPortal
Definition: GradientOutput.h:57
vtkm::VecTraits::BaseComponentType
typename vtkm::VecTraits< ComponentType >::BaseComponentType BaseComponentType
Base component type in the vector.
Definition: VecTraits.h:80
vtkm::exec::GradientScalarOutput
Definition: GradientOutput.h:61
TransportTagExecObject.h
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::exec::GradientScalarOutputExecutionObject::BaseTType
typename vtkm::VecTraits< T >::BaseComponentType BaseTType
Definition: GradientOutput.h:35
vtkm::exec::GradientVecOutputExecutionObject::VorticityPortal
PortalType< vtkm::Vec< BaseTType, 3 > > VorticityPortal
Definition: GradientOutput.h:175
vtkm::exec::GradientScalarOutputExecutionObject
Definition: GradientOutput.h:32
vtkm::exec::GradientScalarOutput::BaseTType
typename vtkm::VecTraits< T >::BaseComponentType BaseTType
Definition: GradientOutput.h:64
vtkm::exec::GradientVecOutputExecutionObject::GradientPortal
PortalType< ValueType > GradientPortal
Definition: GradientOutput.h:173
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::arg::TypeCheckTagExecObject
The ExecObject type check passes for any object that inherits from ExecutionObjectBase.
Definition: TypeCheckTagExecObject.h:32
vtkm::exec::GradientVecOutput::Size
vtkm::Id Size
Definition: GradientOutput.h:233
vtkm::exec::GradientVecOutputExecutionObject::Set
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC void Set(vtkm::Id index, const vtkm::Vec< T, 3 > &value) const
Definition: GradientOutput.h:139
vtkm::worklet::gradient::Vorticity
Definition: Vorticity.h:26
vtkm::exec::GradientVecOutput
Definition: GradientOutput.h:180
vtkm::exec::GradientScalarOutputExecutionObject::PortalType
typename HandleType::WritePortalType PortalType
Definition: GradientOutput.h:38
Vorticity.h
vtkm::exec::GradientVecOutputExecutionObject::SetVorticity
bool SetVorticity
Definition: GradientOutput.h:170
vtkm::exec::GradientScalarOutput::PrepareForExecution
VTKM_CONT vtkm::exec::GradientScalarOutputExecutionObject< T > PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Definition: GradientOutput.h:66
Divergence.h
vtkm::exec::GradientScalarOutput::GradientScalarOutput
GradientScalarOutput(bool, bool, bool, bool, vtkm::cont::ArrayHandle< ValueType > &gradient, vtkm::cont::ArrayHandle< BaseTType > &, vtkm::cont::ArrayHandle< vtkm::Vec< BaseTType, 3 >> &, vtkm::cont::ArrayHandle< BaseTType > &, vtkm::Id size)
Definition: GradientOutput.h:74
vtkm::exec::GradientVecOutput::GradientVecOutput
GradientVecOutput()=default
vtkm::exec::GradientVecOutput< vtkm::Vec3f_64 >::BaseTType
typename vtkm::VecTraits< vtkm::Vec3f_64 >::BaseComponentType BaseTType
Definition: GradientOutput.h:183
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::arg::Transport< vtkm::cont::arg::TransportTagGradientOut, ContObjectType, Device >::operator()
VTKM_CONT ExecObjectType operator()(ContObjectType object, const InputDomainType &vtkmNotUsed(inputDomain), vtkm::Id vtkmNotUsed(inputRange), vtkm::Id outputRange, vtkm::cont::Token &token) const
Definition: GradientOutput.h:282
vtkm::cont::ArrayHandle::WritePortalType
typename StorageType::WritePortalType WritePortalType
Definition: ArrayHandle.h:295
vtkm::exec::GradientVecOutput::Qcriterion
vtkm::cont::ArrayHandle< BaseTType > Qcriterion
Definition: GradientOutput.h:232
vtkm::exec::GradientVecOutput::Gradient
vtkm::cont::ArrayHandle< ValueType > Gradient
Definition: GradientOutput.h:229
vtkm::cont::arg::TransportTagGradientOut
Transport tag for output arrays.
Definition: GradientOutput.h:269
vtkmNotUsed
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
vtkm::worklet::gradient::QCriterion
Definition: QCriterion.h:25
vtkm::exec::GradientVecOutputExecutionObject::QCriterionPortal
PortalType< BaseTType > QCriterionPortal
Definition: GradientOutput.h:176
vtkm::exec::GradientVecOutput::Divergence
vtkm::cont::ArrayHandle< BaseTType > Divergence
Definition: GradientOutput.h:230
vtkm::cont::ExecutionObjectBase
Base ExecutionObjectBase for execution objects to inherit from so that you can use an arbitrary objec...
Definition: ExecutionObjectBase.h:31
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::exec::GradientVecOutput::GradientVecOutput
GradientVecOutput(bool g, bool d, bool v, bool q, vtkm::cont::ArrayHandle< ValueType > &gradient, vtkm::cont::ArrayHandle< BaseTType > &divergence, vtkm::cont::ArrayHandle< vtkm::Vec< BaseTType, 3 >> &vorticity, vtkm::cont::ArrayHandle< BaseTType > &qcriterion, vtkm::Id size)
Definition: GradientOutput.h:204
vtkm::cont::arg::ControlSignatureTagBase
The base class for all tags used in a ControlSignature.
Definition: ControlSignatureTagBase.h:36
vtkm::Vec< T, 3 >
Definition: Types.h:975
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::exec::GradientVecOutputExecutionObject
Definition: GradientOutput.h:92
vtkm::exec::GradientVecOutput::Q
bool Q
Definition: GradientOutput.h:228
vtkm::exec::GradientOutput
Definition: GradientOutput.h:237
vtkm::cont::ArrayHandle::PrepareForOutput
VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:613
vtkm::cont::arg::Transport< vtkm::cont::arg::TransportTagGradientOut, ContObjectType, Device >::ExecObjectType
decltype(std::declval< ExecObjectFactoryType >().PrepareForExecution(Device(), std::declval< vtkm::cont::Token & >())) ExecObjectType
Definition: GradientOutput.h:279
FetchTagArrayDirectOut.h
vtkm::exec::GradientVecOutputExecutionObject::SetQCriterion
bool SetQCriterion
Definition: GradientOutput.h:171
vtkm::cont::arg::Transport
Class for transporting from the control to the execution environment.
Definition: Transport.h:38
vtkm::exec::GradientVecOutput::Vorticity
vtkm::cont::ArrayHandle< vtkm::Vec< BaseTType, 3 > > Vorticity
Definition: GradientOutput.h:231
QCriterion.h
vtkm::exec::GradientVecOutputExecutionObject::GradientVecOutputExecutionObject
GradientVecOutputExecutionObject(bool g, bool d, bool v, bool q, vtkm::cont::ArrayHandle< ValueType > gradient, vtkm::cont::ArrayHandle< BaseTType > divergence, vtkm::cont::ArrayHandle< vtkm::Vec< BaseTType, 3 >> vorticity, vtkm::cont::ArrayHandle< BaseTType > qcriterion, vtkm::Id size, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: GradientOutput.h:102
vtkm::exec::GradientScalarOutput::Size
vtkm::Id Size
Definition: GradientOutput.h:87
vtkm::worklet::gradient::Divergence
Definition: Divergence.h:26
ExecutionObjectBase.h
VTKM_SUPPRESS_EXEC_WARNINGS
#define VTKM_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:53
vtkm::exec::GradientVecOutputExecutionObject::GradientVecOutputExecutionObject
GradientVecOutputExecutionObject()=default
vtkm::exec::GradientVecOutputExecutionObject::PortalType
typename vtkm::cont::ArrayHandle< FieldType >::WritePortalType PortalType
Definition: GradientOutput.h:98
vtkm::exec::GradientVecOutput::D
bool D
Definition: GradientOutput.h:226
VecTraits.h
vtkm::exec::GradientScalarOutputExecutionObject::Set
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC void Set(vtkm::Id index, const vtkm::Vec< T, 3 > &value) const
Definition: GradientOutput.h:52
vtkm::worklet::gradient::GradientOutputs
Definition: GradientOutput.h:305