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 #ifndef vtk_m_exec_arg_FetchTagArrayDirectOutArrayHandleGroupVecVariable_h
11 #define vtk_m_exec_arg_FetchTagArrayDirectOutArrayHandleGroupVecVariable_h
12 
13 #include <vtkm/exec/arg/FetchTagArrayDirectOut.h>
14 
15 // We need to override the fetch for output fields using
16 // ArrayPortalGroupVecVariable because this portal does not behave like most
17 // ArrayPortals. Usually you ignore the Load and implement the Store. But if
18 // you ignore the Load, the VecFromPortal gets no portal to set values into.
19 // Instead, you need to implement the Load to point to the array portal. You
20 // can also ignore the Store because the data is already set in the array at
21 // that point.
22 
23 // This file is included from ArrayHandleGroupVecVariable.h
24 
25 namespace vtkm
26 {
27 namespace exec
28 {
29 namespace arg
30 {
31 
32 // We need to override the fetch for output fields using
33 // ArrayPortalGroupVecVariable because this portal does not behave like most
34 // ArrayPortals. Usually you ignore the Load and implement the Store. But if
35 // you ignore the Load, the VecFromPortal gets no portal to set values into.
36 // Instead, you need to implement the Load to point to the array portal. You
37 // can also ignore the Store because the data is already set in the array at
38 // that point.
39 template <typename ComponentsPortalType, typename OffsetsPortalType>
40 struct Fetch<vtkm::exec::arg::FetchTagArrayDirectOut,
41              vtkm::exec::arg::AspectTagDefault,
42              vtkm::internal::ArrayPortalGroupVecVariable<ComponentsPortalType, OffsetsPortalType>>
43 {
44   using ExecObjectType =
45     vtkm::internal::ArrayPortalGroupVecVariable<ComponentsPortalType, OffsetsPortalType>;
46   using ValueType = typename ExecObjectType::ValueType;
47 
48   VTKM_SUPPRESS_EXEC_WARNINGS
49   template <typename ThreadIndicesType>
50   VTKM_EXEC ValueType Load(const ThreadIndicesType& indices,
51                            const ExecObjectType& arrayPortal) const
52   {
53     return arrayPortal.Get(indices.GetOutputIndex());
54   }
55 
56   VTKM_SUPPRESS_EXEC_WARNINGS
57   template <typename ThreadIndicesType>
58   VTKM_EXEC void Store(const ThreadIndicesType&, const ExecObjectType&, const ValueType&) const
59   {
60     // We can actually ignore this because the VecFromPortal will already have
61     // set new values in the array.
62   }
63 };
64 
65 }
66 }
67 } // namespace vtkm::exec::arg
68 
69 #endif //vtk_m_exec_arg_FetchTagArrayDirectOutArrayHandleGroupVecVariable_h
70