Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_SubcellConnectivity.cpp
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 
12 #include "Panzer_LocalMeshInfo.hpp"
13 
14 namespace panzer
15 {
16 
17 void
20 {
21  const int num_cells = partition.cell_to_faces.extent(0);
22  const int num_faces = partition.face_to_cells.extent(0);
23  const int num_faces_per_cell = partition.cell_to_faces.extent(1);
24  const int num_cells_per_face = 2;
25 
26  _subcell_to_cells_adj = PHX::View<int*>("subcell_to_cells_adj", num_faces+1);
27  _subcell_to_cells = PHX::View<int*>("subcell_to_cells", num_faces*num_cells_per_face);
28  _subcell_to_local_subcells = PHX::View<int*>("subcell_to_local_subcells", num_faces*num_cells_per_face);
29  _cell_to_subcells_adj = PHX::View<int*>("cell_to_subcells_adj", num_cells+1);
30  _cell_to_subcells = PHX::View<int*>("cell_to_subcells", num_cells*num_faces_per_cell);
31 
32  // Host copies
33  _subcell_to_cells_adj_host = PHX::View<int*>::HostMirror("subcell_to_cells_adj_host", num_faces+1);
34  _subcell_to_cells_host = PHX::View<int*>::HostMirror("subcell_to_cells_host", num_faces*num_cells_per_face);
35  _subcell_to_local_subcells_host = PHX::View<int*>::HostMirror("subcell_to_local_subcells_host", num_faces*num_cells_per_face);
36  _cell_to_subcells_adj_host = PHX::View<int*>::HostMirror("cell_to_subcells_adj_host", num_cells+1);
37  _cell_to_subcells_host = PHX::View<int*>::HostMirror("cell_to_subcells_host", num_cells*num_faces_per_cell);
38 
39  // This line not needed since kokkos initializes the arrays above to zero
40  //_subcell_to_cells_adj(0)=0;
41 
42  {
43  auto face_to_cells = partition.face_to_cells;
44  auto face_to_lidx = partition.face_to_lidx;
45  auto subcell_to_cells_adj = _subcell_to_cells_adj;
46  auto subcell_to_cells = _subcell_to_cells;
47  auto subcell_to_local_subcells = _subcell_to_local_subcells;
48  Kokkos::parallel_for("subcell connectivity 0",num_faces,KOKKOS_LAMBDA (const int face) {
49  subcell_to_cells_adj(face+1) = (face * num_cells_per_face) + num_cells_per_face;
50  subcell_to_cells(num_cells_per_face*face + 0) = face_to_cells(face,0);
51  subcell_to_cells(num_cells_per_face*face + 1) = face_to_cells(face,1);
52  subcell_to_local_subcells(num_cells_per_face*face + 0) = face_to_lidx(face,0);
53  subcell_to_local_subcells(num_cells_per_face*face + 1) = face_to_lidx(face,1);
54  });
55  PHX::Device::execution_space().fence();
56  }
57 
58  // This line not needed since kokkos initializes the arrays above to zero
59  //_cell_to_subcells_adj(0)=0;
60 
61  {
62  auto cell_to_faces = partition.cell_to_faces;
63  auto cell_to_subcells_adj = _cell_to_subcells_adj;
64  auto cell_to_subcells = _cell_to_subcells;
65  Kokkos::parallel_for("subcell connectivity 1",num_cells,KOKKOS_LAMBDA (const int cell) {
66  cell_to_subcells_adj(cell+1) = (cell * num_faces_per_cell) + num_faces_per_cell;
67  for(int local_face=0;local_face<num_faces_per_cell;++local_face){
68  cell_to_subcells(num_faces_per_cell*cell+local_face) = cell_to_faces(cell,local_face);
69  }
70  });
71  PHX::Device::execution_space().fence();
72  }
73 
74  // Copy values to host
75  Kokkos::deep_copy(_subcell_to_cells_adj_host, _subcell_to_cells_adj);
76  Kokkos::deep_copy(_subcell_to_cells_host, _subcell_to_cells);
77  Kokkos::deep_copy(_subcell_to_local_subcells_host,_subcell_to_local_subcells);
78  Kokkos::deep_copy(_cell_to_subcells_adj_host,_cell_to_subcells_adj);
79  Kokkos::deep_copy(_cell_to_subcells_host,_cell_to_subcells);
80 }
81 
82 }
PHX::View< int * >::HostMirror _subcell_to_cells_adj_host
PHX::View< int * >::HostMirror _subcell_to_local_subcells_host
PHX::View< panzer::LocalOrdinal *[2]> face_to_cells
PHX::View< int * >::HostMirror _cell_to_subcells_adj_host
PHX::View< int * > _subcell_to_local_subcells
Mapping from subcell indexes to local subcell indexes.
PHX::View< panzer::LocalOrdinal *[2]> face_to_lidx
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.
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
PHX::View< int * > _subcell_to_cells
Mapping from subcells to cells.
PHX::View< panzer::LocalOrdinal ** > cell_to_faces