Viskores  1.0
TransportTagTopologyFieldIn.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_cont_arg_TransportTagTopologyFieldIn_h
19 #define viskores_cont_arg_TransportTagTopologyFieldIn_h
20 
22 #include <viskores/Types.h>
23 
25 #include <viskores/cont/CellSet.h>
26 
28 
29 namespace viskores
30 {
31 namespace cont
32 {
33 namespace arg
34 {
35 
43 template <typename TopologyElementTag>
45 {
46 };
47 
48 namespace detail
49 {
50 
52 inline static viskores::Id TopologyDomainSize(const viskores::cont::CellSet& cellSet,
54 {
55  return cellSet.GetNumberOfPoints();
56 }
57 
59 inline static viskores::Id TopologyDomainSize(const viskores::cont::CellSet& cellSet,
61 {
62  return cellSet.GetNumberOfCells();
63 }
64 
66 inline static viskores::Id TopologyDomainSize(const viskores::cont::CellSet& cellSet,
68 {
69  return cellSet.GetNumberOfFaces();
70 }
71 
73 inline static viskores::Id TopologyDomainSize(const viskores::cont::CellSet& cellSet,
75 {
76  return cellSet.GetNumberOfEdges();
77 }
78 
79 } // namespace detail
80 
81 template <typename TopologyElementTag, typename ContObjectType, typename Device>
83  ContObjectType,
84  Device>
85 {
86  VISKORES_IS_ARRAY_HANDLE(ContObjectType);
87 
88 
89  using ExecObjectType = decltype(std::declval<ContObjectType>().PrepareForInput(
90  Device(),
91  std::declval<viskores::cont::Token&>()));
92 
94  ExecObjectType operator()(const ContObjectType& object,
95  const viskores::cont::CellSet& inputDomain,
98  viskores::cont::Token& token) const
99  {
100  if (object.GetNumberOfValues() != detail::TopologyDomainSize(inputDomain, TopologyElementTag()))
101  {
102  throw viskores::cont::ErrorBadValue("Input array to worklet invocation the wrong size.");
103  }
104 
105  return object.PrepareForInput(Device(), token);
106  }
107 };
108 }
109 }
110 } // namespace viskores::cont::arg
111 
112 #endif //viskores_cont_arg_TransportTagTopologyFieldIn_h
ArrayHandle.h
viskores::TopologyElementTagCell
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:32
Types.h
viskores::cont::arg::Transport
Class for transporting from the control to the execution environment.
Definition: Transport.h:46
VISKORES_IS_ARRAY_HANDLE
#define VISKORES_IS_ARRAY_HANDLE(T)
Checks that the given type is a viskores::cont::ArrayHandle.
Definition: ArrayHandle.h:145
viskores::cont::CellSet::GetNumberOfFaces
virtual viskores::Id GetNumberOfFaces() const =0
viskores::TopologyElementTagEdge
A tag used to identify the edge elements in a topology.
Definition: TopologyElementTag.h:52
viskores::cont::arg::Transport< viskores::cont::arg::TransportTagTopologyFieldIn< TopologyElementTag >, ContObjectType, Device >::operator()
ExecObjectType operator()(const ContObjectType &object, const viskores::cont::CellSet &inputDomain, viskores::Id, viskores::Id, viskores::cont::Token &token) const
Definition: TransportTagTopologyFieldIn.h:94
viskores::TopologyElementTagPoint
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:42
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::cont::CellSet::GetNumberOfCells
virtual viskores::Id GetNumberOfCells() const =0
Get the number of cells in the topology.
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::cont::CellSet::GetNumberOfEdges
virtual viskores::Id GetNumberOfEdges() const =0
CellSet.h
viskores::TopologyElementTagFace
A tag used to identify the face elements in a topology.
Definition: TopologyElementTag.h:62
Transport.h
viskores::cont::arg::Transport< viskores::cont::arg::TransportTagTopologyFieldIn< TopologyElementTag >, ContObjectType, Device >::ExecObjectType
decltype(std::declval< ContObjectType >().PrepareForInput(Device(), std::declval< viskores::cont::Token & >())) ExecObjectType
Definition: TransportTagTopologyFieldIn.h:91
viskores::cont::arg::TransportTagTopologyFieldIn
Transport tag for input arrays in topology maps.
Definition: TransportTagTopologyFieldIn.h:44
viskores::cont::ErrorBadValue
This class is thrown when a Viskores function or method encounters an invalid value that inhibits pro...
Definition: ErrorBadValue.h:33
viskores::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
viskores::cont::CellSet
Defines the topological structure of the data in a DataSet.
Definition: CellSet.h:36
viskores::cont::CellSet::GetNumberOfPoints
virtual viskores::Id GetNumberOfPoints() const =0
Get the number of points in the topology.
TopologyElementTag.h