43 #ifndef PANZER_SHARDS_UTILITIES
44 #define PANZER_SHARDS_UTILITIES
49 #include "Teuchos_Assert.hpp"
50 #include "Shards_CellTopology.hpp"
54 template<
typename ArrayCellGIDs,
typename ArrayS
ideGIDs>
57 const ArraySideGIDs& sideGIDs,
58 const shards::CellTopology& cell)
60 unsigned cell_dim = cell.getDimension();
65 bool found_local_side =
false;
67 while ( (side < cell.getSideCount()) && (!found_local_side) ) {
69 const shards::CellTopology
70 side_topo(cell.getCellTopologyData(cell.getDimension()-1, side));
72 unsigned num_side_nodes =
73 cell.getCellTopologyData()->side[side].topology->node_count;
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,
81 bool side_matches =
true;
83 while ( side_matches && (node < num_side_nodes) ) {
85 std::list<unsigned>::iterator search =
86 std::find(tmp_side_gid_list.begin(), tmp_side_gid_list.end(),
89 if (search == tmp_side_gid_list.end())
96 found_local_side =
true;
104 "Failed to find side!");
120 template<
typename ArrayCellGIDs,
typename ArrayS
ideGIDs>
123 const ArraySideGIDs& subcellGIDs,
124 const shards::CellTopology& cell,
unsigned subcell_dim)
126 unsigned local_subcell;
127 bool found_local_subcell =
false;
128 unsigned subcell = 0;
129 while ( (subcell < cell.getSubcellCount(subcell_dim)) && (!found_local_subcell) ) {
131 unsigned num_subcell_nodes =
132 cell.getCellTopologyData()->subcell[subcell_dim][subcell].topology->node_count;
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,
139 bool subcell_matches =
true;
141 while ( subcell_matches && (node < num_subcell_nodes) ) {
143 std::list<unsigned>::iterator search =
144 std::find(tmp_subcell_gid_list.begin(), tmp_subcell_gid_list.end(),
147 if (search == tmp_subcell_gid_list.end())
148 subcell_matches =
false;
153 if (subcell_matches) {
154 found_local_subcell =
true;
155 local_subcell = subcell;
162 "Failed to find subcell!");
164 return local_subcell;
185 template<
typename ArrayCellGIDs,
typename ArraySubcellGIDs>
187 const std::vector<ArraySubcellGIDs> & subcellGIDs,
188 const shards::CellTopology& cell,
unsigned subcell_dim,
189 std::vector<unsigned> & subcellMap)
191 subcellMap.resize(subcellGIDs.size());
195 typename std::vector<ArraySubcellGIDs>::const_iterator subcellIter;
196 for(subcellIter=subcellGIDs.begin();subcellIter!=subcellGIDs.end();++subcellIter) {
200 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)