Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_SubcellConnectivity.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef PANZER_SUBCELL_CONNECTIVITY_HPP
12 #define PANZER_SUBCELL_CONNECTIVITY_HPP
13 
14 #include "PanzerCore_config.hpp"
15 #include "Phalanx_KokkosDeviceTypes.hpp"
16 #include "Teuchos_Assert.hpp"
17 
18 namespace panzer {
19 
20 struct LocalMeshPartition;
21 
23 {
24 public:
25 
27  SubcellConnectivity() = default;
28 
30  ~SubcellConnectivity() = default;
31 
37  KOKKOS_INLINE_FUNCTION
38  int numSubcells() const {return _subcell_to_cells_adj.extent(0)-1;}
39 
45  KOKKOS_INLINE_FUNCTION
46  int numCells() const {return _cell_to_subcells_adj.extent(0)-1;}
47 
57  KOKKOS_INLINE_FUNCTION
58  int numSubcellsOnCell(const int cell) const;
59  inline
60  int numSubcellsOnCellHost(const int cell) const;
61 
73  KOKKOS_INLINE_FUNCTION
74  int numCellsOnSubcell(const int subcell) const;
75  inline
76  int numCellsOnSubcellHost(const int subcell) const;
77 
92  KOKKOS_INLINE_FUNCTION
93  int subcellForCell(const int cell, const int local_subcell_index) const;
94  inline
95  int subcellForCellHost(const int cell, const int local_subcell_index) const;
96 
111  KOKKOS_INLINE_FUNCTION
112  int cellForSubcell(const int subcell, const int local_cell_index) const;
113  inline
114  int cellForSubcellHost(const int subcell, const int local_cell_index) const;
115 
126  KOKKOS_INLINE_FUNCTION
127  int localSubcellForSubcell(const int subcell, const int local_cell_index) const;
128  inline
129  int localSubcellForSubcellHost(const int subcell, const int local_cell_index) const;
130 
131 protected:
132 
134  PHX::View<int*> _subcell_to_cells_adj;
135  PHX::View<int*>::HostMirror _subcell_to_cells_adj_host;
136 
138  PHX::View<int*> _subcell_to_cells;
139  PHX::View<int*>::HostMirror _subcell_to_cells_host;
140 
142  PHX::View<int*> _subcell_to_local_subcells;
143  PHX::View<int*>::HostMirror _subcell_to_local_subcells_host;
144 
146  PHX::View<int*> _cell_to_subcells_adj;
147  PHX::View<int*>::HostMirror _cell_to_subcells_adj_host;
148 
150  PHX::View<int*> _cell_to_subcells;
151  PHX::View<int*>::HostMirror _cell_to_subcells_host;
152 
153 };
154 
161  public SubcellConnectivity
162 {
163 public:
164 
166  FaceConnectivity() = default;
167 
169  ~FaceConnectivity() = default;
170 
176  void setup(const panzer::LocalMeshPartition & partition);
177 
178 };
179 
180 // **********************************
181 // Inlined functions
182 // **********************************
183 
184 PHALANX_HIP_HACK_KOKKOS_FUNCTION
185 int
187 numSubcellsOnCell(const int cell) const
188 {
189 #ifdef PANZER_DEBUG
190  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
191 #endif
192  return _cell_to_subcells_adj(cell+1)-_cell_to_subcells_adj(cell);
193 }
194 
195 int
197 numSubcellsOnCellHost(const int cell) const
198 {
199 #ifdef PANZER_DEBUG
200  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
201 #endif
203 }
204 
205 PHALANX_HIP_HACK_KOKKOS_FUNCTION
206 int
208 numCellsOnSubcell(const int subcell) const
209 {
210 #ifdef PANZER_DEBUG
211  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
212 #endif
213  return _subcell_to_cells_adj(subcell+1)-_subcell_to_cells_adj(subcell);
214 }
215 
216 int
218 numCellsOnSubcellHost(const int subcell) const
219 {
220 #ifdef PANZER_DEBUG
221  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
222 #endif
223  return _subcell_to_cells_adj_host(subcell+1)-_subcell_to_cells_adj_host(subcell);
224 }
225 
226 PHALANX_HIP_HACK_KOKKOS_FUNCTION
227 int
229 subcellForCell(const int cell, const int local_subcell_index) const
230 {
231 #ifdef PANZER_DEBUG
232  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
233  KOKKOS_ASSERT(local_subcell_index < numSubcellsOnCell(cell));
234 #endif
235  const int index = _cell_to_subcells_adj(cell)+local_subcell_index;
236  return _cell_to_subcells(index);
237 }
238 
239 int
241 subcellForCellHost(const int cell, const int local_subcell_index) const
242 {
243 #ifdef PANZER_DEBUG
244  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
245  KOKKOS_ASSERT(local_subcell_index < numSubcellsOnCellHost(cell));
246 #endif
247  const int index = _cell_to_subcells_adj_host(cell)+local_subcell_index;
248  return _cell_to_subcells_host(index);
249 }
250 
251 PHALANX_HIP_HACK_KOKKOS_FUNCTION
252 int
254 cellForSubcell(const int subcell, const int local_cell_index) const
255 {
256 #ifdef PANZER_DEBUG
257  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
258  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
259 #endif
260  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
261  return _subcell_to_cells(index);
262 }
263 
264 int
266 cellForSubcellHost(const int subcell, const int local_cell_index) const
267 {
268 #ifdef PANZER_DEBUG
269  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
270  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcellHost(subcell));
271 #endif
272  const int index = _subcell_to_cells_adj_host(subcell)+local_cell_index;
273  return _subcell_to_cells_host(index);
274 }
275 
276 PHALANX_HIP_HACK_KOKKOS_FUNCTION
277 int
279 localSubcellForSubcell(const int subcell, const int local_cell_index) const
280 {
281 #ifdef PANZER_DEBUG
282  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
283  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
284 #endif
285  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
286  return _subcell_to_local_subcells(index);
287 }
288 
289 int
291 localSubcellForSubcellHost(const int subcell, const int local_cell_index) const
292 {
293 #ifdef PANZER_DEBUG
294  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
295  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcellHost(subcell));
296 #endif
297  const int index = _subcell_to_cells_adj_host(subcell)+local_cell_index;
298  return _subcell_to_local_subcells_host(index);
299 }
300 
301 } // namespace panzer
302 
303 #endif
KOKKOS_INLINE_FUNCTION int cellForSubcell(const int subcell, const int local_cell_index) const
Get the cell for a given subcell and a local_cell_index.
int numSubcellsOnCellHost(const int cell) const
PHX::View< int * >::HostMirror _subcell_to_cells_adj_host
~SubcellConnectivity()=default
Default destructor.
KOKKOS_INLINE_FUNCTION int numCellsOnSubcell(const int subcell) const
Returns the number of cells attached to a given subcell.
FaceConnectivity()=default
Default constructor.
KOKKOS_INLINE_FUNCTION int localSubcellForSubcell(const int subcell, const int local_cell_index) const
Get the local subcell index given a subcell and a local cell index.
KOKKOS_INLINE_FUNCTION int numSubcellsOnCell(const int cell) const
gives number of subcells (e.g. faces) found on a given cell
PHX::View< int * >::HostMirror _subcell_to_local_subcells_host
Generates a SubcellConnectivity associated with faces and cells given a partition of the local mesh...
PHX::View< int * >::HostMirror _cell_to_subcells_adj_host
KOKKOS_INLINE_FUNCTION int numCells() const
Gives number of cells in connectivity.
PHX::View< int * > _subcell_to_local_subcells
Mapping from subcell indexes to local subcell indexes.
int cellForSubcellHost(const int subcell, const int local_cell_index) const
PHX::View< int * >::HostMirror _subcell_to_cells_host
PHX::View< int * > _cell_to_subcells
Mapping from cells to subcells.
PHX::View< int * > _subcell_to_cells_adj
Adjacency array for indexing into subcell_to_cells array.
KOKKOS_INLINE_FUNCTION int numSubcells() const
Gives number of subcells (e.g. faces) in connectivity.
PHX::View< int * > _cell_to_subcells_adj
Adjacency array for indexing into cell_to_subcells array.
void setup(const panzer::LocalMeshPartition &partition)
Setup the face connectivity from a partition of the local mesh.
PHX::View< int * >::HostMirror _cell_to_subcells_host
int subcellForCellHost(const int cell, const int local_subcell_index) const
~FaceConnectivity()=default
Default destructor.
PHX::View< int * > _subcell_to_cells
Mapping from subcells to cells.
int numCellsOnSubcellHost(const int subcell) const
int localSubcellForSubcellHost(const int subcell, const int local_cell_index) const
SubcellConnectivity()=default
Default constructor.
KOKKOS_INLINE_FUNCTION int subcellForCell(const int cell, const int local_subcell_index) const
Get the subcell index for a given cell and local subcell index.