11 #ifndef PANZER_SHARDS_UTILITIES
12 #define PANZER_SHARDS_UTILITIES
17 #include "Teuchos_Assert.hpp"
18 #include "Shards_CellTopology.hpp"
22 template<
typename ArrayCellGIDs,
typename ArrayS
ideGIDs>
25 const ArraySideGIDs& sideGIDs,
26 const shards::CellTopology& cell)
28 unsigned cell_dim = cell.getDimension();
33 bool found_local_side =
false;
35 while ( (side < cell.getSideCount()) && (!found_local_side) ) {
37 const shards::CellTopology
38 side_topo(cell.getCellTopologyData(cell.getDimension()-1, side));
40 unsigned num_side_nodes =
41 cell.getCellTopologyData()->side[side].topology->node_count;
44 std::list<unsigned> tmp_side_gid_list;
45 for (
unsigned node = 0; node < num_side_nodes; ++node)
46 tmp_side_gid_list.push_back(cellGIDs[cell.getNodeMap(cell_dim - 1,
49 bool side_matches =
true;
51 while ( side_matches && (node < num_side_nodes) ) {
53 std::list<unsigned>::iterator search =
54 std::find(tmp_side_gid_list.begin(), tmp_side_gid_list.end(),
57 if (search == tmp_side_gid_list.end())
64 found_local_side =
true;
72 "Failed to find side!");
88 template<
typename ArrayCellGIDs,
typename ArrayS
ideGIDs>
91 const ArraySideGIDs& subcellGIDs,
92 const shards::CellTopology& cell,
unsigned subcell_dim)
94 unsigned local_subcell;
95 bool found_local_subcell =
false;
97 while ( (subcell < cell.getSubcellCount(subcell_dim)) && (!found_local_subcell) ) {
99 unsigned num_subcell_nodes =
100 cell.getCellTopologyData()->subcell[subcell_dim][subcell].topology->node_count;
102 std::list<unsigned> tmp_subcell_gid_list;
103 for (
unsigned node = 0; node < num_subcell_nodes; ++node)
104 tmp_subcell_gid_list.push_back(cellGIDs[cell.getNodeMap(subcell_dim,
107 bool subcell_matches =
true;
109 while ( subcell_matches && (node < num_subcell_nodes) ) {
111 std::list<unsigned>::iterator search =
112 std::find(tmp_subcell_gid_list.begin(), tmp_subcell_gid_list.end(),
115 if (search == tmp_subcell_gid_list.end())
116 subcell_matches =
false;
121 if (subcell_matches) {
122 found_local_subcell =
true;
123 local_subcell = subcell;
130 "Failed to find subcell!");
132 return local_subcell;
153 template<
typename ArrayCellGIDs,
typename ArraySubcellGIDs>
155 const std::vector<ArraySubcellGIDs> & subcellGIDs,
156 const shards::CellTopology& cell,
unsigned subcell_dim,
157 std::vector<unsigned> & subcellMap)
159 subcellMap.resize(subcellGIDs.size());
163 typename std::vector<ArraySubcellGIDs>::const_iterator subcellIter;
164 for(subcellIter=subcellGIDs.begin();subcellIter!=subcellGIDs.end();++subcellIter) {
168 subcellMap[localSubcell] = index;
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
unsigned getLocalSideIndexFromGlobalNodeList(const ArrayCellGIDs &cellGIDs, const ArraySideGIDs &sideGIDs, const shards::CellTopology &cell)
unsigned getLocalSubcellIndexFromGlobalNodeList(const ArrayCellGIDs &cellGIDs, const ArraySideGIDs &subcellGIDs, const shards::CellTopology &cell, unsigned subcell_dim)
void getLocalSubcellMapFromGlobalNodeLists(const ArrayCellGIDs &cellGIDs, const std::vector< ArraySubcellGIDs > &subcellGIDs, const shards::CellTopology &cell, unsigned subcell_dim, std::vector< unsigned > &subcellMap)