Skip to content

Commit 551335b

Browse files
committed
Relax ghosting check
1 parent 760e74c commit 551335b

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

framework/src/geomsearch/NearestNodeLocator.C

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ NearestNodeLocator::findNodes()
6969
* surrounding each of the secondary nodes. This will speed searching later.
7070
*/
7171
const std::map<dof_id_type, std::vector<dof_id_type>> & node_to_elem_map = _mesh.nodeToElemMap();
72+
std::set<dof_id_type> new_ghost(_new_ghosted_elems.begin(), _new_ghosted_elems.end());
7273

7374
if (_first || (_reinit_iteration && _patch_update_strategy == Moose::Iteration))
7475
{
@@ -151,6 +152,7 @@ NearestNodeLocator::findNodes()
151152
_mesh, trial_primary_nodes, node_to_elem_map, _mesh.getGhostingPatchSize(), kd_tree);
152153

153154
Threads::parallel_reduce(trial_secondary_node_range, snt_ghosting);
155+
new_ghost.insert(snt_ghosting._ghosted_elems.begin(), snt_ghosting._ghosted_elems.end());
154156

155157
for (const auto & dof : snt_ghosting._ghosted_elems)
156158
_subproblem.addGhostedElem(dof);
@@ -193,11 +195,15 @@ NearestNodeLocator::findNodes()
193195
{
194196
const std::vector<dof_id_type> & elems_connected_to_node = node_to_elem_pair->second;
195197
for (const auto & dof : elems_connected_to_node)
196-
if (std::find(ghost.begin(), ghost.end(), dof) == ghost.end() &&
197-
_mesh.elemPtr(dof)->processor_id() != _mesh.processor_id())
198+
{
199+
const Elem * elem = _mesh.elemPtr(dof);
200+
// Only error if element is truly inaccessible (remote_elem or nullptr)
201+
if (elem == libMesh::remote_elem || elem == nullptr)
198202
mooseError("Error in NearestNodeLocator: The nearest neighbor lies outside the "
199-
"ghosted set of elements. Increase the ghosting_patch_size parameter in the "
200-
"mesh block and try again.");
203+
"ghosted set of elements...");
204+
205+
// Otherwise trust that ghosting will be/is correct
206+
}
201207
}
202208
}
203209
}
@@ -347,11 +353,16 @@ NearestNodeLocator::updatePatch(std::vector<dof_id_type> & secondary_nodes)
347353
{
348354
const std::vector<dof_id_type> & elems_connected_to_node = node_to_elem_pair->second;
349355
for (const auto & dof : elems_connected_to_node)
350-
if (std::find(ghost.begin(), ghost.end(), dof) == ghost.end() &&
351-
_mesh.elemPtr(dof)->processor_id() != _mesh.processor_id())
352-
mooseError("Error in NearestNodeLocator: The nearest neighbor lies outside the ghosted "
353-
"set of elements. Increase the ghosting_patch_size parameter in the mesh "
354-
"block and try again.");
356+
{
357+
const Elem * elem = _mesh.elemPtr(dof);
358+
// Only error if element is truly inaccessible (remote_elem or nullptr)
359+
if (elem == libMesh::remote_elem || elem == nullptr)
360+
mooseError("Error in NearestNodeLocator: The nearest neighbor lies outside the "
361+
"ghosted set of elements. Increase the ghosting_patch_size parameter in the "
362+
"mesh block and try again.");
363+
364+
// Otherwise trust that ghosting will be/is correct
365+
}
355366
}
356367
}
357368
}

0 commit comments

Comments
 (0)