VTK-m  2.2
FieldNeighborhood.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_exec_FieldNeighborhood_h
11 #define vtk_m_exec_FieldNeighborhood_h
12 
15 
16 namespace vtkm
17 {
18 namespace exec
19 {
20 
33 template <typename FieldPortalType>
35 {
36  VTKM_EXEC
37  FieldNeighborhood(const FieldPortalType& portal, const vtkm::exec::BoundaryState& boundary)
38  : Boundary(&boundary)
39  , Portal(portal)
40  {
41  }
42 
43  using ValueType = typename FieldPortalType::ValueType;
44 
60  VTKM_EXEC
62  {
63  return Portal.Get(this->Boundary->NeighborIndexToFlatIndexClamp(i, j, k));
64  }
65 
74  VTKM_EXEC
76  {
77  return Portal.Get(this->Boundary->NeighborIndexToFlatIndex(i, j, k));
78  }
79 
81  VTKM_EXEC
82  ValueType Get(const vtkm::Id3& ijk) const
83  {
84  return Portal.Get(this->Boundary->NeighborIndexToFlatIndexClamp(ijk));
85  }
86 
88  VTKM_EXEC
89  ValueType GetUnchecked(const vtkm::Id3& ijk) const
90  {
91  return Portal.Get(this->Boundary->NeighborIndexToFlatIndex(ijk));
92  }
93 
96 
98  FieldPortalType Portal;
99 };
100 
104 template <>
105 struct FieldNeighborhood<vtkm::internal::ArrayPortalUniformPointCoordinates>
106 {
107  VTKM_EXEC
108  FieldNeighborhood(const vtkm::internal::ArrayPortalUniformPointCoordinates& portal,
109  const vtkm::exec::BoundaryState& boundary)
110  : Boundary(&boundary)
111  , Portal(portal)
112  {
113  }
114 
116 
117  VTKM_EXEC
119  {
120  return Portal.Get(this->Boundary->NeighborIndexToFullIndexClamp(i, j, k));
121  }
122 
123  VTKM_EXEC
125  {
126  return Portal.Get(this->Boundary->NeighborIndexToFullIndex(i, j, k));
127  }
128 
129  VTKM_EXEC
130  ValueType Get(const vtkm::IdComponent3& ijk) const
131  {
132  return Portal.Get(this->Boundary->NeighborIndexToFullIndexClamp(ijk));
133  }
134 
135  VTKM_EXEC
136  ValueType GetUnchecked(const vtkm::IdComponent3& ijk) const
137  {
138  return Portal.Get(this->Boundary->NeighborIndexToFullIndex(ijk));
139  }
140 
141  vtkm::exec::BoundaryState const* const Boundary;
142  vtkm::internal::ArrayPortalUniformPointCoordinates Portal;
143 };
144 }
145 } // namespace vtkm::exec
146 
147 #endif //vtk_m_exec_FieldNeighborhood_h
vtkm::exec::FieldNeighborhood::GetUnchecked
ValueType GetUnchecked(const vtkm::Id3 &ijk) const
Retrieve a field value relative to the visited element without bounds checking.
Definition: FieldNeighborhood.h:89
vtkm::exec::BoundaryState
Provides a neighborhood's placement with respect to the mesh's boundary.
Definition: BoundaryState.h:31
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
ArrayPortalUniformPointCoordinates.h
vtkm::exec::FieldNeighborhood::FieldNeighborhood
FieldNeighborhood(const FieldPortalType &portal, const vtkm::exec::BoundaryState &boundary)
Definition: FieldNeighborhood.h:37
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::exec::FieldNeighborhood::Portal
FieldPortalType Portal
The array portal containing field values.
Definition: FieldNeighborhood.h:98
vtkm::exec::FieldNeighborhood::GetUnchecked
ValueType GetUnchecked(vtkm::IdComponent i, vtkm::IdComponent j, vtkm::IdComponent k) const
Retrieve a field value relative to the visited element without bounds checking.
Definition: FieldNeighborhood.h:75
vtkm::exec::BoundaryState::NeighborIndexToFlatIndex
vtkm::Id NeighborIndexToFlatIndex(const vtkm::IdComponent3 &neighbor) const
Takes a local neighborhood index (in the ranges of -neighborhood size to neighborhood size) and retur...
Definition: BoundaryState.h:264
BoundaryState.h
vtkm::exec::FieldNeighborhood::ValueType
typename FieldPortalType::ValueType ValueType
Definition: FieldNeighborhood.h:43
vtkm::exec::BoundaryState::NeighborIndexToFlatIndexClamp
vtkm::Id NeighborIndexToFlatIndexClamp(const vtkm::IdComponent3 &neighbor) const
Takes a local neighborhood index (in the ranges of -neighborhood size to neighborhood size) and retur...
Definition: BoundaryState.h:245
vtkm::Vec< vtkm::Id, 3 >
vtkm::exec::FieldNeighborhood::Get
ValueType Get(const vtkm::Id3 &ijk) const
Retrieve a field value relative to the visited element.
Definition: FieldNeighborhood.h:82
vtkm::exec::BoundaryState::NeighborIndexToFullIndex
vtkm::Id3 NeighborIndexToFullIndex(const vtkm::IdComponent3 &neighbor) const
Takes a local neighborhood index (in the ranges of -neighborhood size to neighborhood size) and retur...
Definition: BoundaryState.h:204
vtkm::exec::FieldNeighborhood::Boundary
vtkm::exec::BoundaryState const *const Boundary
The vtkm::exec::BoundaryState used to find field values from local indices.
Definition: FieldNeighborhood.h:95
vtkm::exec::BoundaryState::NeighborIndexToFullIndexClamp
vtkm::Id3 NeighborIndexToFullIndexClamp(const vtkm::IdComponent3 &neighbor) const
Takes a local neighborhood index (in the ranges of -neighborhood size to neighborhood size) and retur...
Definition: BoundaryState.h:185
vtkm::exec::FieldNeighborhood
Retrieves field values from a neighborhood.
Definition: FieldNeighborhood.h:34
vtkm::exec::FieldNeighborhood::Get
ValueType Get(vtkm::IdComponent i, vtkm::IdComponent j, vtkm::IdComponent k) const
Retrieve a field value relative to the visited element.
Definition: FieldNeighborhood.h:61