Panzer
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
disc-fe
src
Panzer_Shards_Utilities.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
#ifndef PANZER_SHARDS_UTILITIES
44
#define PANZER_SHARDS_UTILITIES
45
46
#include <iostream>
47
#include <vector>
48
#include <list>
49
#include "Teuchos_Assert.hpp"
50
#include "Shards_CellTopology.hpp"
51
52
namespace
panzer
{
53
54
template
<
typename
ArrayCellGIDs,
typename
ArrayS
id
eGIDs>
55
unsigned
56
getLocalSideIndexFromGlobalNodeList
(
const
ArrayCellGIDs& cellGIDs,
57
const
ArraySideGIDs& sideGIDs,
58
const
shards::CellTopology& cell)
59
{
60
unsigned
cell_dim = cell.getDimension();
61
//TEUCHOS_TEST_FOR_EXCEPTION(!cell.getSubcellHomogeneity(cell_dim - 1),
62
// std::runtime_error, "Sides are not homogeneous!");
63
64
unsigned
local_side;
65
bool
found_local_side =
false
;
66
unsigned
side = 0;
67
while
( (side < cell.getSideCount()) && (!found_local_side) ) {
68
69
const
shards::CellTopology
70
side_topo(cell.getCellTopologyData(cell.getDimension()-1, side));
71
72
unsigned
num_side_nodes =
73
cell.getCellTopologyData()->side[side].topology->node_count;
74
75
76
std::list<unsigned> tmp_side_gid_list;
77
for
(
unsigned
node = 0; node < num_side_nodes; ++node)
78
tmp_side_gid_list.push_back(cellGIDs[cell.getNodeMap(cell_dim - 1,
79
side, node)]);
80
81
bool
side_matches =
true
;
82
unsigned
node = 0;
83
while
( side_matches && (node < num_side_nodes) ) {
84
85
std::list<unsigned>::iterator search =
86
std::find(tmp_side_gid_list.begin(), tmp_side_gid_list.end(),
87
sideGIDs[node]);
88
89
if
(search == tmp_side_gid_list.end())
90
side_matches =
false
;
91
92
++node;
93
}
94
95
if
(side_matches) {
96
found_local_side =
true
;
97
local_side = side;
98
}
99
100
++side;
101
}
102
103
TEUCHOS_TEST_FOR_EXCEPTION(!found_local_side, std::runtime_error,
104
"Failed to find side!"
);
105
106
return
local_side;
107
}
108
120
template
<
typename
ArrayCellGIDs,
typename
ArrayS
id
eGIDs>
121
unsigned
122
getLocalSubcellIndexFromGlobalNodeList
(
const
ArrayCellGIDs& cellGIDs,
123
const
ArraySideGIDs& subcellGIDs,
124
const
shards::CellTopology& cell,
unsigned
subcell_dim)
125
{
126
unsigned
local_subcell;
127
bool
found_local_subcell =
false
;
128
unsigned
subcell = 0;
129
while
( (subcell < cell.getSubcellCount(subcell_dim)) && (!found_local_subcell) ) {
130
131
unsigned
num_subcell_nodes =
132
cell.getCellTopologyData()->subcell[subcell_dim][subcell].topology->node_count;
133
134
std::list<unsigned> tmp_subcell_gid_list;
135
for
(
unsigned
node = 0; node < num_subcell_nodes; ++node)
136
tmp_subcell_gid_list.push_back(cellGIDs[cell.getNodeMap(subcell_dim,
137
subcell, node)]);
138
139
bool
subcell_matches =
true
;
140
unsigned
node = 0;
141
while
( subcell_matches && (node < num_subcell_nodes) ) {
142
143
std::list<unsigned>::iterator search =
144
std::find(tmp_subcell_gid_list.begin(), tmp_subcell_gid_list.end(),
145
subcellGIDs[node]);
146
147
if
(search == tmp_subcell_gid_list.end())
148
subcell_matches =
false
;
149
150
++node;
151
}
152
153
if
(subcell_matches) {
154
found_local_subcell =
true
;
155
local_subcell = subcell;
156
}
157
158
++subcell;
159
}
160
161
TEUCHOS_TEST_FOR_EXCEPTION(!found_local_subcell, std::runtime_error,
162
"Failed to find subcell!"
);
163
164
return
local_subcell;
165
}
166
185
template
<
typename
ArrayCellGIDs,
typename
ArraySubcellGIDs>
186
void
getLocalSubcellMapFromGlobalNodeLists
(
const
ArrayCellGIDs& cellGIDs,
187
const
std::vector<ArraySubcellGIDs> & subcellGIDs,
188
const
shards::CellTopology& cell,
unsigned
subcell_dim,
189
std::vector<unsigned> & subcellMap)
190
{
191
subcellMap.resize(subcellGIDs.size());
192
193
// loop over subcell node indices searching for local subcell index
194
unsigned
index = 0;
195
typename
std::vector<ArraySubcellGIDs>::const_iterator subcellIter;
196
for
(subcellIter=subcellGIDs.begin();subcellIter!=subcellGIDs.end();++subcellIter) {
197
unsigned
localSubcell =
getLocalSubcellIndexFromGlobalNodeList
(cellGIDs,*subcellIter,cell,subcell_dim);
198
199
// build vector mapping current index to local subcell index
200
subcellMap[localSubcell] = index;
201
202
index++;
203
}
204
}
205
206
}
207
208
#endif
panzer
Computes .
Definition
Panzer_BasisValues_Evaluator_decl.hpp:54
panzer::getLocalSubcellIndexFromGlobalNodeList
unsigned getLocalSubcellIndexFromGlobalNodeList(const ArrayCellGIDs &cellGIDs, const ArraySideGIDs &subcellGIDs, const shards::CellTopology &cell, unsigned subcell_dim)
Definition
Panzer_Shards_Utilities.hpp:122
panzer::getLocalSubcellMapFromGlobalNodeLists
void getLocalSubcellMapFromGlobalNodeLists(const ArrayCellGIDs &cellGIDs, const std::vector< ArraySubcellGIDs > &subcellGIDs, const shards::CellTopology &cell, unsigned subcell_dim, std::vector< unsigned > &subcellMap)
Definition
Panzer_Shards_Utilities.hpp:186
panzer::getLocalSideIndexFromGlobalNodeList
unsigned getLocalSideIndexFromGlobalNodeList(const ArrayCellGIDs &cellGIDs, const ArraySideGIDs &sideGIDs, const shards::CellTopology &cell)
Definition
Panzer_Shards_Utilities.hpp:56
Generated by
1.17.0