21 #include "libmesh/default_coupling.h" 22 #include "libmesh/coupling_matrix.h" 23 #include "libmesh/elem.h" 24 #include "libmesh/periodic_boundaries.h" 25 #include "libmesh/remote_elem.h" 26 #include "libmesh/int_range.h" 27 #include "libmesh/libmesh_logging.h" 30 #include <unordered_set> 42 if (dof_coupling && dof_coupling->
empty())
57 #ifdef LIBMESH_ENABLE_PERIODIC 73 void DefaultCoupling::operator()
79 LOG_SCOPE(
"operator()",
"DefaultCoupling");
88 #ifdef LIBMESH_ENABLE_PERIODIC 89 bool check_periodic_bcs =
90 (_periodic_bcs && !_periodic_bcs->empty());
92 std::unique_ptr<PointLocatorBase> point_locator;
93 if (check_periodic_bcs)
96 point_locator = _mesh->sub_point_locator();
100 if (!this->_n_levels)
102 for (
const auto & elem :
as_range(range_begin, range_end))
105 if (elem->processor_id() != p)
106 coupled_elements.emplace(elem, _dof_coupling);
111 typedef std::unordered_set<const Elem*> set_type;
112 set_type next_elements_to_check(range_begin, range_end);
113 set_type elements_to_check;
114 set_type elements_checked;
116 for (
unsigned int i=0; i != this->_n_levels; ++i)
118 elements_to_check.swap(next_elements_to_check);
119 next_elements_to_check.clear();
120 elements_checked.insert(elements_to_check.begin(), elements_to_check.end());
122 for (
const auto & elem : elements_to_check)
124 std::vector<const Elem *> active_neighbors;
128 if (elem->processor_id() != p)
129 coupled_elements.emplace(elem, _dof_coupling);
131 for (
auto s : elem->side_index_range())
135 #ifdef LIBMESH_ENABLE_PERIODIC 137 if (!neigh && check_periodic_bcs)
142 (s, *_mesh, *point_locator, _periodic_bcs);
156 #ifdef LIBMESH_ENABLE_AMR 159 # ifdef LIBMESH_ENABLE_PERIODIC 162 (active_neighbors,elem,*_mesh,*point_locator,_periodic_bcs);
165 active_neighbors.clear();
166 active_neighbors.push_back(neigh);
169 for (
const auto & neighbor : active_neighbors)
171 if (!elements_checked.count(neighbor))
172 next_elements_to_check.insert(neighbor);
174 if (neighbor->processor_id() != p)
175 coupled_elements.emplace(neighbor, _dof_coupling);
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, bool reset=true) const
Same as the active_family_tree_by_neighbor() member, but the neighbor here may be a topological (e...
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 definition of the const_element_iterator struct.
This is the base class from which all geometric element types are derived.
virtual void mesh_reinit() override
If we have periodic boundaries, then we'll need the mesh to have an updated point locator whenever we...
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
What elements do we care about and what variables do we care about on each element?
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t processor_id_type
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
void set_dof_coupling(const CouplingMatrix *dof_coupling)
void active_family_tree_by_neighbor(std::vector< const Elem *> &family, const Elem *neighbor, bool reset=true) const
Same as the active_family_tree() member, but only adds elements which are next to neighbor...
const Elem * neighbor_ptr(unsigned int i) const
const CouplingMatrix * _dof_coupling
const PeriodicBoundaries * _periodic_bcs
This class defines a coupling matrix.
const RemoteElem * remote_elem