dune-grid  2.2.0
adaptcallback.hh
Go to the documentation of this file.
00001 #ifndef DUNE_ADAPTCALLBACK_HH
00002 #define DUNE_ADAPTCALLBACK_HH
00003 
00010 namespace Dune
00011 {
00012 
00013   // Internal Forward Declarations
00014   // -----------------------------
00015 
00016   template< class Grid, class Impl >
00017   class AdaptDataHandle;
00018 
00019 
00020 
00021   // AdaptDataHandleInterface
00022   // ------------------------
00023 
00024   template< class Grid, class Impl >
00025   class AdaptDataHandleInterface
00026   {
00027     typedef AdaptDataHandleInterface< Grid, Impl > This;
00028 
00029     friend class AdaptDataHandle< Grid, Impl >;
00030 
00031   public:
00032     typedef typename Grid::template Codim< 0 >::Entity Entity;
00033 
00034   private:
00035     AdaptDataHandleInterface ()
00036     {}
00037 
00038     AdaptDataHandleInterface ( const This & );
00039     This &operator= ( const This & );
00040 
00041   public:
00042     void preAdapt ( const unsigned int estimateAdditionalElements )
00043     {
00044       asImp().preAdapt( estimateAdditionalElements );
00045     }
00046 
00047     void postAdapt ()
00048     {
00049       asImp().postAdapt();
00050     }
00051 
00052     void preCoarsening ( const Entity &father ) const
00053     {
00054       asImp().preCoarsening( father );
00055     }
00056 
00057     void postRefinement ( const Entity &father ) const
00058     {
00059       asImp().postRefinement( father );
00060     }
00061 
00062     void restrictLocal( const Entity &father, const Entity& son, bool initialize ) const 
00063     {
00064       asImp().restrictLocal( father, son, initialize );
00065     }
00066 
00067     void prolongLocal( const Entity &father, const Entity& son, bool initialize ) const 
00068     {
00069       asImp().prolongLocal( father, son, initialize );
00070     }
00071 
00072   protected:
00073     const Impl &asImp () const
00074     {
00075       return static_cast< const Impl & >( *this );
00076     }
00077 
00078     Impl &asImp ()
00079     {
00080       return static_cast< Impl & >( *this );
00081     }
00082   };
00083 
00084 
00085 
00086   // AdaptDataHandle
00087   // ---------------
00088 
00089   template< class Grid, class Impl >
00090   class AdaptDataHandle
00091   : public AdaptDataHandleInterface< Grid, Impl >
00092   {
00093     typedef AdaptDataHandle< Grid, Impl > This;
00094     typedef AdaptDataHandleInterface< Grid, Impl > Base;
00095 
00096   public:
00097     typedef typename Base::Entity Entity;
00098 
00099   protected:
00100     AdaptDataHandle ()
00101     {}
00102 
00103   private:
00104     AdaptDataHandle ( const This & );
00105     This &operator= ( const This & );
00106 
00107     void preAdapt ( const unsigned int estimateAdditionalElements );
00108     void postAdapt ();
00109     void preCoarsening ( const Entity &father ) const;
00110     void postRefinement ( const Entity &father ) const;
00111   };
00112 
00113 
00114   // CombinedAdaptProlongRestrict
00115   // ----------------------------
00116 
00118   template <class A, class B >
00119   class CombinedAdaptProlongRestrict
00120   {
00122     const A & _a;
00123     const B & _b;
00124   public: 
00126     CombinedAdaptProlongRestrict ( const A & a, const B & b ) : _a ( a ) , _b ( b )
00127     {}
00128     
00130     template <class EntityType>
00131     void restrictLocal ( EntityType &father, EntityType &son, bool initialize ) const
00132     {
00133       _a.restrictLocal(father,son,initialize);
00134       _b.restrictLocal(father,son,initialize);
00135     }
00136 
00138     template <class EntityType>
00139     void prolongLocal ( EntityType &father, EntityType &son, bool initialize ) const
00140     {
00141       _a.prolongLocal(father,son,initialize);
00142       _b.prolongLocal(father,son,initialize);
00143     }
00144   };
00145 
00146 } // end namespace Dune 
00147 
00148 #endif