Skip to content

Commit d100e50

Browse files
committed
Refactor: Fold DisconnectedNeighborCoupling into GhostPointNeighbors
Refactored the ghosting workflow following @roystgnr’s review. Removed the separate DisconnectedNeighborCoupling class and integrated its logic directly into GhostPointNeighbors for a cleaner and more consistent approach. This avoids duplicate functor additions in `UnstructuredMesh::find_neighbors`. - Deleted `DisconnectedNeighborCoupling.[C,h]` and updated Makefiles - Moved all related logic into `GhostPointNeighbors::operator()` - Added move assignment and equality checks for `_disconnected_boundary_pairs` in `MeshBase`. This was a great catch from Roy and is needed for mesh cloning/comparisons to work correctly. - Added `libmesh_deprecated()` warning to `UnstructuredMesh::stitching_helper` for disconnected meshes - Replaced a `libmesh_error_msg` in `MeshRefinement` with `libmesh_not_implemented_msg` - Updated unit tests: added `LOG_UNIT_TEST` for `disconnected_neighbor_test`
1 parent 38787d8 commit d100e50

File tree

15 files changed

+63
-232
lines changed

15 files changed

+63
-232
lines changed

Makefile.in

Lines changed: 1 addition & 82 deletions
Large diffs are not rendered by default.

build-aux/ltmain.sh

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7648,11 +7648,6 @@ func_mode_link ()
76487648
arg=$func_stripname_result
76497649
;;
76507650

7651-
-Wl,--as-needed)
7652-
deplibs="$deplibs $arg"
7653-
continue
7654-
;;
7655-
76567651
-Wl,*)
76577652
func_stripname '-Wl,' '' "$arg"
76587653
args=$func_stripname_result
@@ -7995,7 +7990,6 @@ func_mode_link ()
79957990

79967991
case $linkmode in
79977992
lib)
7998-
as_needed_flag=
79997993
passes="conv dlpreopen link"
80007994
for file in $dlfiles $dlprefiles; do
80017995
case $file in
@@ -8007,7 +8001,6 @@ func_mode_link ()
80078001
done
80088002
;;
80098003
prog)
8010-
as_needed_flag=
80118004
compile_deplibs=
80128005
finalize_deplibs=
80138006
alldeplibs=false
@@ -8077,15 +8070,6 @@ func_mode_link ()
80778070
lib=
80788071
found=false
80798072
case $deplib in
8080-
-Wl,--as-needed)
8081-
if test prog,link = "$linkmode,$pass" ||
8082-
test lib,link = "$linkmode,$pass"; then
8083-
as_needed_flag="$deplib "
8084-
else
8085-
deplibs="$deplib $deplibs"
8086-
fi
8087-
continue
8088-
;;
80898073
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
80908074
|-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
80918075
if test prog,link = "$linkmode,$pass"; then
@@ -10411,13 +10395,6 @@ func_mode_link ()
1041110395
test "X$libobjs" = "X " && libobjs=
1041210396
fi
1041310397

10414-
# A bit hacky. I had wanted to add \$as_needed_flag to archive_cmds instead, but that
10415-
# comes from libtool.m4 which is part of the project being built. This should put it
10416-
# in the right place though.
10417-
if test lib,link = "$linkmode,$pass" && test -n "$as_needed_flag"; then
10418-
libobjs=$as_needed_flag$libobjs
10419-
fi
10420-
1042110398
save_ifs=$IFS; IFS='~'
1042210399
for cmd in $cmds; do
1042310400
IFS=$sp$nl
@@ -10650,8 +10627,8 @@ func_mode_link ()
1065010627
compile_deplibs=$new_libs
1065110628

1065210629

10653-
func_append compile_command " $as_needed_flag $compile_deplibs"
10654-
func_append finalize_command " $as_needed_flag $finalize_deplibs"
10630+
func_append compile_command " $compile_deplibs"
10631+
func_append finalize_command " $finalize_deplibs"
1065510632

1065610633
if test -n "$rpath$xrpath"; then
1065710634
# If the user specified any rpath flags, then add them.

include/Makefile.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ include_HEADERS = \
780780
geom/surface.h \
781781
ghosting/default_coupling.h \
782782
ghosting/ghost_point_neighbors.h \
783-
ghosting/disconnected_neighbor_coupling.h \
784783
ghosting/ghosting_functor.h \
785784
ghosting/non_manifold_coupling.h \
786785
ghosting/overlap_coupling.h \
@@ -1119,7 +1118,7 @@ include_HEADERS = \
11191118
utils/utility.h \
11201119
utils/vectormap.h \
11211120
utils/win_gettimeofday.h \
1122-
utils/xdr_cxx.h
1121+
utils/xdr_cxx.h
11231122

11241123

11251124
# definition of include_HEADERS - get from auto-maintained list

include/ghosting/disconnected_neighbor_coupling.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

