~ubuntu-branches/ubuntu/utopic/dune-grid/utopic-proposed

« back to all changes in this revision

Viewing changes to dune/grid/yaspgrid/yaspgridintersectioniterator.hh

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2014-02-14 10:49:16 UTC
  • mfrom: (1.3.1) (5.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20140214104916-2clchnny3eu7ks4w
Tags: 2.3.0-2
InstallĀ /usr/share/dune-grid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 
2
// vi: set et ts=4 sw=2 sts=2:
 
3
#ifndef DUNE_GRID_YASPGRIDINTERSECTIONITERATOR_HH
 
4
#define DUNE_GRID_YASPGRIDINTERSECTIONITERATOR_HH
 
5
 
 
6
/** \file
 
7
 * \brief The YaspIntersectionIterator class
 
8
 
 
9
   YaspIntersectionIterator enables iteration over intersections with
 
10
   neighboring codim 0 entities.
 
11
 */
 
12
 
 
13
namespace Dune {
 
14
 
 
15
  /** \brief YaspIntersectionIterator enables iteration over intersections with
 
16
             neighboring codim 0 entities.
 
17
   */
 
18
  template<class GridImp>
 
19
  class YaspIntersectionIterator
 
20
  {
 
21
    enum { dim=GridImp::dimension };
 
22
    YaspIntersectionIterator();
 
23
  public:
 
24
    // types used from grids
 
25
    typedef Dune::Intersection< GridImp, Dune::YaspIntersection< GridImp > > Intersection;
 
26
    typedef MakeableInterfaceObject<Intersection> MakeableIntersection;
 
27
 
 
28
    //! increment
 
29
    void increment()
 
30
    {
 
31
      GridImp::getRealImplementation(intersection_)._count += (GridImp::getRealImplementation(intersection_)._count < 2*dim);
 
32
    }
 
33
 
 
34
    //! equality
 
35
    bool equals (const YaspIntersectionIterator& other) const
 
36
    {
 
37
      return GridImp::getRealImplementation(intersection_)._inside.equals(GridImp::getRealImplementation(other.intersection_)._inside)
 
38
             and (GridImp::getRealImplementation(intersection_)._count == GridImp::getRealImplementation(other.intersection_)._count);
 
39
    }
 
40
 
 
41
    //! \brief dereferencing
 
42
    const Intersection & dereference() const
 
43
    {
 
44
      return intersection_;
 
45
    }
 
46
 
 
47
    //! make intersection iterator from entity
 
48
    YaspIntersectionIterator (const YaspEntity<0,dim,GridImp>& myself, bool toend)
 
49
      : intersection_(MakeableIntersection(YaspIntersection<GridImp>(myself, toend)))
 
50
    {}
 
51
 
 
52
    //! copy constructor
 
53
    YaspIntersectionIterator (const YaspIntersectionIterator& other)
 
54
      : intersection_(other.intersection_)
 
55
    {}
 
56
 
 
57
    //! assignment
 
58
    YaspIntersectionIterator & operator = (const YaspIntersectionIterator& other)
 
59
    {
 
60
      GridImp::getRealImplementation(intersection_).assign(
 
61
        GridImp::getRealImplementation(other.intersection_));
 
62
      return *this;
 
63
    }
 
64
 
 
65
  private:
 
66
    // The intersection this iterator points to
 
67
    mutable MakeableIntersection intersection_;
 
68
  };
 
69
 
 
70
}        // namespace Dune
 
71
 
 
72
#endif   // DUNE_GRID_YASPGRIDINTERSECTIONITERATOR_HH