Index: include/geom/elem.h =================================================================== --- include/geom/elem.h (Revision 3518) +++ include/geom/elem.h (Arbeitskopie) @@ -211,12 +211,25 @@ bool contains_vertex_of(const Elem *e) const; /** + * This function returns true iff an edge of \p e is contained in + * this element. (Internally, this is done by checking whether at + * least two vertices of \p e are contained in this element). + */ + bool contains_edge_of(const Elem *e) const; + + /** * This function finds all elements which * touch the current element at any point */ void find_point_neighbors(std::set &neighbor_set) const; /** + * This function finds all elements which touch the current element + * at any edge (more precisely, at at least two points). + */ + void find_edge_neighbors(std::set &neighbor_set) const; + + /** * Resets this element's neighbors' appropriate neighbor pointers * and its parent's and children's appropriate pointers * to point to the global remote_elem instead of this. Index: src/geom/elem.C =================================================================== --- src/geom/elem.C (Revision 3518) +++ src/geom/elem.C (Arbeitskopie) @@ -440,6 +440,27 @@ +bool Elem::contains_edge_of(const Elem *e) const +{ + unsigned int num_contained_edges = 0; + + // Our vertices are the first numbered nodes + for (unsigned int n = 0; n != e->n_vertices(); ++n) + { + if (this->contains_point(e->point(n))) + { + num_contained_edges++; + if(num_contained_edges>=2) + { + return true; + } + } + } + return false; +} + + + void Elem::find_point_neighbors(std::set &neighbor_set) const { neighbor_set.clear(); @@ -498,6 +519,64 @@ +void Elem::find_edge_neighbors(std::set &neighbor_set) const +{ + neighbor_set.clear(); + neighbor_set.insert(this); + + unsigned int old_size; + do + { + old_size = neighbor_set.size(); + + // Loop over all the elements in the patch + std::set::const_iterator it = neighbor_set.begin(); + const std::set::const_iterator end = neighbor_set.end(); + + for (; it != end; ++it) + { + const Elem* elem = *it; + + for (unsigned int s=0; sn_sides(); s++) + { + const Elem* neighbor = elem->neighbor(s); + if (neighbor && + neighbor != remote_elem) // we have a real neighbor on this side + { + if (neighbor->active()) // ... if it is active + { + if (this->contains_edge_of(neighbor) // ... and touches us + || neighbor->contains_edge_of(this)) + neighbor_set.insert (neighbor); // ... then add it + } +#ifdef LIBMESH_ENABLE_AMR + else // ... the neighbor is *not* active, + { // ... so add *all* neighboring + // active children + std::vector active_neighbor_children; + + neighbor->active_family_tree_by_neighbor + (active_neighbor_children, elem); + + std::vector::const_iterator + child_it = active_neighbor_children.begin(); + const std::vector::const_iterator + child_end = active_neighbor_children.end(); + for (; child_it != child_end; ++child_it) + if (this->contains_edge_of(*child_it) || + (*child_it)->contains_edge_of(this)) + neighbor_set.insert (*child_it); + } +#endif // #ifdef LIBMESH_ENABLE_AMR + } + } + } + } + while (old_size != neighbor_set.size()); +} + + + #ifdef DEBUG void Elem::libmesh_assert_valid_node_pointers() const