include/include_HEADERS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ include_HEADERS = \
176176
geom/surface.h \
177177
ghosting/default_coupling.h \
178178
ghosting/ghost_point_neighbors.h \
179-
ghosting/disconnected_neighbor_coupling.h \
180179
ghosting/ghosting_functor.h \
181180
ghosting/non_manifold_coupling.h \
182181
ghosting/overlap_coupling.h \
@@ -515,4 +514,4 @@ include_HEADERS = \
515514
utils/utility.h \
516515
utils/vectormap.h \
517516
utils/win_gettimeofday.h \
518-
utils/xdr_cxx.h
517+
utils/xdr_cxx.h

include/libmesh/Makefile.am

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ BUILT_SOURCES = \
166166
surface.h \
167167
default_coupling.h \
168168
ghost_point_neighbors.h \
169-
disconnected_neighbor_coupling.h \
170169
ghosting_functor.h \
171170
non_manifold_coupling.h \
172171
overlap_coupling.h \
@@ -1098,9 +1097,6 @@ default_coupling.h: $(top_srcdir)/include/ghosting/default_coupling.h
10981097
ghost_point_neighbors.h: $(top_srcdir)/include/ghosting/ghost_point_neighbors.h
10991098
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
11001099

1101-
disconnected_neighbor_coupling.h: $(top_srcdir)/include/ghosting/disconnected_neighbor_coupling.h
1102-
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
1103-
11041100
ghosting_functor.h: $(top_srcdir)/include/ghosting/ghosting_functor.h
11051101
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
11061102

include/libmesh/Makefile.in

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,7 @@ BUILT_SOURCES = dirichlet_boundaries.h dof_map.h dof_map_base.h \
575575
face_tri3_subdivision.h face_tri6.h face_tri7.h node.h \
576576
node_elem.h node_range.h plane.h point.h reference_elem.h \
577577
remote_elem.h sphere.h stored_range.h surface.h \
578-
default_coupling.h ghost_point_neighbors.h \
579-
disconnected_neighbor_coupling.h ghosting_functor.h \
578+
default_coupling.h ghost_point_neighbors.h ghosting_functor.h \
580579
non_manifold_coupling.h overlap_coupling.h \
581580
point_neighbor_coupling.h sibling_coupling.h abaqus_io.h \
582581
boundary_info.h boundary_mesh.h checkpoint_io.h \
@@ -1432,9 +1431,6 @@ default_coupling.h: $(top_srcdir)/include/ghosting/default_coupling.h
14321431
ghost_point_neighbors.h: $(top_srcdir)/include/ghosting/ghost_point_neighbors.h
14331432
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
14341433

1435-
disconnected_neighbor_coupling.h: $(top_srcdir)/include/ghosting/disconnected_neighbor_coupling.h
1436-
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
1437-
14381434
ghosting_functor.h: $(top_srcdir)/include/ghosting/ghosting_functor.h
14391435
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
14401436

include/mesh/mesh_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ class MeshBase : public ParallelObject
18461846

18471847
protected:
18481848

1849-
#ifdef LIBMESH_ENABLE_PERIODIC
1849+
#ifdef LIBMESH_ENABLE_PERIODIC
18501850
/// @brief The disconnected boundary id pairs.
18511851
std::unique_ptr<PeriodicBoundaries> _disconnected_boundary_pairs;
18521852
#endif

src/ghosting/disconnected_neighbor_coupling.C

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/ghosting/ghost_point_neighbors.C

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ void GhostPointNeighbors::operator()
4646
bool check_periodic_bcs =
4747
(_periodic_bcs && !_periodic_bcs->empty());
4848

49+
auto * db = _mesh->get_disconnected_boundaries();
50+
bool check_disconnected_bcs = (db && !db->empty());
51+
4952
std::unique_ptr<PointLocatorBase> point_locator;
50-
if (check_periodic_bcs)
53+
if (check_periodic_bcs || check_disconnected_bcs)
5154
point_locator = _mesh->sub_point_locator();
5255

5356
std::set<const Elem *> periodic_elems_examined;
@@ -176,6 +179,30 @@ void GhostPointNeighbors::operator()
176179
}
177180
}
178181
}
182+
183+
if (check_disconnected_bcs)
184+
{
185+
// Also ghost their disconnected neighbors
186+
for (auto s : elem->side_index_range())
187+
{
188+
for (const auto & [id, boundary_ptr] : *db)
189+
{
190+
if (!_mesh->get_boundary_info().has_boundary_id(elem, s, id))
191+
continue;
192+
193+
unsigned int neigh_side = invalid_uint;
194+
const Elem * neigh =
195+
db->neighbor(id, *point_locator, elem, s, &neigh_side);
196+
197+
if (!neigh || neigh == remote_elem)
198+
continue;
199+
200+
if (neigh->processor_id() != p)
201+
coupled_elements.emplace(neigh, nullcm);
202+
}
203+
}
204+
}
205+
179206
#endif // LIBMESH_ENABLE_PERIODIC
180207
}
181208
}

0 commit comments

Comments
 (0)