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

« back to all changes in this revision

Viewing changes to dune/grid/uggrid/uggridintersectioniterators.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:
1
3
#ifndef DUNE_UGINTERSECTIONIT_HH
2
4
#define DUNE_UGINTERSECTIONIT_HH
3
5
 
7
9
 
8
10
namespace Dune {
9
11
 
10
 
    /** \brief Implementation of the UGGrid LevelIntersectionIterator
11
 
     */
12
 
template<class GridImp>
13
 
class UGGridLevelIntersectionIterator
14
 
{
 
12
  /** \brief Implementation of the UGGrid LevelIntersectionIterator
 
13
   */
 
14
  template<class GridImp>
 
15
  class UGGridLevelIntersectionIterator
 
16
  {
15
17
 
16
18
    enum {dim=GridImp::dimension};
17
19
 
18
20
    friend class UGGridEntity<0,dim,GridImp>;
19
21
 
20
 
public:
21
 
 
22
 
    typedef Dune::Intersection<const GridImp, Dune::UGGridLevelIntersection> Intersection;
23
 
 
24
 
    /** The default Constructor makes empty Iterator 
25
 
    */
 
22
  public:
 
23
    typedef Dune::Intersection< GridImp, Dune::UGGridLevelIntersection< GridImp > > Intersection;
 
24
 
 
25
    /** The default Constructor makes empty Iterator
 
26
     */
26
27
    UGGridLevelIntersectionIterator(typename UG_NS<dim>::Element* center, int nb, const GridImp* gridImp)
27
 
        : intersection_(UGGridLevelIntersection<GridImp>(center,nb,gridImp))
 
28
      : intersection_(UGGridLevelIntersection<GridImp>(center,nb,gridImp))
28
29
    {}
29
30
 
30
31
    //! equality
31
32
    bool equals(const UGGridLevelIntersectionIterator<GridImp>& other) const {
32
 
        return GridImp::getRealImplementation(intersection_).equals(GridImp::getRealImplementation(other.intersection_));
 
33
      return GridImp::getRealImplementation(intersection_).equals(GridImp::getRealImplementation(other.intersection_));
33
34
    }
34
35
 
35
36
    //! prefix increment
36
37
    void increment() {
37
 
        GridImp::getRealImplementation(intersection_).neighborCount_++;
 
38
      GridImp::getRealImplementation(intersection_).neighborCount_++;
38
39
 
39
 
        GridImp::getRealImplementation(intersection_).geometryIsUpToDate_          = false;
40
 
        GridImp::getRealImplementation(intersection_).geometryInInsideIsUpToDate_  = false;
41
 
        GridImp::getRealImplementation(intersection_).geometryInOutsideIsUpToDate_ = false;
 
40
      GridImp::getRealImplementation(intersection_).geometry_.reset();
 
41
      GridImp::getRealImplementation(intersection_).geometryInInside_.reset();
 
42
      GridImp::getRealImplementation(intersection_).geometryInOutside_.reset();
42
43
    }
43
44
 
44
45
    //! \brief dereferencing
45
46
    const Intersection & dereference() const {
46
 
        return intersection_;
 
47
      return intersection_;
47
48
    }
48
 
    
49
 
private:
 
49
 
 
50
  private:
50
51
 
51
52
    mutable MakeableInterfaceObject<Intersection> intersection_;
52
 
    
53
 
};
54
 
 
55
 
 
56
 
    /** \brief Implementation of the UGGrid LeafIntersectionIterator
57
 
     */
58
 
template<class GridImp>
59
 
class UGGridLeafIntersectionIterator
60
 
{
 
53
 
 
54
  };
 
55
 
 
56
 
 
57
  /** \brief Implementation of the UGGrid LeafIntersectionIterator
 
58
   */
 
59
  template<class GridImp>
 
60
  class UGGridLeafIntersectionIterator
 
61
  {
61
62
 
62
63
    enum {dim=GridImp::dimension};
63
64
 
64
65
    friend class UGGridEntity<0,dim,GridImp>;
65
66
 
66
 
public:
 
67
  public:
67
68
 
68
 
    typedef Dune::Intersection<const GridImp, Dune::UGGridLeafIntersection> Intersection;
 
69
    typedef Dune::Intersection< GridImp, Dune::UGGridLeafIntersection< GridImp > > Intersection;
69
70
 
70
71
    UGGridLeafIntersectionIterator(typename UG_NS<dim>::Element* center, int nb, const GridImp* gridImp)
71
 
        : intersection_(UGGridLeafIntersection<GridImp>(center,nb,gridImp))
 
72
      : intersection_(UGGridLeafIntersection<GridImp>(center,nb,gridImp))
72
73
    {}
73
74
 
74
75
    //! equality
75
76
    bool equals(const UGGridLeafIntersectionIterator<GridImp>& other) const {
76
 
        return GridImp::getRealImplementation(intersection_).equals(GridImp::getRealImplementation(other.intersection_));
 
77
      return GridImp::getRealImplementation(intersection_).equals(GridImp::getRealImplementation(other.intersection_));
77
78
    }
78
79
 
79
80
    /** \brief Prefix increment.
80
81
 
81
 
    The UG data structure does not directly contain information about leaf neighbors/intersections.
82
 
    Therefore getting that information is fairly expensive.  In particular, it is too expensive to
83
 
    start looking for the next intersection whenever 'increment()' is called.  Therefore, all
84
 
    intersections of one face of the 'inside' element are precomputed, and incrementing then traverses
85
 
    this precomputed list.  If the list is exhausted the iterator advances to the next faces
86
 
    and precomputes all intersections there.
87
 
    */
 
82
       The UG data structure does not directly contain information about leaf neighbors/intersections.
 
83
       Therefore getting that information is fairly expensive.  In particular, it is too expensive to
 
84
       start looking for the next intersection whenever 'increment()' is called.  Therefore, all
 
85
       intersections of one face of the 'inside' element are precomputed, and incrementing then traverses
 
86
       this precomputed list.  If the list is exhausted the iterator advances to the next faces
 
87
       and precomputes all intersections there.
 
88
     */
88
89
    void increment() {
89
90
 
90
 
        UGGridLeafIntersection<GridImp>& intersectionImp = GridImp::getRealImplementation(intersection_);
91
 
 
92
 
        intersectionImp.subNeighborCount_++;
93
 
        
94
 
        // are there no more intersections for the current element face?
95
 
        if (intersectionImp.subNeighborCount_ >= intersectionImp.leafSubFaces_.size() ) {
96
 
            
97
 
            // move to the next face
98
 
            intersectionImp.neighborCount_++;
99
 
            intersectionImp.subNeighborCount_ = 0;
100
 
            
101
 
            // if the next face is not the end iterator construct all intersections for it
102
 
            if (intersectionImp.neighborCount_ < UG_NS<dim>::Sides_Of_Elem(intersectionImp.center_))
103
 
                intersectionImp.constructLeafSubfaces();
104
 
            
105
 
        }
106
 
 
107
 
        // make sure geometries are not taken from the cache the next time
108
 
        // the geometry{|InInside|InOutside} methods are called.
109
 
        intersectionImp.geometryIsUpToDate_          = false;
110
 
        intersectionImp.geometryInInsideIsUpToDate_  = false;
111
 
        intersectionImp.geometryInOutsideIsUpToDate_ = false;
 
91
      UGGridLeafIntersection<GridImp>& intersectionImp = GridImp::getRealImplementation(intersection_);
 
92
 
 
93
      intersectionImp.subNeighborCount_++;
 
94
 
 
95
      // are there no more intersections for the current element face?
 
96
      if (intersectionImp.subNeighborCount_ >= intersectionImp.leafSubFaces_.size() ) {
 
97
 
 
98
        // move to the next face
 
99
        intersectionImp.neighborCount_++;
 
100
        intersectionImp.subNeighborCount_ = 0;
 
101
 
 
102
        // if the next face is not the end iterator construct all intersections for it
 
103
        if (intersectionImp.neighborCount_ < UG_NS<dim>::Sides_Of_Elem(intersectionImp.center_))
 
104
          intersectionImp.constructLeafSubfaces();
 
105
 
 
106
      }
 
107
 
 
108
      // make sure geometries are not taken from the cache the next time
 
109
      // the geometry{|InInside|InOutside} methods are called.
 
110
      intersectionImp.geometry_.reset();
 
111
      intersectionImp.geometryInInside_.reset();
 
112
      intersectionImp.geometryInOutside_.reset();
112
113
    }
113
114
 
114
115
    //! \brief dereferencing
115
116
    const Intersection & dereference() const {
116
 
        return intersection_;
 
117
      return intersection_;
117
118
    }
118
 
    
119
 
private:
 
119
 
 
120
  private:
120
121
 
121
122
    mutable MakeableInterfaceObject<Intersection> intersection_;
122
123
 
123
 
};
 
124
  };
124
125
 
125
126
}  // namespace Dune
126
127