VTK-m  2.0
TransportTagTopologyFieldIn.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 #ifndef vtk_m_cont_arg_TransportTagTopologyFieldIn_h
11 #define vtk_m_cont_arg_TransportTagTopologyFieldIn_h
12 
14 #include <vtkm/Types.h>
15 
16 #include <vtkm/cont/ArrayHandle.h>
17 #include <vtkm/cont/CellSet.h>
18 
20 
21 namespace vtkm
22 {
23 namespace cont
24 {
25 namespace arg
26 {
27 
35 template <typename TopologyElementTag>
37 {
38 };
39 
40 namespace detail
41 {
42 
44 inline static vtkm::Id TopologyDomainSize(const vtkm::cont::CellSet& cellSet,
46 {
47  return cellSet.GetNumberOfPoints();
48 }
49 
51 inline static vtkm::Id TopologyDomainSize(const vtkm::cont::CellSet& cellSet,
53 {
54  return cellSet.GetNumberOfCells();
55 }
56 
58 inline static vtkm::Id TopologyDomainSize(const vtkm::cont::CellSet& cellSet,
60 {
61  return cellSet.GetNumberOfFaces();
62 }
63 
65 inline static vtkm::Id TopologyDomainSize(const vtkm::cont::CellSet& cellSet,
67 {
68  return cellSet.GetNumberOfEdges();
69 }
70 
71 } // namespace detail
72 
73 template <typename TopologyElementTag, typename ContObjectType, typename Device>
75  ContObjectType,
76  Device>
77 {
78  VTKM_IS_ARRAY_HANDLE(ContObjectType);
79 
80 
81  using ExecObjectType = decltype(
82  std::declval<ContObjectType>().PrepareForInput(Device(), std::declval<vtkm::cont::Token&>()));
83 
84  VTKM_CONT
85  ExecObjectType operator()(const ContObjectType& object,
86  const vtkm::cont::CellSet& inputDomain,
87  vtkm::Id,
88  vtkm::Id,
89  vtkm::cont::Token& token) const
90  {
91  if (object.GetNumberOfValues() != detail::TopologyDomainSize(inputDomain, TopologyElementTag()))
92  {
93  throw vtkm::cont::ErrorBadValue("Input array to worklet invocation the wrong size.");
94  }
95 
96  return object.PrepareForInput(Device(), token);
97  }
98 };
99 }
100 }
101 } // namespace vtkm::cont::arg
102 
103 #endif //vtk_m_cont_arg_TransportTagTopologyFieldIn_h
vtkm::TopologyElementTagPoint
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
vtkm::TopologyElementTagFace
A tag used to identify the face elements in a topology.
Definition: TopologyElementTag.h:54
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
vtkm::cont::arg::TransportTagTopologyFieldIn
Transport tag for input arrays in topology maps.
Definition: TransportTagTopologyFieldIn.h:36
vtkm::TopologyElementTagEdge
A tag used to identify the edge elements in a topology.
Definition: TopologyElementTag.h:44
vtkm::cont::arg::Transport< vtkm::cont::arg::TransportTagTopologyFieldIn< TopologyElementTag >, ContObjectType, Device >::operator()
VTKM_CONT ExecObjectType operator()(const ContObjectType &object, const vtkm::cont::CellSet &inputDomain, vtkm::Id, vtkm::Id, vtkm::cont::Token &token) const
Definition: TransportTagTopologyFieldIn.h:85
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
VTKM_IS_ARRAY_HANDLE
#define VTKM_IS_ARRAY_HANDLE(T)
Definition: ArrayHandle.h:132
vtkm::cont::CellSet::GetNumberOfPoints
virtual vtkm::Id GetNumberOfPoints() const =0
vtkm::cont::CellSet::GetNumberOfCells
virtual vtkm::Id GetNumberOfCells() const =0
vtkm::cont::arg::Transport< vtkm::cont::arg::TransportTagTopologyFieldIn< TopologyElementTag >, ContObjectType, Device >::ExecObjectType
decltype(std::declval< ContObjectType >().PrepareForInput(Device(), std::declval< vtkm::cont::Token & >())) ExecObjectType
Definition: TransportTagTopologyFieldIn.h:82
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
CellSet.h
vtkm::cont::CellSet
Definition: CellSet.h:24
Transport.h
vtkm::cont::ErrorBadValue
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
vtkm::cont::CellSet::GetNumberOfFaces
virtual vtkm::Id GetNumberOfFaces() const =0
vtkm::cont::arg::Transport
Class for transporting from the control to the execution environment.
Definition: Transport.h:38
vtkm::TopologyElementTagCell
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
TopologyElementTag.h
vtkm::cont::CellSet::GetNumberOfEdges
virtual vtkm::Id GetNumberOfEdges() const =0