Panzer  Version of the Day
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 "Kokkos_View.hpp"
49 #include "Phalanx_KokkosDeviceTypes.hpp"
50 #include "Teuchos_Assert.hpp"
51 
52 namespace panzer {
53 
54 struct LocalMeshPartition;
55 
57 {
58 public:
59 
61  SubcellConnectivity() = default;
62 
64  ~SubcellConnectivity() = default;
65 
71  KOKKOS_INLINE_FUNCTION
72  int numSubcells() const {return _subcell_to_cells_adj.extent(0)-1;}
73 
79  KOKKOS_INLINE_FUNCTION
80  int numCells() const {return _cell_to_subcells_adj.extent(0)-1;}
81 
91  KOKKOS_INLINE_FUNCTION
92  int numSubcellsOnCell(const int cell) const;
93  inline
94  int numSubcellsOnCellHost(const int cell) const;
95 
107  KOKKOS_INLINE_FUNCTION
108  int numCellsOnSubcell(const int subcell) const;
109  inline
110  int numCellsOnSubcellHost(const int subcell) const;
111 
126  KOKKOS_INLINE_FUNCTION
127  int subcellForCell(const int cell, const int local_subcell_index) const;
128  inline
129  int subcellForCellHost(const int cell, const int local_subcell_index) const;
130 
145  KOKKOS_INLINE_FUNCTION
146  int cellForSubcell(const int subcell, const int local_cell_index) const;
147  inline
148  int cellForSubcellHost(const int subcell, const int local_cell_index) const;
149 
160  KOKKOS_INLINE_FUNCTION
161  int localSubcellForSubcell(const int subcell, const int local_cell_index) const;
162  inline
163  int localSubcellForSubcellHost(const int subcell, const int local_cell_index) const;
164 
165 protected:
166 
168  PHX::View<int*> _subcell_to_cells_adj;
169  PHX::View<int*>::HostMirror _subcell_to_cells_adj_host;
170 
172  PHX::View<int*> _subcell_to_cells;
173  PHX::View<int*>::HostMirror _subcell_to_cells_host;
174 
176  PHX::View<int*> _subcell_to_local_subcells;
177  PHX::View<int*>::HostMirror _subcell_to_local_subcells_host;
178 
180  PHX::View<int*> _cell_to_subcells_adj;
181  PHX::View<int*>::HostMirror _cell_to_subcells_adj_host;
182 
184  PHX::View<int*> _cell_to_subcells;
185  PHX::View<int*>::HostMirror _cell_to_subcells_host;
186 
187 };
188 
195  public SubcellConnectivity
196 {
197 public:
198 
200  FaceConnectivity() = default;
201 
203  ~FaceConnectivity() = default;
204 
210  void setup(const panzer::LocalMeshPartition & partition);
211 
212 };
213 
214 // **********************************
215 // Inlined functions
216 // **********************************
217 
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 int
240 numCellsOnSubcell(const int subcell) const
241 {
242 #ifdef PANZER_DEBUG
243  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
244 #endif
245  return _subcell_to_cells_adj(subcell+1)-_subcell_to_cells_adj(subcell);
246 }
247 
248 int
250 numCellsOnSubcellHost(const int subcell) const
251 {
252 #ifdef PANZER_DEBUG
253  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
254 #endif
255  return _subcell_to_cells_adj_host(subcell+1)-_subcell_to_cells_adj_host(subcell);
256 }
257 
258 int
260 subcellForCell(const int cell, const int local_subcell_index) const
261 {
262 #ifdef PANZER_DEBUG
263  KOKKOS_ASSERT(cell >= 0 and cell < numCells());
264  KOKKOS_ASSERT(local_subcell_index < numSubcellsOnCell(cell));
265 #endif
266  const int index = _cell_to_subcells_adj(cell)+local_subcell_index;
267  return _cell_to_subcells(index);
268 }
269 
270 int
272 subcellForCellHost(const int cell, const int local_subcell_index) const
273 {
274 #ifdef PANZER_DEBUG
275  KOKKOS_ASSERT(cell >= 0 and cell < numCell());
276  KOKKOS_ASSERT(local_subcell_index < numSubcellsOnCellHost(cell));
277 #endif
278  const int index = _cell_to_subcells_adj_host(cell)+local_subcell_index;
279  return _cell_to_subcells_host(index);
280 }
281 
282 int
284 cellForSubcell(const int subcell, const int local_cell_index) const
285 {
286 #ifdef PANZER_DEBUG
287  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
288  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
289 #endif
290  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
291  return _subcell_to_cells(index);
292 }
293 
294 int
296 cellForSubcellHost(const int subcell, const int local_cell_index) const
297 {
298 #ifdef PANZER_DEBUG
299  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
300  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcellHost(subcell));
301 #endif
302  const int index = _subcell_to_cells_adj_host(subcell)+local_cell_index;
303  return _subcell_to_cells_host(index);
304 }
305 
306 int
308 localSubcellForSubcell(const int subcell, const int local_cell_index) const
309 {
310 #ifdef PANZER_DEBUG
311  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
312  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
313 #endif
314  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
315  return _subcell_to_local_subcells(index);
316 }
317 
318 int
320 localSubcellForSubcellHost(const int subcell, const int local_cell_index) const
321 {
322 #ifdef PANZER_DEBUG
323  KOKKOS_ASSERT(subcell >= 0 and subcell < numSubcells());
324  KOKKOS_ASSERT(local_cell_index < numCellsOnSubcellHost(subcell));
325 #endif
326  const int index = _subcell_to_cells_adj_host(subcell)+local_cell_index;
327  return _subcell_to_local_subcells_host(index);
328 }
329 
330 } // namespace panzer
331 
332 #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 numCellsOnSubcellHost(const int subcell) const
KOKKOS_INLINE_FUNCTION int numSubcellsOnCell(const int cell) const
gives number of subcells (e.g. faces) found on a given cell
KOKKOS_INLINE_FUNCTION int numSubcells() const
Gives number of subcells (e.g. faces) in connectivity.
PHX::View< int * >::HostMirror _subcell_to_cells_adj_host
~SubcellConnectivity()=default
Default destructor.
FaceConnectivity()=default
Default constructor.
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
PHX::View< int * > _subcell_to_local_subcells
Mapping from subcell indexes to local subcell indexes.
KOKKOS_INLINE_FUNCTION int numCellsOnSubcell(const int subcell) const
Returns the number of cells attached to a given subcell.
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.
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.
int localSubcellForSubcellHost(const int subcell, const int local_cell_index) const
KOKKOS_INLINE_FUNCTION int numCells() const
Gives number of cells in connectivity.
PHX::View< int * > _subcell_to_cells_adj
Adjacency array for indexing into subcell_to_cells array.
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
~FaceConnectivity()=default
Default destructor.
PHX::View< int * > _subcell_to_cells
Mapping from subcells to cells.
SubcellConnectivity()=default
Default constructor.
int numSubcellsOnCellHost(const int cell) const
int subcellForCellHost(const int cell, const int local_subcell_index) const
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.