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 "Kokkos_View.hpp"
49 #include "Phalanx_KokkosDeviceTypes.hpp"
50 #include "Teuchos_Assert.hpp"
51 
52 namespace panzer {
53 
54 template <typename LO, typename GO>
55 struct LocalMeshPartition;
56 
58 {
59 public:
60 
63 
65  ~SubcellConnectivity() = default;
66 
72  KOKKOS_INLINE_FUNCTION
73  int numSubcells() const {return _num_subcells;}
74 
80  KOKKOS_INLINE_FUNCTION
81  int numCells() const {return _num_cells;}
82 
92  KOKKOS_INLINE_FUNCTION
93  int numSubcellsOnCell(const int cell) const;
94 
106  KOKKOS_INLINE_FUNCTION
107  int numCellsOnSubcell(const int subcell) const;
108 
123  KOKKOS_INLINE_FUNCTION
124  int subcellForCell(const int cell, const int local_subcell_index) const;
125 
140  KOKKOS_INLINE_FUNCTION
141  int cellForSubcell(const int subcell, const int local_cell_index) const;
142 
153  KOKKOS_INLINE_FUNCTION
154  int localSubcellForSubcell(const int subcell, const int local_cell_index) const;
155 
156 protected:
157 
160 
163 
165  Kokkos::View<int*, PHX::Device> _subcell_to_cells_adj;
166 
168  Kokkos::View<int*, PHX::Device> _subcell_to_cells;
169 
171  Kokkos::View<int*, PHX::Device> _subcell_to_local_subcells;
172 
174  Kokkos::View<int*, PHX::Device> _cell_to_subcells_adj;
175 
177  Kokkos::View<int*, PHX::Device> _cell_to_subcells;
178 
179 };
180 
187  public SubcellConnectivity
188 {
189 public:
190 
192  FaceConnectivity() = default;
193 
195  ~FaceConnectivity() = default;
196 
203 
204 };
205 
206 // **********************************
207 // Inlined functions
208 // **********************************
209 
210 int
212 numSubcellsOnCell(const int cell) const
213 {
214 #ifdef PANZER_DEBUG
215 #ifndef KOKKOS_ENABLE_CUDA
216  TEUCHOS_ASSERT(cell >= 0 and cell < _num_cells);
217 #endif
218 #endif
219  return _cell_to_subcells_adj(cell+1)-_cell_to_subcells_adj(cell);
220 }
221 
222 int
224 numCellsOnSubcell(const int subcell) const
225 {
226 #ifdef PANZER_DEBUG
227 #ifndef KOKKOS_ENABLE_CUDA
228  TEUCHOS_ASSERT(subcell >= 0 and subcell < _num_subcells);
229 #endif
230 #endif
231  return _subcell_to_cells_adj(subcell+1)-_subcell_to_cells_adj(subcell);
232 }
233 
234 int
236 subcellForCell(const int cell, const int local_subcell_index) const
237 {
238 #ifdef PANZER_DEBUG
239 #ifndef KOKKOS_ENABLE_CUDA
240  TEUCHOS_ASSERT(cell >= 0 and cell < _num_cells);
241  TEUCHOS_ASSERT(local_subcell_index < numSubcellsOnCell(cell));
242 #endif
243 #endif
244  const int index = _cell_to_subcells_adj(cell)+local_subcell_index;
245  return _cell_to_subcells(index);
246 }
247 
248 int
250 cellForSubcell(const int subcell, const int local_cell_index) const
251 {
252 #ifdef PANZER_DEBUG
253 #ifndef KOKKOS_ENABLE_CUDA
254  TEUCHOS_ASSERT(subcell >= 0 and subcell < _num_subcells);
255  TEUCHOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
256 #endif
257 #endif
258  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
259  return _subcell_to_cells(index);
260 }
261 
262 int
264 localSubcellForSubcell(const int subcell, const int local_cell_index) const
265 {
266 #ifdef PANZER_DEBUG
267 #ifndef KOKKOS_ENABLE_CUDA
268  TEUCHOS_ASSERT(subcell >= 0 and subcell < _num_subcells);
269  TEUCHOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
270 #endif
271 #endif
272  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
273  return _subcell_to_local_subcells(index);
274 }
275 
276 } // namespace panzer
277 
278 #endif
Kokkos::View< int *, PHX::Device > _subcell_to_cells
Mapping from subcells to cells.
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 _num_subcells
Number of subcells for a given number of cells.
Kokkos::View< int *, PHX::Device > _cell_to_subcells_adj
Adjacency array for indexing into cell_to_subcells array.
~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.
Generates a SubcellConnectivity associated with faces and cells given a partition of the local mesh...
KOKKOS_INLINE_FUNCTION int numCells() const
Gives number of cells in connectivity.
Kokkos::View< int *, PHX::Device > _cell_to_subcells
Mapping from cells to subcells.
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.
void setup(const panzer::LocalMeshPartition< int, panzer::Ordinal64 > &partition)
Setup the face connectivity from a partition of the local mesh.
KOKKOS_INLINE_FUNCTION int numSubcellsOnCell(const int cell) const
gives number of subcells (e.g. faces) found on a given cell
Kokkos::View< int *, PHX::Device > _subcell_to_local_subcells
Mapping from subcell indexes to local subcell indexes.
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.
KOKKOS_INLINE_FUNCTION int numSubcells() const
Gives number of subcells (e.g. faces) in connectivity.
~FaceConnectivity()=default
Default destructor.
Kokkos::View< int *, PHX::Device > _subcell_to_cells_adj
Adjacency array for indexing into subcell_to_cells array.
#define TEUCHOS_ASSERT(assertion_test)
SubcellConnectivity()
Default constructor.