Viskores  1.0
FetchExtrude.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_exec_arg_FetchExtrude_h
19 #define viskores_exec_arg_FetchExtrude_h
20 
24 
26 
27 //optimized fetches for ArrayPortalXGCCoordinates for
28 // - 3D Scheduling
29 // - WorkletNeighboorhood
30 namespace viskores
31 {
32 namespace exec
33 {
34 namespace arg
35 {
36 
43 {
44 };
45 
46 //Optimized fetch for point ids when iterating the cells ConnectivityExtrude
47 template <typename FetchType, typename ExecObjectType>
48 struct Fetch<FetchType, viskores::exec::arg::AspectTagIncidentElementIndices, ExecObjectType>
49 {
51  template <typename ScatterAndMaskMode>
54  ScatterAndMaskMode>& indices,
55  const ExecObjectType&) const -> viskores::Vec<viskores::Id, 6>
56  {
57  // std::cout << "opimized fetch for point ids" << std::endl;
58  const auto& xgcidx = indices.GetIndicesIncident();
59  const viskores::Id offset1 = (xgcidx.Planes[0] * xgcidx.NumberOfPointsPerPlane);
60  const viskores::Id offset2 = (xgcidx.Planes[1] * xgcidx.NumberOfPointsPerPlane);
62  result[0] = offset1 + xgcidx.PointIds[0][0];
63  result[1] = offset1 + xgcidx.PointIds[0][1];
64  result[2] = offset1 + xgcidx.PointIds[0][2];
65  result[3] = offset2 + xgcidx.PointIds[1][0];
66  result[4] = offset2 + xgcidx.PointIds[1][1];
67  result[5] = offset2 + xgcidx.PointIds[1][2];
68  return result;
69  }
70 
72  template <typename ConnectivityType, typename ScatterAndMaskMode>
75  indices,
76  const ExecObjectType&) const -> decltype(indices.GetIndicesIncident())
77  {
78  return indices.GetIndicesIncident();
79  }
80 
81  template <typename ThreadIndicesType, typename ValueType>
82  VISKORES_EXEC void Store(const ThreadIndicesType&, const ExecObjectType&, const ValueType&) const
83  {
84  // Store is a no-op.
85  }
86 };
87 
88 //Optimized fetch for point coordinates when iterating the cells of ConnectivityExtrude
89 template <typename T>
92  viskores::internal::ArrayPortalXGCCoordinates<T>>
93 
94 {
95  //Optimized fetch for point arrays when iterating the cells ConnectivityExtrude
97  template <typename ScatterAndMaskMode>
98  VISKORES_EXEC auto Load(
100  ScatterAndMaskMode>& indices,
101  const viskores::internal::ArrayPortalXGCCoordinates<T>& portal)
102  -> decltype(portal.GetWedge(indices.GetIndicesIncident()))
103  {
104  return portal.GetWedge(indices.GetIndicesIncident());
105  }
106 
108  template <typename ThreadIndicesType>
109  VISKORES_EXEC auto Load(const ThreadIndicesType& indices,
110  const viskores::internal::ArrayPortalXGCCoordinates<T>& field) const
111  -> decltype(detail::FetchArrayTopologyMapInImplementation<
112  typename ThreadIndicesType::Connectivity,
113  viskores::internal::ArrayPortalXGCCoordinates<T>,
114  ThreadIndicesType>::Load(indices, field))
115  {
116  using Implementation = detail::FetchArrayTopologyMapInImplementation<
117  typename ThreadIndicesType::Connectivity,
118  viskores::internal::ArrayPortalXGCCoordinates<T>,
119  ThreadIndicesType>;
120  return Implementation::Load(indices, field);
121  }
122 
123  template <typename ThreadIndicesType, typename ValueType>
124  VISKORES_EXEC void Store(const ThreadIndicesType&,
125  const viskores::internal::ArrayPortalXGCCoordinates<T>&,
126  const ValueType&) const
127  {
128  // Store is a no-op for this fetch.
129  }
130 };
131 
132 //Optimized fetch for point coordinates when iterating the points of ConnectivityExtrude
133 template <typename T>
134 struct Fetch<viskores::exec::arg::FetchTagArrayDirectIn,
136  viskores::internal::ArrayPortalXGCCoordinates<T>>
137 
138 {
140  template <typename ThreadIndicesType>
141  VISKORES_EXEC auto Load(const ThreadIndicesType& indices,
142  const viskores::internal::ArrayPortalXGCCoordinates<T>& points)
143  -> decltype(points.Get(indices.GetInputIndex()))
144  {
145  // std::cout << "optimized fetch for point coordinates" << std::endl;
146  return points.Get(indices.GetInputIndex());
147  }
148 
150  template <typename ScatterAndMaskMode>
151  VISKORES_EXEC auto Load(
153  ScatterAndMaskMode>& indices,
154  const viskores::internal::ArrayPortalXGCCoordinates<T>& points)
155  -> decltype(points.Get(indices.GetIndexLogical()))
156  {
157  // std::cout << "optimized fetch for point coordinates" << std::endl;
158  return points.Get(indices.GetIndexLogical());
159  }
160 
161  template <typename ThreadIndicesType, typename ValueType>
162  VISKORES_EXEC void Store(const ThreadIndicesType&,
163  const viskores::internal::ArrayPortalXGCCoordinates<T>&,
164  const ValueType&) const
165  {
166  // Store is a no-op for this fetch.
167  }
168 };
169 }
170 }
171 }
172 
173 
174 #endif
viskores::exec::ConnectivityExtrude
Definition: ConnectivityExtrude.h:34
VISKORES_SUPPRESS_EXEC_WARNINGS
#define VISKORES_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:61
viskores::exec::arg::AspectTagIncidentElementIndices
Aspect tag to use for getting the visited indices.
Definition: FetchExtrude.h:42
viskores::exec::arg::ThreadIndicesTopologyMap
Container for thread indices in a topology map.
Definition: ThreadIndicesTopologyMap.h:103
ConnectivityExtrude.h
viskores::exec::ReverseConnectivityExtrude
Definition: ConnectivityExtrude.h:104
viskores::exec::arg::Fetch< FetchType, viskores::exec::arg::AspectTagIncidentElementIndices, ExecObjectType >::Load
auto Load(const viskores::exec::arg::ThreadIndicesTopologyMap< viskores::exec::ConnectivityExtrude, ScatterAndMaskMode > &indices, const ExecObjectType &) const -> viskores::Vec< viskores::Id, 6 >
Definition: FetchExtrude.h:52
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::exec::arg::Fetch::ValueType
typename ExecObjectType::ValueType ValueType
The type of value to load and store.
Definition: Fetch.h:66
viskores::exec::arg::Fetch
Class for loading and storing values in thread instance.
Definition: Fetch.h:57
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::exec::arg::Fetch::Store
void Store(const ThreadIndicesType &indices, const ExecObjectType &execObject, const ValueType &value) const
Store data from a work instance.
viskores::exec::arg::FetchTagArrayTopologyMapIn
Fetch tag for getting array values determined by topology connections.
Definition: FetchTagArrayTopologyMapIn.h:48
viskores::exec::arg::AspectTagDefault
Aspect tag to use for default load/store of data.
Definition: AspectTagDefault.h:30
FetchTagArrayTopologyMapIn.h
FetchTagArrayDirectIn.h
viskores::exec::arg::Fetch< FetchType, viskores::exec::arg::AspectTagIncidentElementIndices, ExecObjectType >::Store
void Store(const ThreadIndicesType &, const ExecObjectType &, const ValueType &) const
Definition: FetchExtrude.h:82
viskores::exec::arg::Fetch< FetchType, viskores::exec::arg::AspectTagIncidentElementIndices, ExecObjectType >::Load
auto Load(const viskores::exec::arg::ThreadIndicesTopologyMap< ConnectivityType, ScatterAndMaskMode > &indices, const ExecObjectType &) const -> decltype(indices.GetIndicesIncident())
Definition: FetchExtrude.h:73
viskores::exec::arg::Fetch::Load
ValueType Load(const ThreadIndicesType &indices, const ExecObjectType &execObject) const
Load data for a work instance.
ArrayHandleXGCCoordinates.h
viskores::Vec
A short fixed-length array.
Definition: Types.h:365
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59