@@ -1919,25 +1919,42 @@ void BoundaryInfo::renumber_id (boundary_id_type old_id,
19191919boundary_id_type BoundaryInfo ::check_renumber_nodeset (boundary_id_type bc_id )
19201920{
19211921 if (_sideset_to_nodeset_conversion .find (bc_id ) != _sideset_to_nodeset_conversion .end ())
1922- // A new bc ID has already been created for this nodeset. Return that
1922+ // The appropriate sideset->nodeset conversion has already been found and we can skip this check
19231923 return _sideset_to_nodeset_conversion [bc_id ];
1924- else
1924+ // Else search for a nodeset name that matches this sideset's name
1925+ std ::string sideset_name = _ss_id_to_name [bc_id ];
1926+ for (const auto & ns_id : _node_boundary_ids )
1927+ {
1928+ if (_ns_id_to_name [ns_id ] == sideset_name )
19251929 {
1926- // Find a suitable id and add to map
1927- boundary_id_type new_id = _node_boundary_ids .size () + 1 ;
1928- while (_node_boundary_ids .find (new_id ) != _node_boundary_ids .end ())
1929- new_id ++ ;
1930- _sideset_to_nodeset_conversion .emplace (bc_id , new_id );
1931- return new_id ;
1930+ // This sideset and nodeset should be treated the same
1931+ _sideset_to_nodeset_conversion .emplace (bc_id , ns_id );
1932+ return ns_id ;
19321933 }
1934+ }
1935+ // Find a suitable id and add to map
1936+ boundary_id_type new_id = _node_boundary_ids .size () + 1 ;
1937+ while (_node_boundary_ids .find (new_id ) != _node_boundary_ids .end ())
1938+ new_id ++ ;
1939+ _sideset_to_nodeset_conversion .emplace (bc_id , new_id );
1940+ return new_id ;
19331941}
19341942
19351943bool BoundaryInfo ::has_equivalent_nodeset (const Elem * side , boundary_id_type bc_id )
19361944{
19371945 bool equivalent_nodeset = false;
19381946 if (_sideset_to_nodeset_conversion .find (bc_id ) != _sideset_to_nodeset_conversion .end ())
1947+ {
19391948 // The appropriate sideset->nodeset conversion has already been found and we can skip this check
1949+ equivalent_nodeset = true;
19401950 return equivalent_nodeset ;
1951+ }
1952+ // If there is no nodeset with the same ID then we don't have to worry about overwriting
1953+ if (_node_boundary_ids .find (bc_id ) == _node_boundary_ids .end ())
1954+ {
1955+ equivalent_nodeset = true;
1956+ return equivalent_nodeset ;
1957+ }
19411958 const auto * n_list = side -> get_nodes ();
19421959 for (unsigned int i = 0 ; i < side -> n_nodes (); i ++ )
19431960 {
@@ -2424,12 +2441,13 @@ BoundaryInfo::build_node_list_from_side_list()
24242441 {
24252442 const boundary_id_type bcid = id_pair .second ;
24262443 auto bcid_renum = bcid ;
2427- // Check that bcid is not the same as a sideset id
2428- if (_node_boundary_ids .find (bcid ) != _node_boundary_ids .end ())
2429- // Check that the nodeset and sideset don't cover the same area
2430- bcid_renum = check_renumber_nodeset ( bcid_renum );
2444+ // If grouping by name check if nodeset id needs to be renumbered
2445+ if (_node_boundary_ids .find (bcid ) != _node_boundary_ids .end () && ! has_equivalent_nodeset ( side , bcid ) )
2446+ // This sideset overlaps with a nodeset. Throw an error
2447+ libmesh_error_msg (" Sideset " << bcid << " has the same ID as a preexisting nodeset. Rename one in order to build a nodeset from this sideset" );
24312448 this -> add_node (side -> node_ptr (i ), bcid_renum );
2432- _sideset_to_nodeset_conversion .emplace (bcid , bcid_renum );
2449+ _sideset_to_nodeset_conversion .emplace (bcid , bcid );
2450+ // _sideset_to_nodeset_conversion.emplace(bcid, bcid_renum);
24332451 if (!mesh_is_serial )
24342452 {
24352453 const processor_id_type proc_id =
0 commit comments