Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/mesh/gmsh_io.C
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,13 @@ void GmshIO::read_mesh(std::istream & in)
// actually blocks of lower-dimensional elements.
std::set<subdomain_id_type> lower_dimensional_blocks;

// Mapping from physical id -> (physical dim, physical name) pairs.
// Mapping from (physical id, physical dim) -> physical name.
// These can refer to either "sidesets" or "subdomains"; we need to
// wait until the Mesh has been read to know which is which. Note
// that we are using 'int' as the key here rather than
// that we are using ptrdiff_t as the key here rather than
// subdomain_id_type or boundary_id_type, since at this point, it
// could be either.
typedef std::pair<unsigned, std::string> GmshPhysical;
std::map<int, GmshPhysical> gmsh_physicals;
std::map<std::pair<std::ptrdiff_t, unsigned>, std::string> gmsh_physicals;

// map to hold the node numbers for translation
// note the the nodes can be non-consecutive
Expand Down Expand Up @@ -267,7 +266,7 @@ void GmshIO::read_mesh(std::istream & in)
phys_name.erase(std::remove(phys_name.begin(), phys_name.end(), '"'), phys_name.end());

// Record this ID for later assignment of subdomain/sideset names.
gmsh_physicals[phys_id] = std::make_pair(phys_dim, phys_name);
gmsh_physicals[std::make_pair(phys_id, phys_dim)] = phys_name;

// If 's' also contains the libmesh-specific string
// "lower_dimensional_block", add this block ID to
Expand Down Expand Up @@ -790,9 +789,8 @@ void GmshIO::read_mesh(std::istream & in)
for (const auto & pr : gmsh_physicals)
{
// Extract data
int phys_id = pr.first;
unsigned phys_dim = pr.second.first;
const std::string & phys_name = pr.second.second;
auto [phys_id, phys_dim] = pr.first;
const std::string & phys_name = pr.second;

// If the physical's dimension matches the largest
// dimension we've seen, it's a subdomain name.
Expand Down
28 changes: 28 additions & 0 deletions tests/mesh/mesh_input.C
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ public:
CPPUNIT_TEST( testGoodSTL );
CPPUNIT_TEST( testGoodSTLBinary );

CPPUNIT_TEST( testGmshBCIDOverlap );

#ifdef LIBMESH_HAVE_TETGEN
CPPUNIT_TEST( testTetgenIO );
#endif
Expand Down Expand Up @@ -1562,6 +1564,32 @@ public:
CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(14));
}

void testGmshBCIDOverlap ()
{
LOG_UNIT_TEST;

Mesh mesh(*TestCommWorld);

GmshIO gmsh_io(mesh);

if (mesh.processor_id() == 0)
gmsh_io.read("meshes/bcid_overlap.msh");
MeshCommunication().broadcast(mesh);

CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().get_sideset_name_map().size(),
std::size_t(2));
CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().sideset_name(1),
std::string("srfBC4A"));
CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().sideset_name(2),
std::string("srfBC4B"));
CPPUNIT_ASSERT_EQUAL(mesh.get_subdomain_name_map().size(),
std::size_t(2));
CPPUNIT_ASSERT_EQUAL(mesh.subdomain_name(1),
std::string("volBC3A"));
CPPUNIT_ASSERT_EQUAL(mesh.subdomain_name(2),
std::string("volBC3B"));
}

void testGoodSTL ()
{
LOG_UNIT_TEST;
Expand Down
184 changes: 184 additions & 0 deletions tests/meshes/bcid_overlap.msh
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
$MeshFormat
4.1 0 8
$EndMeshFormat
$PhysicalNames
6
1 1 "linD4A"
1 2 "linD4B"
2 1 "srfBC4A"
2 2 "srfBC4B"
3 1 "volBC3A"
3 2 "volBC3B"
$EndPhysicalNames
$Entities
9 21 15 2
1 1 0 1 0
2 2 0 1 0
3 1 0 0 0
4 2 0 0 0
5 2 1 0 0
6 0 0 1 0
7 0 0 0 0
8 0 1 0 0
9 1 1 0 0
1 1.0 0.0 1.0 2.0 0.0 1.0 1 1 2 1 -2
2 1.0 0.0 0.0 1.0 0.0 1.0 0 2 3 -1
3 1.0 0.0 0.0 2.0 0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 1
118 2 3 4 13 28 14
3 1 11 3
130 6 3 7 8 18 20 19 23 27 26
131 9 8 3 1 24 26 25 21 12 22
132 6 3 8 1 18 26 23 17 22 12
3 2 11 3
133 3 2 9 1 13 15 25 12 21 11
134 2 4 9 5 14 31 15 16 29 30
135 2 3 9 4 13 25 15 14 31 28
$EndElements