dune-grid  2.2.1
adaptcallback.hh
Go to the documentation of this file.
1 #ifndef DUNE_ADAPTCALLBACK_HH
2 #define DUNE_ADAPTCALLBACK_HH
3 
10 namespace Dune
11 {
12 
13  // Internal Forward Declarations
14  // -----------------------------
15 
16  template< class Grid, class Impl >
18 
19 
20 
21  // AdaptDataHandleInterface
22  // ------------------------
23 
24  template< class Grid, class Impl >
26  {
28 
29  friend class AdaptDataHandle< Grid, Impl >;
30 
31  public:
32  typedef typename Grid::template Codim< 0 >::Entity Entity;
33 
34  private:
36  {}
37 
38  AdaptDataHandleInterface ( const This & );
39  This &operator= ( const This & );
40 
41  public:
42  void preAdapt ( const unsigned int estimateAdditionalElements )
43  {
44  asImp().preAdapt( estimateAdditionalElements );
45  }
46 
47  void postAdapt ()
48  {
49  asImp().postAdapt();
50  }
51 
52  void preCoarsening ( const Entity &father ) const
53  {
54  asImp().preCoarsening( father );
55  }
56 
57  void postRefinement ( const Entity &father ) const
58  {
59  asImp().postRefinement( father );
60  }
61 
62  void restrictLocal( const Entity &father, const Entity& son, bool initialize ) const
63  {
64  asImp().restrictLocal( father, son, initialize );
65  }
66 
67  void prolongLocal( const Entity &father, const Entity& son, bool initialize ) const
68  {
69  asImp().prolongLocal( father, son, initialize );
70  }
71 
72  protected:
73  const Impl &asImp () const
74  {
75  return static_cast< const Impl & >( *this );
76  }
77 
78  Impl &asImp ()
79  {
80  return static_cast< Impl & >( *this );
81  }
82  };
83 
84 
85 
86  // AdaptDataHandle
87  // ---------------
88 
89  template< class Grid, class Impl >
90  class AdaptDataHandle
91  : public AdaptDataHandleInterface< Grid, Impl >
92  {
93  typedef AdaptDataHandle< Grid, Impl > This;
94  typedef AdaptDataHandleInterface< Grid, Impl > Base;
95 
96  public:
97  typedef typename Base::Entity Entity;
98 
99  protected:
101  {}
102 
103  private:
104  AdaptDataHandle ( const This & );
105  This &operator= ( const This & );
106 
107  void preAdapt ( const unsigned int estimateAdditionalElements );
108  void postAdapt ();
109  void preCoarsening ( const Entity &father ) const;
110  void postRefinement ( const Entity &father ) const;
111  };
112 
113 
114  // CombinedAdaptProlongRestrict
115  // ----------------------------
116 
118  template <class A, class B >
120  {
122  const A & _a;
123  const B & _b;
124  public:
126  CombinedAdaptProlongRestrict ( const A & a, const B & b ) : _a ( a ) , _b ( b )
127  {}
128 
130  template <class EntityType>
131  void restrictLocal ( EntityType &father, EntityType &son, bool initialize ) const
132  {
133  _a.restrictLocal(father,son,initialize);
134  _b.restrictLocal(father,son,initialize);
135  }
136 
138  template <class EntityType>
139  void prolongLocal ( EntityType &father, EntityType &son, bool initialize ) const
140  {
141  _a.prolongLocal(father,son,initialize);
142  _b.prolongLocal(father,son,initialize);
143  }
144  };
145 
146 } // end namespace Dune
147 
148 #endif