Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_SubcellConnectivity.cpp
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
45
46namespace panzer
47{
48
49void
51setup(const panzer::LocalMeshPartition & partition)
52{
53 const int num_cells = partition.cell_to_faces.extent(0);
54 const int num_faces = partition.face_to_cells.extent(0);
55 const int num_faces_per_cell = partition.cell_to_faces.extent(1);
56 const int num_cells_per_face = 2;
57
58 _subcell_to_cells_adj = PHX::View<int*>("subcell_to_cells_adj", num_faces+1);
59 _subcell_to_cells = PHX::View<int*>("subcell_to_cells", num_faces*num_cells_per_face);
60 _subcell_to_local_subcells = PHX::View<int*>("subcell_to_local_subcells", num_faces*num_cells_per_face);
61 _cell_to_subcells_adj = PHX::View<int*>("cell_to_subcells_adj", num_cells+1);
62 _cell_to_subcells = PHX::View<int*>("cell_to_subcells", num_cells*num_faces_per_cell);
63
64 // Host copies
65 _subcell_to_cells_adj_host = PHX::View<int*>::HostMirror("subcell_to_cells_adj_host", num_faces+1);
66 _subcell_to_cells_host = PHX::View<int*>::HostMirror("subcell_to_cells_host", num_faces*num_cells_per_face);
67 _subcell_to_local_subcells_host = PHX::View<int*>::HostMirror("subcell_to_local_subcells_host", num_faces*num_cells_per_face);
68 _cell_to_subcells_adj_host = PHX::View<int*>::HostMirror("cell_to_subcells_adj_host", num_cells+1);
69 _cell_to_subcells_host = PHX::View<int*>::HostMirror("cell_to_subcells_host", num_cells*num_faces_per_cell);
70
71 // This line not needed since kokkos initializes the arrays above to zero
72 //_subcell_to_cells_adj(0)=0;
73
74 {
75 auto face_to_cells = partition.face_to_cells;
76 auto face_to_lidx = partition.face_to_lidx;
77 auto subcell_to_cells_adj = _subcell_to_cells_adj;
78 auto subcell_to_cells = _subcell_to_cells;
79 auto subcell_to_local_subcells = _subcell_to_local_subcells;
80 Kokkos::parallel_for("subcell connectivity 0",num_faces,KOKKOS_LAMBDA (const int face) {
81 subcell_to_cells_adj(face+1) = (face * num_cells_per_face) + num_cells_per_face;
82 subcell_to_cells(num_cells_per_face*face + 0) = face_to_cells(face,0);
83 subcell_to_cells(num_cells_per_face*face + 1) = face_to_cells(face,1);
84 subcell_to_local_subcells(num_cells_per_face*face + 0) = face_to_lidx(face,0);
85 subcell_to_local_subcells(num_cells_per_face*face + 1) = face_to_lidx(face,1);
86 });
87 PHX::Device::execution_space().fence();
88 }
89
90 // This line not needed since kokkos initializes the arrays above to zero
91 //_cell_to_subcells_adj(0)=0;
92
93 {
94 auto cell_to_faces = partition.cell_to_faces;
95 auto cell_to_subcells_adj = _cell_to_subcells_adj;
96 auto cell_to_subcells = _cell_to_subcells;
97 Kokkos::parallel_for("subcell connectivity 1",num_cells,KOKKOS_LAMBDA (const int cell) {
98 cell_to_subcells_adj(cell+1) = (cell * num_faces_per_cell) + num_faces_per_cell;
99 for(int local_face=0;local_face<num_faces_per_cell;++local_face){
100 cell_to_subcells(num_faces_per_cell*cell+local_face) = cell_to_faces(cell,local_face);
101 }
102 });
103 PHX::Device::execution_space().fence();
104 }
105
106 // Copy values to host
108 Kokkos::deep_copy(_subcell_to_cells_host, _subcell_to_cells);
111 Kokkos::deep_copy(_cell_to_subcells_host,_cell_to_subcells);
112}
113
114}
void setup(const panzer::LocalMeshPartition &partition)
Setup the face connectivity from a partition of the local mesh.
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 * >::HostMirror _subcell_to_cells_host
PHX::View< int * >::HostMirror _subcell_to_cells_adj_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 * >::HostMirror _cell_to_subcells_host
PHX::View< int * >::HostMirror _cell_to_subcells_adj_host
PHX::View< int * >::HostMirror _subcell_to_local_subcells_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