VTK-m  2.0
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 
35 template <typename FieldPortalType>
37 {
38  VTKM_EXEC
39  FieldNeighborhood(const FieldPortalType& portal, const vtkm::exec::BoundaryState& boundary)
40  : Boundary(&boundary)
41  , Portal(portal)
42  {
43  }
44 
45  using ValueType = typename FieldPortalType::ValueType;
46 
47  VTKM_EXEC
49  {
50  return Portal.Get(this->Boundary->NeighborIndexToFlatIndexClamp(i, j, k));
51  }
52 
53  VTKM_EXEC
55  {
56  return Portal.Get(this->Boundary->NeighborIndexToFlatIndex(i, j, k));
57  }
58 
59  VTKM_EXEC
60  ValueType Get(const vtkm::Id3& ijk) const
61  {
62  return Portal.Get(this->Boundary->NeighborIndexToFlatIndexClamp(ijk));
63  }
64 
65  VTKM_EXEC
66  ValueType GetUnchecked(const vtkm::Id3& ijk) const
67  {
68  return Portal.Get(this->Boundary->NeighborIndexToFlatIndex(ijk));
69  }
70 
72  FieldPortalType Portal;
73 };
74 
78 template <>
79 struct FieldNeighborhood<vtkm::internal::ArrayPortalUniformPointCoordinates>
80 {
81  VTKM_EXEC
82  FieldNeighborhood(const vtkm::internal::ArrayPortalUniformPointCoordinates& portal,
83  const vtkm::exec::BoundaryState& boundary)
84  : Boundary(&boundary)
85  , Portal(portal)
86  {
87  }
88 
90 
91  VTKM_EXEC
93  {
94  return Portal.Get(this->Boundary->NeighborIndexToFullIndexClamp(i, j, k));
95  }
96 
97  VTKM_EXEC
99  {
100  return Portal.Get(this->Boundary->NeighborIndexToFullIndex(i, j, k));
101  }
102 
103  VTKM_EXEC
104  ValueType Get(const vtkm::IdComponent3& ijk) const
105  {
106  return Portal.Get(this->Boundary->NeighborIndexToFullIndexClamp(ijk));
107  }
108 
109  VTKM_EXEC
110  ValueType GetUnchecked(const vtkm::IdComponent3& ijk) const
111  {
112  return Portal.Get(this->Boundary->NeighborIndexToFullIndex(ijk));
113  }
114 
115  vtkm::exec::BoundaryState const* const Boundary;
116  vtkm::internal::ArrayPortalUniformPointCoordinates Portal;
117 };
118 }
119 } // namespace vtkm::exec
120 
121 #endif //vtk_m_exec_FieldNeighborhood_h
vtkm::exec::FieldNeighborhood::Get
VTKM_EXEC ValueType Get(const vtkm::Id3 &ijk) const
Definition: FieldNeighborhood.h:60
vtkm::exec::BoundaryState
Provides a neighborhood's placement with respect to the mesh's boundary.
Definition: BoundaryState.h:31
vtkm::exec::BoundaryState::NeighborIndexToFullIndex
VTKM_EXEC vtkm::Id3 NeighborIndexToFullIndex(const vtkm::IdComponent3 &neighbor) const
Definition: BoundaryState.h:184
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::BoundaryState::NeighborIndexToFlatIndexClamp
VTKM_EXEC vtkm::Id NeighborIndexToFlatIndexClamp(const vtkm::IdComponent3 &neighbor) const
Definition: BoundaryState.h:227
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::exec::FieldNeighborhood::Portal
FieldPortalType Portal
Definition: FieldNeighborhood.h:72
vtkm::exec::BoundaryState::NeighborIndexToFlatIndex
VTKM_EXEC vtkm::Id NeighborIndexToFlatIndex(const vtkm::IdComponent3 &neighbor) const
Definition: BoundaryState.h:247
vtkm::exec::FieldNeighborhood::GetUnchecked
VTKM_EXEC ValueType GetUnchecked(vtkm::IdComponent i, vtkm::IdComponent j, vtkm::IdComponent k) const
Definition: FieldNeighborhood.h:54
vtkm::exec::FieldNeighborhood::FieldNeighborhood
VTKM_EXEC FieldNeighborhood(const FieldPortalType &portal, const vtkm::exec::BoundaryState &boundary)
Definition: FieldNeighborhood.h:39
BoundaryState.h
vtkm::exec::FieldNeighborhood::Get
VTKM_EXEC ValueType Get(vtkm::IdComponent i, vtkm::IdComponent j, vtkm::IdComponent k) const
Definition: FieldNeighborhood.h:48
vtkm::exec::FieldNeighborhood::ValueType
typename FieldPortalType::ValueType ValueType
Definition: FieldNeighborhood.h:45
vtkm::exec::FieldNeighborhood::GetUnchecked
VTKM_EXEC ValueType GetUnchecked(const vtkm::Id3 &ijk) const
Definition: FieldNeighborhood.h:66
vtkm::Vec< vtkm::Id, 3 >
vtkm::exec::FieldNeighborhood::Boundary
vtkm::exec::BoundaryState const *const Boundary
Definition: FieldNeighborhood.h:71
vtkm::exec::BoundaryState::NeighborIndexToFullIndexClamp
VTKM_EXEC vtkm::Id3 NeighborIndexToFullIndexClamp(const vtkm::IdComponent3 &neighbor) const
Definition: BoundaryState.h:164
vtkm::exec::FieldNeighborhood
Retrieves field values from a neighborhood.
Definition: FieldNeighborhood.h:36