+template <int structdim, int dim, int spacedim>
+inline
+bool
+TriaAccessorBase<structdim,dim,spacedim>::operator < (const TriaAccessorBase<structdim,dim,spacedim> &other) const
+{
+ Assert (tria == other.tria, TriaAccessorExceptions::ExcCantCompareIterators());
+
+ if (present_level != other.present_level)
+ return (present_level < other.present_level);
+
+ return (present_index < other.present_index);
+
+}
+
+
+
template <int structdim, int dim, int spacedim>
inline
int
return neighbor_of_coarser_neighbor(neighbor).first;
}
+
+template <int dim, int spacedim>
+inline
+bool
+CellAccessor<dim,spacedim>::operator < (const CellAccessor<dim,spacedim> &other) const
+{
+ Assert (this->tria == other.tria, TriaAccessorExceptions::ExcCantCompareIterators());
+
+ if (level_subdomain_id() != other.level_subdomain_id())
+ return (level_subdomain_id() < other.level_subdomain_id());
+
+ if (active() && other.active() &&
+ (subdomain_id() != other.subdomain_id()))
+ return (subdomain_id() < other.subdomain_id());
+
+ return TriaAccessorBase<dim,dim,spacedim>::operator < (other);
+}
+
+
+
DEAL_II_NAMESPACE_CLOSE
#endif
//---------------------------------------------------------------------------
// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
bool operator != (const TriaRawIterator &) const;
/**
- * Offer a weak ordering of iterators,
- * which is needed to make @p maps with
- * iterators being keys. An iterator
- * pointing to an element @p a is
- * less than another iterator pointing
- * to an element @p b if
- * level(a)<level(b) or
- * (level(a)==level(b) and index(a)<index(b)).
+ * Ordering relation for iterators.
*
- * Comparing iterators of which one or
- * both are invalid is an error. The
- * past-the-end iterator is always
- * ordered last. Two past-the-end
- * iterators rank the same, thus false
- * is returned in that case.
+ * This relation attempts a total ordering of cells. For lower
+ * dimensional objects on distributed meshes, we only attempt a
+ * partial ordering.
+ *
+ * The relation is defined as follows:
+ *
+ * For objects of <tt>Accessor::structure_dimension <
+ * Accessor::dimension</tt>, we simply compare the index of such an
+ * object. This consitutes an ordering of the elements of same
+ * dimension on a mesh on a single process. For a distributed mesh,
+ * the result of the ordering relation between faces across
+ * processes is not defined, but most likely irrelevant.
+ *
+ * For cells, there is a total ordering even in a
+ * distributed::parallel::Triangulation. The ordering is lexicographic
+ * according to the following hierarchy (in the sense, that the next
+ * test is only applied if the previous was inconclusive):
+ *
+ * <ol>
+ * <li> The past-the-end iterator is always ordered last. Two
+ * past-the-end iterators rank the same, thus false is returned in
+ * that case.</li>
+ *
+ * <li> The level subdomain id</li>
+ * <li> If both cells are active, the subdomain id.</li>
+ * <li> The level of the cell.</li>
+ * <li> The index of a cell inside the level.</li>
+ * </ol>
*/
bool operator < (const TriaRawIterator &) const;
template <typename Accessor>
inline
bool
-TriaRawIterator<Accessor>::operator < (const TriaRawIterator &i) const
+TriaRawIterator<Accessor>::operator < (const TriaRawIterator<Accessor> &other) const
{
- Assert (Accessor::structure_dimension!=Accessor::dimension ||
- state() != IteratorState::invalid,
- ExcDereferenceInvalidCell(accessor));
- Assert (Accessor::structure_dimension==Accessor::dimension ||
- state() != IteratorState::invalid,
- ExcDereferenceInvalidObject(accessor));
-
- Assert (Accessor::structure_dimension!=Accessor::dimension ||
- i.state() != IteratorState::invalid,
- ExcDereferenceInvalidCell(i.accessor));
- Assert (Accessor::structure_dimension==Accessor::dimension ||
- i.state() != IteratorState::invalid,
- ExcDereferenceInvalidObject(i.accessor));
+ Assert (state() != IteratorState::invalid, ExcDereferenceInvalidObject(accessor));
+ Assert (other.state() != IteratorState::invalid, ExcDereferenceInvalidObject(other.accessor));
- Assert (&accessor.get_triangulation() == &i.accessor.get_triangulation(),
+ Assert (&accessor.get_triangulation() == &other.accessor.get_triangulation(),
ExcInvalidComparison());
-
- if (Accessor::structure_dimension==Accessor::dimension)
- return ((((accessor.level() < i.accessor.level()) ||
- ((accessor.level() == i.accessor.level()) &&
- (accessor.index() < i.accessor.index())) ) &&
- (state()==IteratorState::valid) &&
- (i.state()==IteratorState::valid) ) ||
- ((state()==IteratorState::valid) &&
- (i.state()==IteratorState::past_the_end)));
- else
- return ((((accessor.index() < i.accessor.index()) ) &&
- (state()==IteratorState::valid) &&
- (i.state()==IteratorState::valid) ) ||
- ((state()==IteratorState::valid) &&
- (i.state()==IteratorState::past_the_end)));
+
+ // Deal with iterators past end
+ if (state()==IteratorState::past_the_end)
+ return false;
+ if (other.state()==IteratorState::past_the_end)
+ return true;
+
+ return ((**this) < (*other));
}