Skip to content

Commit 48b8cc8

Browse files
authored
Merge pull request #3512 from jwpeterson/fix_edge_block_reading
ExodusII_IO: Allow edges with different orientations to match
2 parents d143a59 + 0a5a650 commit 48b8cc8

3 files changed

Lines changed: 24 additions & 19 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
{

tests/mesh/boundary_info.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,9 +746,9 @@ public:
746746
std::vector<boundary_id_type> container;
747747
bi.boundary_ids(elem, 3, container);
748748

749-
CPPUNIT_ASSERT_EQUAL((unsigned long) 2, container.size());
750-
CPPUNIT_ASSERT_EQUAL((short int) 5, container[0]);
751-
CPPUNIT_ASSERT_EQUAL((short int) 3, container[1]);
749+
CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), container.size());
750+
CPPUNIT_ASSERT_EQUAL(static_cast<boundary_id_type>(5), container[0]);
751+
CPPUNIT_ASSERT_EQUAL(static_cast<boundary_id_type>(3), container[1]);
752752
}
753753
}
754754
}

tests/mesh/mesh_input.C

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,12 @@ public:
258258
// reader threw an exception while trying to read this mesh.
259259
if (mesh.is_serial())
260260
{
261-
// Mesh has 15 boundary ids total (including edge and side ids).
262-
CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(15), bi.n_boundary_ids());
261+
// Mesh has 26 boundary ids total (including edge and side ids).
262+
// ss_prop1 = 200, 201 ;
263+
// ed_prop1 = 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009, 8010,
264+
// 8011, 9001, 9002, 9003, 9004, 9005, 9006, 9007, 9008, 9009, 9010,
265+
// 9011, 9012 ;
266+
CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(26), bi.n_boundary_ids());
263267

264268
// We can binary_search() the build_edge_list() which is sorted
265269
// in lexicographical order before it's returned.

0 commit comments

Comments
 (0)