Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : // App includes 11 : #include "GhostAllPointNeighbors.h" 12 : #include "Executioner.h" 13 : #include "FEProblemBase.h" 14 : #include "MooseApp.h" 15 : #include "GhostLowerDElems.h" 16 : #include "GhostHigherDLowerDPointNeighbors.h" 17 : 18 : // libMesh includes 19 : #include "libmesh/elem.h" 20 : #include "libmesh/mesh_base.h" 21 : #include "libmesh/boundary_info.h" 22 : 23 : registerMooseObject("MooseApp", GhostAllPointNeighbors); 24 : 25 : using namespace libMesh; 26 : 27 : InputParameters 28 26697 : GhostAllPointNeighbors::validParams() 29 : { 30 26697 : InputParameters params = RelationshipManager::validParams(); 31 26697 : params.set<bool>("attach_geometric_early") = false; 32 26697 : return params; 33 0 : } 34 : 35 11469 : GhostAllPointNeighbors::GhostAllPointNeighbors(const InputParameters & params) 36 11469 : : RelationshipManager(params) 37 : { 38 11469 : } 39 : 40 698 : GhostAllPointNeighbors::GhostAllPointNeighbors(const GhostAllPointNeighbors & other) 41 698 : : RelationshipManager(other) 42 : { 43 698 : } 44 : 45 : std::string 46 0 : GhostAllPointNeighbors::getInfo() const 47 : { 48 0 : std::ostringstream oss; 49 0 : oss << "GhostAllPointNeighbors"; 50 0 : return oss.str(); 51 0 : } 52 : 53 : void 54 458 : GhostAllPointNeighbors::operator()(const MeshBase::const_element_iterator & range_begin, 55 : const MeshBase::const_element_iterator & range_end, 56 : const processor_id_type p, 57 : map_type & coupled_elements) 58 : { 59 : mooseAssert(_moose_mesh, 60 : "The MOOSE mesh must be non-null in order for this relationship manager to work."); 61 458 : const auto & node_to_elem_map = _moose_mesh->nodeToElemMap(); 62 : 63 : static const CouplingMatrix * const null_mat = nullptr; 64 458 : std::unordered_set<dof_id_type> visited_nodes; 65 : 66 60542 : for (const Elem * const elem : as_range(range_begin, range_end)) 67 221982 : for (const auto & node : elem->node_ref_range()) 68 : { 69 : // We want to ghost the point neighbors if the node hasn't been partitioned yet 70 : // (e.g. we don't know what processes it will be) or if its processor id matches our 71 : // processes's id 72 191940 : const auto node_pid = node.processor_id(); 73 191940 : if (node_pid == p || node_pid == DofObject::invalid_processor_id) 74 : { 75 183767 : const auto [_, inserted] = visited_nodes.insert(node.id()); 76 183767 : if (!inserted) 77 : // We've already considered this node 78 108240 : continue; 79 : 80 75527 : const auto & elem_node_neighbors = libmesh_map_find(node_to_elem_map, node.id()); 81 267467 : for (const auto elem_id : elem_node_neighbors) 82 : { 83 191940 : const Elem * const elem_node_neighbor = _mesh->elem_ptr(elem_id); 84 191940 : if (elem_node_neighbor->processor_id() != p) 85 8173 : coupled_elements.emplace(elem_node_neighbor, null_mat); 86 : } 87 : } 88 458 : } 89 458 : } 90 : 91 : bool 92 35087 : GhostAllPointNeighbors::operator>=(const RelationshipManager & other) const 93 : { 94 59057 : return dynamic_cast<const GhostAllPointNeighbors *>(&other) || 95 59057 : dynamic_cast<const GhostLowerDElems *>(&other) || 96 47399 : dynamic_cast<const GhostHigherDLowerDPointNeighbors *>(&other); 97 : } 98 : 99 : std::unique_ptr<GhostingFunctor> 100 698 : GhostAllPointNeighbors::clone() const 101 : { 102 698 : return _app.getFactory().copyConstruct(*this); 103 : }