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 struct LocalMeshPartition;
55 
57 {
58 public:
59 
62 
64  ~SubcellConnectivity() = default;
65 
71  KOKKOS_INLINE_FUNCTION
72  int numSubcells() const {return _num_subcells;}
73 
79  KOKKOS_INLINE_FUNCTION
80  int numCells() const {return _num_cells;}
81 
91  KOKKOS_INLINE_FUNCTION
92  int numSubcellsOnCell(const int cell) const;
93 
105  KOKKOS_INLINE_FUNCTION
106  int numCellsOnSubcell(const int subcell) const;
107 
122  KOKKOS_INLINE_FUNCTION
123  int subcellForCell(const int cell, const int local_subcell_index) const;
124 
139  KOKKOS_INLINE_FUNCTION
140  int cellForSubcell(const int subcell, const int local_cell_index) const;
141 
152  KOKKOS_INLINE_FUNCTION
153  int localSubcellForSubcell(const int subcell, const int local_cell_index) const;
154 
155 protected:
156 
159 
162 
164  Kokkos::View<int*, PHX::Device> _subcell_to_cells_adj;
165 
167  Kokkos::View<int*, PHX::Device> _subcell_to_cells;
168 
170  Kokkos::View<int*, PHX::Device> _subcell_to_local_subcells;
171 
173  Kokkos::View<int*, PHX::Device> _cell_to_subcells_adj;
174 
176  Kokkos::View<int*, PHX::Device> _cell_to_subcells;
177 
178 };
179 
186  public SubcellConnectivity
187 {
188 public:
189 
191  FaceConnectivity() = default;
192 
194  ~FaceConnectivity() = default;
195 
201  void setup(const panzer::LocalMeshPartition & partition);
202 
203 };
204 
205 // **********************************
206 // Inlined functions
207 // **********************************
208 
209 int
211 numSubcellsOnCell(const int cell) const
212 {
213 #ifdef PANZER_DEBUG
214 #ifndef KOKKOS_ENABLE_CUDA
215  TEUCHOS_ASSERT(cell >= 0 and cell < _num_cells);
216 #endif
217 #endif
218  return _cell_to_subcells_adj(cell+1)-_cell_to_subcells_adj(cell);
219 }
220 
221 int
223 numCellsOnSubcell(const int subcell) const
224 {
225 #ifdef PANZER_DEBUG
226 #ifndef KOKKOS_ENABLE_CUDA
227  TEUCHOS_ASSERT(subcell >= 0 and subcell < _num_subcells);
228 #endif
229 #endif
230  return _subcell_to_cells_adj(subcell+1)-_subcell_to_cells_adj(subcell);
231 }
232 
233 int
235 subcellForCell(const int cell, const int local_subcell_index) const
236 {
237 #ifdef PANZER_DEBUG
238 #ifndef KOKKOS_ENABLE_CUDA
239  TEUCHOS_ASSERT(cell >= 0 and cell < _num_cells);
240  TEUCHOS_ASSERT(local_subcell_index < numSubcellsOnCell(cell));
241 #endif
242 #endif
243  const int index = _cell_to_subcells_adj(cell)+local_subcell_index;
244  return _cell_to_subcells(index);
245 }
246 
247 int
249 cellForSubcell(const int subcell, const int local_cell_index) const
250 {
251 #ifdef PANZER_DEBUG
252 #ifndef KOKKOS_ENABLE_CUDA
253  TEUCHOS_ASSERT(subcell >= 0 and subcell < _num_subcells);
254  TEUCHOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
255 #endif
256 #endif
257  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
258  return _subcell_to_cells(index);
259 }
260 
261 int
263 localSubcellForSubcell(const int subcell, const int local_cell_index) const
264 {
265 #ifdef PANZER_DEBUG
266 #ifndef KOKKOS_ENABLE_CUDA
267  TEUCHOS_ASSERT(subcell >= 0 and subcell < _num_subcells);
268  TEUCHOS_ASSERT(local_cell_index < numCellsOnSubcell(subcell));
269 #endif
270 #endif
271  const int index = _subcell_to_cells_adj(subcell)+local_cell_index;
272  return _subcell_to_local_subcells(index);
273 }
274 
275 } // namespace panzer
276 
277 #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.
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.
void setup(const panzer::LocalMeshPartition &partition)
Setup the face connectivity from a partition of the local mesh.
~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.