Viskores  1.0
FieldNeighborhood.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_FieldNeighborhood_h
19 #define viskores_exec_FieldNeighborhood_h
20 
23 
24 namespace viskores
25 {
26 namespace exec
27 {
28 
41 template <typename FieldPortalType>
43 {
45  FieldNeighborhood(const FieldPortalType& portal, const viskores::exec::BoundaryState& boundary)
46  : Boundary(&boundary)
47  , Portal(portal)
48  {
49  }
50 
51  using ValueType = typename FieldPortalType::ValueType;
52 
70  {
71  return Portal.Get(this->Boundary->NeighborIndexToFlatIndexClamp(i, j, k));
72  }
73 
85  viskores::IdComponent k) const
86  {
87  return Portal.Get(this->Boundary->NeighborIndexToFlatIndex(i, j, k));
88  }
89 
92  ValueType Get(const viskores::Id3& ijk) const
93  {
94  return Portal.Get(this->Boundary->NeighborIndexToFlatIndexClamp(ijk));
95  }
96 
100  {
101  return Portal.Get(this->Boundary->NeighborIndexToFlatIndex(ijk));
102  }
103 
106 
108  FieldPortalType Portal;
109 };
110 
114 template <>
115 struct FieldNeighborhood<viskores::internal::ArrayPortalUniformPointCoordinates>
116 {
118  FieldNeighborhood(const viskores::internal::ArrayPortalUniformPointCoordinates& portal,
119  const viskores::exec::BoundaryState& boundary)
120  : Boundary(&boundary)
121  , Portal(portal)
122  {
123  }
124 
126 
129  {
130  return Portal.Get(this->Boundary->NeighborIndexToFullIndexClamp(i, j, k));
131  }
132 
136  viskores::IdComponent k) const
137  {
138  return Portal.Get(this->Boundary->NeighborIndexToFullIndex(i, j, k));
139  }
140 
142  ValueType Get(const viskores::IdComponent3& ijk) const
143  {
144  return Portal.Get(this->Boundary->NeighborIndexToFullIndexClamp(ijk));
145  }
146 
149  {
150  return Portal.Get(this->Boundary->NeighborIndexToFullIndex(ijk));
151  }
152 
154  viskores::internal::ArrayPortalUniformPointCoordinates Portal;
155 };
156 }
157 } // namespace viskores::exec
158 
159 #endif //viskores_exec_FieldNeighborhood_h
viskores::exec::BoundaryState::NeighborIndexToFullIndexClamp
viskores::Id3 NeighborIndexToFullIndexClamp(const viskores::IdComponent3 &neighbor) const
Takes a local neighborhood index (in the ranges of -neighborhood size to neighborhood size) and retur...
Definition: BoundaryState.h:193
ArrayPortalUniformPointCoordinates.h
viskores::exec::BoundaryState
Provides a neighborhood's placement with respect to the mesh's boundary.
Definition: BoundaryState.h:39
viskores::exec::FieldNeighborhood::Boundary
viskores::exec::BoundaryState const *const Boundary
The viskores::exec::BoundaryState used to find field values from local indices.
Definition: FieldNeighborhood.h:105
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores::exec::FieldNeighborhood::GetUnchecked
ValueType GetUnchecked(const viskores::Id3 &ijk) const
Retrieve a field value relative to the visited element without bounds checking.
Definition: FieldNeighborhood.h:99
BoundaryState.h
viskores::exec::FieldNeighborhood::GetUnchecked
ValueType GetUnchecked(viskores::IdComponent i, viskores::IdComponent j, viskores::IdComponent k) const
Retrieve a field value relative to the visited element without bounds checking.
Definition: FieldNeighborhood.h:83
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::exec::FieldNeighborhood
Retrieves field values from a neighborhood.
Definition: FieldNeighborhood.h:42
viskores::exec::FieldNeighborhood::Get
ValueType Get(const viskores::Id3 &ijk) const
Retrieve a field value relative to the visited element.
Definition: FieldNeighborhood.h:92
viskores::exec::BoundaryState::NeighborIndexToFlatIndexClamp
viskores::Id NeighborIndexToFlatIndexClamp(const viskores::IdComponent3 &neighbor) const
Takes a local neighborhood index (in the ranges of -neighborhood size to neighborhood size) and retur...
Definition: BoundaryState.h:256
viskores::exec::FieldNeighborhood::Get
ValueType Get(viskores::IdComponent i, viskores::IdComponent j, viskores::IdComponent k) const
Retrieve a field value relative to the visited element.
Definition: FieldNeighborhood.h:69
viskores::exec::BoundaryState::NeighborIndexToFullIndex
viskores::Id3 NeighborIndexToFullIndex(const viskores::IdComponent3 &neighbor) const
Takes a local neighborhood index (in the ranges of -neighborhood size to neighborhood size) and retur...
Definition: BoundaryState.h:214
viskores::exec::FieldNeighborhood::ValueType
typename FieldPortalType::ValueType ValueType
Definition: FieldNeighborhood.h:51
viskores::exec::BoundaryState::NeighborIndexToFlatIndex
viskores::Id NeighborIndexToFlatIndex(const viskores::IdComponent3 &neighbor) const
Takes a local neighborhood index (in the ranges of -neighborhood size to neighborhood size) and retur...
Definition: BoundaryState.h:276
viskores::exec::FieldNeighborhood::Portal
FieldPortalType Portal
The array portal containing field values.
Definition: FieldNeighborhood.h:108
viskores::Vec< viskores::Id, 3 >
viskores::exec::FieldNeighborhood::FieldNeighborhood
FieldNeighborhood(const FieldPortalType &portal, const viskores::exec::BoundaryState &boundary)
Definition: FieldNeighborhood.h:45
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59