Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions framework/src/geomsearch/NearestNodeLocator.C
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ NearestNodeLocator::findNodes()
* surrounding each of the secondary nodes. This will speed searching later.
*/
const std::map<dof_id_type, std::vector<dof_id_type>> & node_to_elem_map = _mesh.nodeToElemMap();
std::set<dof_id_type> new_ghost(_new_ghosted_elems.begin(), _new_ghosted_elems.end());

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

Threads::parallel_reduce(trial_secondary_node_range, snt_ghosting);
new_ghost.insert(snt_ghosting._ghosted_elems.begin(), snt_ghosting._ghosted_elems.end());

for (const auto & dof : snt_ghosting._ghosted_elems)
_subproblem.addGhostedElem(dof);
Expand Down Expand Up @@ -193,11 +195,15 @@ NearestNodeLocator::findNodes()
{
const std::vector<dof_id_type> & elems_connected_to_node = node_to_elem_pair->second;
for (const auto & dof : elems_connected_to_node)
if (std::find(ghost.begin(), ghost.end(), dof) == ghost.end() &&
_mesh.elemPtr(dof)->processor_id() != _mesh.processor_id())
{
const Elem * elem = _mesh.elemPtr(dof);
// Only error if element is truly inaccessible (remote_elem or nullptr)
if (elem == libMesh::remote_elem || elem == nullptr)
mooseError("Error in NearestNodeLocator: The nearest neighbor lies outside the "
"ghosted set of elements. Increase the ghosting_patch_size parameter in the "
"mesh block and try again.");
"ghosted set of elements...");

// Otherwise trust that ghosting will be/is correct
}
}
}
}
Expand Down Expand Up @@ -347,11 +353,16 @@ NearestNodeLocator::updatePatch(std::vector<dof_id_type> & secondary_nodes)
{
const std::vector<dof_id_type> & elems_connected_to_node = node_to_elem_pair->second;
for (const auto & dof : elems_connected_to_node)
if (std::find(ghost.begin(), ghost.end(), dof) == ghost.end() &&
_mesh.elemPtr(dof)->processor_id() != _mesh.processor_id())
mooseError("Error in NearestNodeLocator: The nearest neighbor lies outside the ghosted "
"set of elements. Increase the ghosting_patch_size parameter in the mesh "
"block and try again.");
{
const Elem * elem = _mesh.elemPtr(dof);
// Only error if element is truly inaccessible (remote_elem or nullptr)
if (elem == libMesh::remote_elem || elem == nullptr)
mooseError("Error in NearestNodeLocator: The nearest neighbor lies outside the "
"ghosted set of elements. Increase the ghosting_patch_size parameter in the "
"mesh block and try again.");

// Otherwise trust that ghosting will be/is correct
}
}
}
}
Expand Down