Skip to content

Commit a9aa7ae

Browse files
committed
Allow edges with different orientations to match
The idea here is that a user should be able to specify an edge block in the Exodus file simply by specifying their desired edge ids, without knowing the orientation of the edge in the 3D elem it is attached to. This means that edges which are attached to multiple Elems will be added to the BoundaryInfo object multiple times.
1 parent e7e3102 commit a9aa7ae

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

src/mesh/exodusII_io_helper.C

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,11 @@ void ExodusII_IO_Helper::read_edge_blocks(MeshBase & mesh)
14311431
// map from edge->key() to a list of (elem_id, edge_id) pairs
14321432
// for the Edge in question. Since edge->key() is edge orientation
14331433
// invariant, this map does not distinguish different orientations
1434-
// of the same Edge.
1434+
// of the same Edge. Since edge->key() is also not guaranteed to be
1435+
// unique (though it is very unlikely for two distinct edges to have
1436+
// the same key()), when we later look up an (elem_id, edge_id) pair
1437+
// in the edge_map, we need to verify that the edge indeed matches
1438+
// the searched edge by doing some further checks.
14351439
typedef std::pair<dof_id_type, unsigned int> ElemEdgePair;
14361440
std::unordered_map<dof_id_type, std::vector<ElemEdgePair>> edge_map;
14371441
std::unique_ptr<Elem> edge_ptr;
@@ -1538,14 +1542,14 @@ void ExodusII_IO_Helper::read_edge_blocks(MeshBase & mesh)
15381542

15391543
// If this key is not found in the edge_map, which is
15401544
// supposed to include every edge in the Mesh, then we
1541-
// need to throw an error.
1545+
// will throw an error now.
15421546
auto & elem_edge_pair_vec =
15431547
libmesh_map_find(edge_map, edge_key);
15441548

15451549
for (const auto & elem_edge_pair : elem_edge_pair_vec)
15461550
{
15471551
// We only want to match edges which have the same
1548-
// orientation (node ordering) to the one in the
1552+
// nodes (possibly with different orientation) to the one in the
15491553
// Exodus file, otherwise we ignore this elem_edge_pair.
15501554
//
15511555
// Note: this also handles the situation where two
@@ -1557,17 +1561,14 @@ void ExodusII_IO_Helper::read_edge_blocks(MeshBase & mesh)
15571561
build_edge_ptr(edge_ptr, elem_edge_pair.second);
15581562

15591563
// Determine whether this candidate edge is a "real" match,
1560-
// i.e. also has the same orientation. Note that here we
1561-
// only check that the vertices match regardless of how many
1562-
// nodes the edge has, which allows us to match a lower-order
1563-
// edge to a higher-order Elem.
1564-
bool is_match = true;
1565-
for (unsigned int n=0; n<edge_ptr->n_vertices(); ++n)
1566-
if (edge_ptr->node_id(n) != edge->node_id(n))
1567-
{
1568-
is_match = false;
1569-
break;
1570-
}
1564+
// i.e. has the same nodes with a possibly different
1565+
// orientation. Note that here we only check that
1566+
// the vertices match regardless of how many nodes
1567+
// the edge has, which allows us to match a
1568+
// lower-order edge to a higher-order Elem.
1569+
bool is_match =
1570+
((edge_ptr->node_id(0) == edge->node_id(0)) && (edge_ptr->node_id(1) == edge->node_id(1))) ||
1571+
((edge_ptr->node_id(0) == edge->node_id(1)) && (edge_ptr->node_id(1) == edge->node_id(0)));
15711572

15721573
if (is_match)
15731574
{

0 commit comments

Comments
 (0)