@@ -141,6 +141,7 @@ BoundaryInfo & BoundaryInfo::operator=(const BoundaryInfo & other_boundary_info)
141141 _global_boundary_ids = other_boundary_info ._global_boundary_ids ;
142142 _side_boundary_ids = other_boundary_info ._side_boundary_ids ;
143143 _node_boundary_ids = other_boundary_info ._node_boundary_ids ;
144+ _sideset_to_nodeset_conversion = other_boundary_info ._sideset_to_nodeset_conversion ;
144145 _edge_boundary_ids = other_boundary_info ._edge_boundary_ids ;
145146 _shellface_boundary_ids = other_boundary_info ._shellface_boundary_ids ;
146147
@@ -348,6 +349,7 @@ void BoundaryInfo::clear()
348349 _boundary_ids .clear ();
349350 _side_boundary_ids .clear ();
350351 _node_boundary_ids .clear ();
352+ _sideset_to_nodeset_conversion .clear ();
351353 _edge_boundary_ids .clear ();
352354 _shellface_boundary_ids .clear ();
353355 _ss_id_to_name .clear ();
@@ -1188,6 +1190,12 @@ void BoundaryInfo::add_side(const Elem * elem,
11881190 _boundary_side_id .emplace (elem , std ::make_pair (side , id ));
11891191 _boundary_ids .insert (id );
11901192 _side_boundary_ids .insert (id ); // Also add this ID to the set of side boundary IDs
1193+
1194+ // create temp side and check if sideset has a matching nodeset
1195+ ElemSideBuilder side_builder ;
1196+ const Elem * new_side = & side_builder (* elem , side );
1197+ if (has_equivalent_nodeset (new_side , id ))
1198+ _sideset_to_nodeset_conversion .emplace (id , id );
11911199}
11921200
11931201
@@ -1258,6 +1266,12 @@ void BoundaryInfo::add_side(const Elem * elem,
12581266 _boundary_side_id .emplace (elem , std ::make_pair (side , id ));
12591267 _boundary_ids .insert (id );
12601268 _side_boundary_ids .insert (id ); // Also add this ID to the set of side boundary IDs
1269+
1270+ // create temp side and check if sideset has a matching nodeset
1271+ ElemSideBuilder side_builder ;
1272+ const Elem * new_side = & side_builder (* elem , side );
1273+ if (has_equivalent_nodeset (new_side , id ))
1274+ _sideset_to_nodeset_conversion .emplace (id , id );
12611275 }
12621276}
12631277
@@ -1902,7 +1916,51 @@ void BoundaryInfo::renumber_id (boundary_id_type old_id,
19021916 this -> libmesh_assert_valid_multimaps ();
19031917}
19041918
1919+ boundary_id_type BoundaryInfo ::check_renumber_nodeset (boundary_id_type bc_id )
1920+ {
1921+ 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
1923+ return _sideset_to_nodeset_conversion [bc_id ];
1924+ else
1925+ {
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 ;
1932+ }
1933+ }
19051934
1935+ bool BoundaryInfo ::has_equivalent_nodeset (const Elem * side , boundary_id_type bc_id )
1936+ {
1937+ bool equivalent_nodeset = false;
1938+ if (_sideset_to_nodeset_conversion .find (bc_id ) != _sideset_to_nodeset_conversion .end ())
1939+ // The appropriate sideset->nodeset conversion has already been found and we can skip this check
1940+ return equivalent_nodeset ;
1941+ const auto * n_list = side -> get_nodes ();
1942+ for (unsigned int i = 0 ; i < side -> n_nodes (); i ++ )
1943+ {
1944+ const auto node = n_list [i ];
1945+ //auto bc_ids = _boundary_node_id.equal_range(node);
1946+ for (const auto & itr : as_range (_boundary_node_id .equal_range (node )))
1947+ {
1948+ if (itr .second == bc_id )
1949+ {
1950+ equivalent_nodeset = true;
1951+ break ;
1952+ }
1953+ else
1954+ equivalent_nodeset = false;
1955+ // no equivalent nodeset exists
1956+ //equivalent_nodeset = false;
1957+ //break;
1958+ }
1959+ if (!equivalent_nodeset )
1960+ break ;
1961+ }
1962+ return equivalent_nodeset ;
1963+ }
19061964
19071965unsigned int BoundaryInfo ::side_with_boundary_id (const Elem * const elem ,
19081966 const boundary_id_type boundary_id_in ) const
@@ -2358,20 +2416,28 @@ BoundaryInfo::build_node_list_from_side_list()
23582416 for (const auto & cur_elem : family )
23592417 {
23602418 side = & side_builder (* cur_elem , id_pair .first );
2361-
2419+ // Check for equivalent nodeset here. If it has one the next portion can be skipped
23622420 // Add each node node on the side with the side's boundary id
2421+ //if (has_equivalent_nodeset(side, id_pair.second))
2422+ //_sideset_to_nodeset_conversion.emplace(id_pair.second, id_pair.second);
23632423 for (auto i : side -> node_index_range ())
2424+ {
2425+ const boundary_id_type bcid = id_pair .second ;
2426+ 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 );
2431+ this -> add_node (side -> node_ptr (i ), bcid_renum );
2432+ _sideset_to_nodeset_conversion .emplace (bcid , bcid_renum );
2433+ if (!mesh_is_serial )
23642434 {
2365- const boundary_id_type bcid = id_pair .second ;
2366- this -> add_node (side -> node_ptr (i ), bcid );
2367- if (!mesh_is_serial )
2368- {
2369- const processor_id_type proc_id =
2370- side -> node_ptr (i )-> processor_id ();
2371- if (proc_id != my_proc_id )
2372- nodes_to_push [proc_id ].emplace (side -> node_id (i ), bcid );
2373- }
2435+ const processor_id_type proc_id =
2436+ side -> node_ptr (i )-> processor_id ();
2437+ if (proc_id != my_proc_id )
2438+ nodes_to_push [proc_id ].emplace (side -> node_id (i ), bcid );
23742439 }
2440+ }
23752441 }
23762442 }
23772443
0 commit comments