VTK
vtkmCellSetExplicit.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 // This software is distributed WITHOUT ANY WARRANTY; without even
6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 // PURPOSE. See the above copyright notice for more information.
8 //
9 // Copyright 2015 Sandia Corporation.
10 // Copyright 2015 UT-Battelle, LLC.
11 // Copyright 2015 Los Alamos National Security.
12 //
13 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
14 // the U.S. Government retains certain rights in this software.
15 //
16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 // Laboratory (LANL), the U.S. Government retains certain rights in
18 // this software.
19 //============================================================================
20 #ifndef vtkmCellSetExplicit_h
21 #define vtkmCellSetExplicit_h
22 #ifndef __VTK_WRAP__
23 #ifndef VTK_WRAPPING_CXX
24 
25 #include "vtkmTags.h"
26 
27 #include <vtkm/CellShape.h>
28 #include <vtkm/TopologyElementTag.h>
29 #include <vtkm/cont/ArrayHandle.h>
30 #include <vtkm/cont/CellSet.h>
31 
32 #include <vtkm/cont/serial/DeviceAdapterSerial.h>
33 #include <vtkm/cont/cuda/DeviceAdapterCuda.h>
34 #include <vtkm/cont/tbb/DeviceAdapterTBB.h>
35 
36 #include "vtkmConnectivityExec.h"
37 
38 namespace vtkm {
39 namespace cont {
40 
41 class VTKACCELERATORSVTKM_EXPORT vtkmCellSetExplicitAOS : public CellSet
42 {
43 public:
45  : CellSet(name), Shapes(), Connectivity(), IndexOffsets(),
46  ReverseConnectivityBuilt(false),RConn(), RNumIndices(), RIndexOffsets(),
47  NumberOfPoints(0)
48  {
49  }
50 
52  {
53  }
54 
56  {
57  this->CellSet::operator=(src);
58  this->Shapes = src.Shapes;
59  this->Connectivity = src.Connectivity;
60  this->IndexOffsets = src.IndexOffsets;
61  this->ReverseConnectivityBuilt = src.ReverseConnectivityBuilt;
62  this->RConn = src.RConn;
63  this->RNumIndices = src.RNumIndices;
64  this->RIndexOffsets = src.RIndexOffsets;
65  this->NumberOfPoints = src.NumberOfPoints;
66  return *this;
67  }
68 
69  vtkm::Id GetNumberOfCells() const
70  {
71  return this->Shapes.GetNumberOfValues();
72  }
73 
74  vtkm::Id GetNumberOfPoints() const
75  {
76  return this->NumberOfPoints;
77  }
78 
79  virtual vtkm::Id GetNumberOfFaces() const { return -1; }
80 
81  virtual vtkm::Id GetNumberOfEdges() const { return -1; }
82 
83 
84  vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const
85  {
86  return this->GetNumberOfCells();
87  }
88 
89  vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagPoint) const
90  {
91  return this->GetNumberOfPoints();
92  }
93 
94  vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id index) const;
95 
96  vtkm::Id GetCellShape(vtkm::Id index) const;
97 
100  void Fill(
101  vtkm::Id numberOfPoints,
102  const vtkm::cont::ArrayHandle<vtkm::UInt8,
104  const vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>&
105  connectivity,
106  const vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkAOSArrayContainerTag>&
107  offsets);
108 
109  template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
111 
112  template <typename DeviceAdapter>
113  struct ExecutionTypes<DeviceAdapter, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
114  {
116  };
117 
118  template <typename DeviceAdapter>
119  struct ExecutionTypes<DeviceAdapter, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>
120  {
122  };
123 
124  template <typename Device>
126  PrepareForInput(Device, vtkm::TopologyElementTagPoint,
127  vtkm::TopologyElementTagCell) const;
128 
129  template <typename Device>
131  PrepareForInput(Device, vtkm::TopologyElementTagCell,
132  vtkm::TopologyElementTagPoint) const;
133 
134  const vtkm::cont::ArrayHandle<vtkm::UInt8, tovtkm::vtkAOSArrayContainerTag>&
135  GetShapesArray(vtkm::TopologyElementTagPoint,
136  vtkm::TopologyElementTagCell) const
137  {
138  return this->Shapes;
139  }
140 
141  const vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>&
142  GetConnectivityArray(vtkm::TopologyElementTagPoint,
143  vtkm::TopologyElementTagCell) const
144  {
145  return this->Connectivity;
146  }
147 
148  const vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkAOSArrayContainerTag>&
149  GetIndexOffsetArray(vtkm::TopologyElementTagPoint,
150  vtkm::TopologyElementTagCell) const
151  {
152  return this->IndexOffsets;
153  }
154 
155  virtual void PrintSummary(std::ostream& out) const;
156 
157 private:
158  vtkm::cont::ArrayHandle<vtkm::UInt8, tovtkm::vtkAOSArrayContainerTag> Shapes;
159  vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>
160  Connectivity;
161  vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkAOSArrayContainerTag>
162  IndexOffsets;
163 
164  //Reverse connectivity (cell -> point)
165  //Todo: Need a better way to represent that PrepareForInput is a
166  // non-const operation, but that is going to take some real
167  // code refactoring in vtk-m
168  mutable bool ReverseConnectivityBuilt;
169  mutable vtkm::cont::ArrayHandle<vtkm::Id> RConn;
170  mutable vtkm::cont::ArrayHandle<vtkm::IdComponent> RNumIndices;
171  mutable vtkm::cont::ArrayHandle<vtkm::Id> RIndexOffsets;
172  mutable vtkm::Id NumberOfPoints;
173 
174 };
175 
176 // template methods we want to compile only once
177 extern template VTKACCELERATORSVTKM_TEMPLATE_EXPORT
179  vtkmCellSetExplicitAOS::PrepareForInput(vtkm::cont::DeviceAdapterTagSerial,
180  vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const;
181 
182 extern template VTKACCELERATORSVTKM_TEMPLATE_EXPORT
184  vtkmCellSetExplicitAOS::PrepareForInput(vtkm::cont::DeviceAdapterTagSerial,
185  vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint) const;
186 
187 #ifdef VTKM_ENABLE_TBB
188 extern template VTKACCELERATORSVTKM_TEMPLATE_EXPORT
190  vtkmCellSetExplicitAOS::PrepareForInput(vtkm::cont::DeviceAdapterTagTBB,
191  vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const;
192 
193 extern template VTKACCELERATORSVTKM_TEMPLATE_EXPORT
195  vtkmCellSetExplicitAOS::PrepareForInput(vtkm::cont::DeviceAdapterTagTBB,
196  vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint) const;
197 #endif
198 
199 #if defined(VTKM_ENABLE_CUDA) && defined(VTKM_CUDA)
200 extern template VTKACCELERATORSVTKM_TEMPLATE_EXPORT
202  vtkmCellSetExplicitAOS::PrepareForInput(vtkm::cont::DeviceAdapterTagCuda,
203  vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const;
204 
205 extern template VTKACCELERATORSVTKM_TEMPLATE_EXPORT
207  vtkmCellSetExplicitAOS::PrepareForInput(vtkm::cont::DeviceAdapterTagCuda,
208  vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint) const;
209 #endif
210 }
211 }
212 
213 #endif
214 #endif
215 #endif
216 // VTK-HeaderTest-Exclude: vtkmCellSetExplicit.h
vtkmCellSetExplicitAOS(const std::string &name=std::string())
const vtkm::cont::ArrayHandle< vtkm::Id, tovtkm::vtkCellArrayContainerTag > & GetConnectivityArray(vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const
const vtkm::cont::ArrayHandle< vtkm::UInt8, tovtkm::vtkAOSArrayContainerTag > & GetShapesArray(vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const
virtual vtkm::Id GetNumberOfFaces() const
vtkm::exec::ConnectivityVTKAOS< Device > PrepareForInput(Device, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const
vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const
const vtkm::cont::ArrayHandle< vtkm::Id, tovtkm::vtkAOSArrayContainerTag > & GetIndexOffsetArray(vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const
virtual vtkm::Id GetNumberOfEdges() const
vtkmCellSetExplicitAOS & operator=(const vtkmCellSetExplicitAOS &src)
vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagPoint) const