Panzer Version of the Day
Loading...
Searching...
No Matches
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
13
14namespace panzer
15{
16
17void
19setup(const panzer::LocalMeshPartition & partition)
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*>::host_mirror_type("subcell_to_cells_adj_host", num_faces+1);
34 _subcell_to_cells_host = PHX::View<int*>::host_mirror_type("subcell_to_cells_host", num_faces*num_cells_per_face);
35 _subcell_to_local_subcells_host = PHX::View<int*>::host_mirror_type("subcell_to_local_subcells_host", num_faces*num_cells_per_face);
36 _cell_to_subcells_adj_host = PHX::View<int*>::host_mirror_type("cell_to_subcells_adj_host", num_cells+1);
37 _cell_to_subcells_host = PHX::View<int*>::host_mirror_type("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
76 Kokkos::deep_copy(_subcell_to_cells_host, _subcell_to_cells);
80}
81
82}
void setup(const panzer::LocalMeshPartition &partition)
Setup the face connectivity from a partition of the local mesh.
PHX::View< int * >::host_mirror_type _subcell_to_cells_adj_host
PHX::View< int * > _subcell_to_cells_adj
Adjacency array for indexing into subcell_to_cells array.
PHX::View< int * > _subcell_to_cells
Mapping from subcells to cells.
PHX::View< int * >::host_mirror_type _cell_to_subcells_host
PHX::View< int * >::host_mirror_type _subcell_to_cells_host
PHX::View< int * > _cell_to_subcells
Mapping from cells to subcells.
PHX::View< int * > _cell_to_subcells_adj
Adjacency array for indexing into cell_to_subcells array.
PHX::View< int * >::host_mirror_type _subcell_to_local_subcells_host
PHX::View< int * >::host_mirror_type _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< panzer::LocalOrdinal *[2]> face_to_cells
PHX::View< panzer::LocalOrdinal ** > cell_to_faces