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 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 
44 #ifndef PANZER_SUBCELL_CONNECTIVITY_HPP
45 #define PANZER_SUBCELL_CONNECTIVITY_HPP
46 
47 #include "PanzerCore_config.hpp"
48 #include "Phalanx_KokkosDeviceTypes.hpp"
49 #include "Teuchos_Assert.hpp"
50 
51 namespace panzer {
52 
53 struct LocalMeshPartition;
54 
56 {
57 public:
58 
60  SubcellConnectivity() = default;
61 
63  ~SubcellConnectivity() = default;
64 
70  KOKKOS_INLINE_FUNCTION
71  int numSubcells() const {return _subcell_to_cells_adj.extent(0)-1;}
72 
78  KOKKOS_INLINE_FUNCTION
79  int numCells() const {return _cell_to_subcells_adj.extent(0)-1;}
80 
90  KOKKOS_INLINE_FUNCTION
91  int numSubcellsOnCell(const int cell) const;
92  inline
93  int numSubcellsOnCellHost(const int cell) const;
94 
106  KOKKOS_INLINE_FUNCTION
107  int numCellsOnSubcell(const int subcell) const;
108  inline
109  int numCellsOnSubcellHost(const int subcell) const;
110 
125  KOKKOS_INLINE_FUNCTION
126  int subcellForCell(const int cell, const int local_subcell_index) const;
127  inline
128  int subcellForCellHost(const int cell, const int local_subcell_index) const;
129 
144  KOKKOS_INLINE_FUNCTION
145  int cellForSubcell(const int subcell, const int local_cell_index) const;
146  inline
147  int cellForSubcellHost(const int subcell, const int local_cell_index) const;
148 
159  KOKKOS_INLINE_FUNCTION
160  int localSubcellForSubcell(const int subcell, const int local_cell_index) const;
161  inline
162  int localSubcellForSubcellHost(const int subcell, const int local_cell_index) const;
163 
164 protected:
165 
167  PHX::View<int*> _subcell_to_cells_adj;
168  PHX::View<int*>::HostMirror _subcell_to_cells_adj_host;
169 
171  PHX::View<int*> _subcell_to_cells;
172  PHX::View<int*>::HostMirror _subcell_to_cells_host;
173 
175  PHX::View<int*> _subcell_to_local_subcells;
176  PHX::View<int*>::HostMirror _subcell_to_local_subcells_host;
177 
179  PHX::View<int*> _cell_to_subcells_adj;
180  PHX::View<int*>::HostMirror _cell_to_subcells_adj_host;
181 
183  PHX::View<int*> _cell_to_subcells;
184  PHX::View<int*>::HostMirror _cell_to_subcells_host;
185 
186 };
187 
194  public SubcellConnectivity
195 {
196 public:
197 
199  FaceConnectivity() = default;
200 
202  ~FaceConnectivity() = default;
203 
209  void setup(const panzer::LocalMeshPartition & partition);
210 
211 };
212 
213 // **********************************
214 // Inlined functions
215 // **********************************
216 
217 PHALANX_HIP_HACK_KOKKOS_FUNCTION
218 int
220 numSubcellsOnCell(const int cell) const
221 {
222 #ifdef PANZER_DEBUG
223  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
224 #endif
225  return _cell_to_subcells_adj(cell+1)-_cell_to_subcells_adj(cell);
226 }
227 
228 int
230 numSubcellsOnCellHost(const int cell) const
231 {
232 #ifdef PANZER_DEBUG
233  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
234 #endif
236 }
237 
238 PHALANX_HIP_HACK_KOKKOS_FUNCTION
239 int
241 numCellsOnSubcell(const int subcell) const
242 {
243 #ifdef PANZER_DEBUG
244  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
245 #endif
246  return _subcell_to_cells_adj(subcell+1)-_subcell_to_cells_adj(subcell);
247 }
248 
249 int
251 numCellsOnSubcellHost(const int subcell) const
252 {
253 #ifdef PANZER_DEBUG
254  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
255 #endif
256  return _subcell_to_cells_adj_host(subcell+1)-_subcell_to_cells_adj_host(subcell);
257 }
258 
259 PHALANX_HIP_HACK_KOKKOS_FUNCTION
260 int
262 subcellForCell(const int cell, const int local_subcell_index) const
263 {
264 #ifdef PANZER_DEBUG
265  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
266  KOKKOS_ASSERT(local_subcell_index < numSubcellsOnCell(cell));
267 #endif
268  const int index = _cell_to_subcells_adj(cell)+local_subcell_index;
269  return _cell_to_subcells(index);
270 }
271 
272 int
274 subcellForCellHost(const int cell, const int local_subcell_index) const
275 {
276 #ifdef PANZER_DEBUG
277  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
278  KOKKOS_ASSERT(local_subcell_index < numSubcellsOnCellHost(cell));
279 #endif
280  const int index = _cell_to_subcells_adj_host(cell)+local_subcell_index;
281  return _cell_to_subcells_host(index);
282 }
283 
284 PHALANX_HIP_HACK_KOKKOS_FUNCTION
285 int
287 cellForSubcell(const int subcell, const int local_cell_index) const
288 {
289 #ifdef PANZER_DEBUG
290  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
291  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
292 #endif
293  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
294  return _subcell_to_cells(index);
295 }
296 
297 int
299 cellForSubcellHost(const int subcell, const int local_cell_index) const
300 {
301 #ifdef PANZER_DEBUG
302  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
303  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcellHost(subcell));
304 #endif
305  const int index = _subcell_to_cells_adj_host(subcell)+local_cell_index;
306  return _subcell_to_cells_host(index);
307 }
308 
309 PHALANX_HIP_HACK_KOKKOS_FUNCTION
310 int
312 localSubcellForSubcell(const int subcell, const int local_cell_index) const
313 {
314 #ifdef PANZER_DEBUG
315  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
316  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
317 #endif
318  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
319  return _subcell_to_local_subcells(index);
320 }
321 
322 int
324 localSubcellForSubcellHost(const int subcell, const int local_cell_index) const
325 {
326 #ifdef PANZER_DEBUG
327  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
328  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcellHost(subcell));
329 #endif
330  const int index = _subcell_to_cells_adj_host(subcell)+local_cell_index;
331  return _subcell_to_local_subcells_host(index);
332 }
333 
334 } // namespace panzer
335 
336 #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.