@@ -1721,57 +1721,66 @@ void UnstructuredMesh::all_complete_order ()
17211721}
17221722
17231723
1724- void UnstructuredMesh ::stitch_meshes (const MeshBase & other_mesh ,
1725- boundary_id_type this_mesh_boundary_id ,
1726- boundary_id_type other_mesh_boundary_id ,
1727- Real tol ,
1728- bool clear_stitched_boundary_ids ,
1729- bool verbose ,
1730- bool use_binary_search ,
1731- bool enforce_all_nodes_match_on_boundaries )
1724+ std ::size_t
1725+ UnstructuredMesh ::stitch_meshes (const MeshBase & other_mesh ,
1726+ boundary_id_type this_mesh_boundary_id ,
1727+ boundary_id_type other_mesh_boundary_id ,
1728+ Real tol ,
1729+ bool clear_stitched_boundary_ids ,
1730+ bool verbose ,
1731+ bool use_binary_search ,
1732+ bool enforce_all_nodes_match_on_boundaries ,
1733+ bool merge_boundary_nodes_all_or_nothing )
17321734{
17331735 LOG_SCOPE ("stitch_meshes()" , "UnstructuredMesh" );
1734- stitching_helper (& other_mesh ,
1735- this_mesh_boundary_id ,
1736- other_mesh_boundary_id ,
1737- tol ,
1738- clear_stitched_boundary_ids ,
1739- verbose ,
1740- use_binary_search ,
1741- enforce_all_nodes_match_on_boundaries ,
1742- true);
1736+ return stitching_helper (& other_mesh ,
1737+ this_mesh_boundary_id ,
1738+ other_mesh_boundary_id ,
1739+ tol ,
1740+ clear_stitched_boundary_ids ,
1741+ verbose ,
1742+ use_binary_search ,
1743+ enforce_all_nodes_match_on_boundaries ,
1744+ true,
1745+ merge_boundary_nodes_all_or_nothing );
17431746}
17441747
17451748
1746- void UnstructuredMesh ::stitch_surfaces (boundary_id_type boundary_id_1 ,
1747- boundary_id_type boundary_id_2 ,
1748- Real tol ,
1749- bool clear_stitched_boundary_ids ,
1750- bool verbose ,
1751- bool use_binary_search ,
1752- bool enforce_all_nodes_match_on_boundaries )
1749+ std ::size_t
1750+ UnstructuredMesh ::stitch_surfaces (boundary_id_type boundary_id_1 ,
1751+ boundary_id_type boundary_id_2 ,
1752+ Real tol ,
1753+ bool clear_stitched_boundary_ids ,
1754+ bool verbose ,
1755+ bool use_binary_search ,
1756+ bool enforce_all_nodes_match_on_boundaries ,
1757+ bool merge_boundary_nodes_all_or_nothing )
1758+
17531759{
1754- stitching_helper (nullptr ,
1755- boundary_id_1 ,
1756- boundary_id_2 ,
1757- tol ,
1758- clear_stitched_boundary_ids ,
1759- verbose ,
1760- use_binary_search ,
1761- enforce_all_nodes_match_on_boundaries ,
1762- true);
1760+ return stitching_helper (nullptr ,
1761+ boundary_id_1 ,
1762+ boundary_id_2 ,
1763+ tol ,
1764+ clear_stitched_boundary_ids ,
1765+ verbose ,
1766+ use_binary_search ,
1767+ enforce_all_nodes_match_on_boundaries ,
1768+ true ,
1769+ merge_boundary_nodes_all_or_nothing );
17631770}
17641771
17651772
1766- void UnstructuredMesh ::stitching_helper (const MeshBase * other_mesh ,
1767- boundary_id_type this_mesh_boundary_id ,
1768- boundary_id_type other_mesh_boundary_id ,
1769- Real tol ,
1770- bool clear_stitched_boundary_ids ,
1771- bool verbose ,
1772- bool use_binary_search ,
1773- bool enforce_all_nodes_match_on_boundaries ,
1774- bool skip_find_neighbors )
1773+ std ::size_t
1774+ UnstructuredMesh ::stitching_helper (const MeshBase * other_mesh ,
1775+ boundary_id_type this_mesh_boundary_id ,
1776+ boundary_id_type other_mesh_boundary_id ,
1777+ Real tol ,
1778+ bool clear_stitched_boundary_ids ,
1779+ bool verbose ,
1780+ bool use_binary_search ,
1781+ bool enforce_all_nodes_match_on_boundaries ,
1782+ bool skip_find_neighbors ,
1783+ bool merge_boundary_nodes_all_or_nothing )
17751784{
17761785#ifdef DEBUG
17771786 // We rely on neighbor links here
@@ -2109,6 +2118,26 @@ void UnstructuredMesh::stitching_helper (const MeshBase * other_mesh,
21092118 libmesh_error_msg_if ((n_matching_nodes != this_mesh_n_nodes ) || (n_matching_nodes != other_mesh_n_nodes ),
21102119 "Error: We expected the number of nodes to match." );
21112120 }
2121+
2122+ if (merge_boundary_nodes_all_or_nothing )
2123+ {
2124+ std ::size_t n_matching_nodes = node_to_node_map .size ();
2125+ std ::size_t this_mesh_n_nodes = this_boundary_node_ids .size ();
2126+ std ::size_t other_mesh_n_nodes = other_boundary_node_ids .size ();
2127+ if ((n_matching_nodes != this_mesh_n_nodes ) || (n_matching_nodes != other_mesh_n_nodes ))
2128+ {
2129+ if (verbose )
2130+ {
2131+ libMesh ::out << "Skipping node merging in "
2132+ "UnstructuredMesh::stitch_meshes because not "
2133+ "all boundary nodes were matched."
2134+ << std ::endl ;
2135+ }
2136+ node_to_node_map .clear ();
2137+ other_to_this_node_map .clear ();
2138+ node_to_elems_map .clear ();
2139+ }
2140+ }
21122141 }
21132142 else
21142143 {
@@ -2395,6 +2424,9 @@ void UnstructuredMesh::stitching_helper (const MeshBase * other_mesh,
23952424 this -> get_boundary_info ().clear_stitched_boundary_side_ids (
23962425 this_mesh_boundary_id , other_mesh_boundary_id , /*clear_nodeset_data=*/ true);
23972426 }
2427+
2428+ // Return the number of nodes which were merged.
2429+ return node_to_node_map .size ();
23982430}
23992431
24002432
0 commit comments