Skip to content

Commit d3f2763

Browse files
committedApr 2, 2025·
Don't let GMSH physicals overwrite each other
See #4125 for an example case.
1 parent 25ab562 commit d3f2763

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed
 

‎src/mesh/gmsh_io.C

+6-8
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,13 @@ void GmshIO::read_mesh(std::istream & in)
175175
// actually blocks of lower-dimensional elements.
176176
std::set<subdomain_id_type> lower_dimensional_blocks;
177177

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

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

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

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

797795
// If the physical's dimension matches the largest
798796
// dimension we've seen, it's a subdomain name.

0 commit comments

Comments
 (0)
Please sign in to comment.