29 #include <unordered_set> 41 if (dof_coupling && dof_coupling->
empty())
56 #ifdef LIBMESH_ENABLE_PERIODIC 63 libmesh_assert(
_mesh);
72 void DefaultCoupling::operator()
78 LOG_SCOPE(
"operator()",
"DefaultCoupling");
80 #ifdef LIBMESH_ENABLE_PERIODIC 81 bool check_periodic_bcs =
82 (_periodic_bcs && !_periodic_bcs->empty());
84 std::unique_ptr<PointLocatorBase> point_locator;
85 if (check_periodic_bcs)
87 libmesh_assert(_mesh);
88 point_locator = _mesh->sub_point_locator();
94 for (
const auto & elem :
as_range(range_begin, range_end))
95 if (elem->processor_id() != p)
96 coupled_elements.insert (std::make_pair(elem,_dof_coupling));
100 typedef std::unordered_set<const Elem*> set_type;
101 set_type next_elements_to_check(range_begin, range_end);
102 set_type elements_to_check;
103 set_type elements_checked;
105 for (
unsigned int i=0; i != this->_n_levels; ++i)
107 elements_to_check.swap(next_elements_to_check);
108 next_elements_to_check.clear();
109 elements_checked.insert(elements_to_check.begin(), elements_to_check.end());
111 for (
const auto & elem : elements_to_check)
113 std::vector<const Elem *> active_neighbors;
115 if (elem->processor_id() != p)
116 coupled_elements.insert (std::make_pair(elem,_dof_coupling));
118 for (
auto s : elem->side_index_range())
132 #ifdef LIBMESH_ENABLE_PERIODIC 134 else if (check_periodic_bcs)
136 libmesh_assert(_mesh);
139 (s, *_mesh, *point_locator, _periodic_bcs);
150 #ifdef LIBMESH_ENABLE_AMR 153 # ifdef LIBMESH_ENABLE_PERIODIC 156 (active_neighbors,elem,*_mesh,*point_locator,_periodic_bcs);
159 active_neighbors.clear();
160 active_neighbors.push_back(neigh);
163 for (
const auto & neighbor : active_neighbors)
165 if (!elements_checked.count(neighbor))
166 next_elements_to_check.insert(neighbor);
168 if (neighbor->processor_id() != p)
169 coupled_elements.insert
170 (std::make_pair(neighbor, _dof_coupling));
std::unique_ptr< PointLocatorBase > sub_point_locator() const
const Elem * topological_neighbor(const unsigned int i, const MeshBase &mesh, const PointLocatorBase &point_locator, const PeriodicBoundaries *pb) const
The base class for all geometric element types.
uint8_t processor_id_type
virtual void mesh_reinit() override
void active_family_tree_by_topological_neighbor(std::vector< const Elem *> &family, const Elem *neighbor, const MeshBase &mesh, const PointLocatorBase &point_locator, const PeriodicBoundaries *pb, const bool reset=true) const
SimpleRange< I > as_range(const std::pair< I, I > &p)
std::unordered_map< const Elem *, const CouplingMatrix * > map_type
void set_dof_coupling(const CouplingMatrix *dof_coupling)
void active_family_tree_by_neighbor(std::vector< const Elem *> &family, const Elem *neighbor, const bool reset=true) const
const Elem * neighbor_ptr(unsigned int i) const
const CouplingMatrix * _dof_coupling
const PeriodicBoundaries * _periodic_bcs
Defines the coupling between variables of a System.
const RemoteElem * remote_elem