dune-grid  2.2.0
alugrid/2d/datahandle.hh
Go to the documentation of this file.
00001 #ifndef DUNE_ALU2DGRIDDATAHANDLE_HH
00002 #define DUNE_ALU2DGRIDDATAHANDLE_HH
00003 
00004 //- system includes 
00005 #include <iostream>
00006 
00007 #include <dune/grid/common/adaptcallback.hh>
00008 
00009 //- local includes 
00010 #include "alu2dinclude.hh"
00011 
00012 using std::endl;
00013 using std::cout;
00014 using std::flush;
00015 
00016 namespace ALU2DSPACENAME 
00017 {
00018 
00020 //
00021 //  --AdaptRestrictProlong 
00022 //
00024 template< class GridType, class AdaptDataHandle >
00025 class AdaptRestrictProlong2dImpl
00026 : public AdaptRestrictProlong2d ALU2DDIMWORLD( GridType::dimensionworld, GridType::elementType )
00027 {
00028   GridType & grid_;
00029   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<0>::Entity> EntityType;
00030   typedef typename EntityType :: ImplementationType RealEntityType;
00031   typedef typename Dune::ALU2dImplTraits< GridType::dimensionworld, GridType::elementType >::HElementType HElementType ;
00032   
00033   EntityType & reFather_;
00034   EntityType & reSon_;
00035   RealEntityType & realFather_;
00036   RealEntityType & realSon_;
00037 
00038   AdaptDataHandle &rp_;
00039 
00040   int maxlevel_;
00041 
00042 
00043 public:
00045   AdaptRestrictProlong2dImpl ( GridType &grid,
00046                                EntityType &f, RealEntityType &rf,
00047                                EntityType &s, RealEntityType &rs,
00048                                AdaptDataHandle &rp )
00049    : grid_(grid)
00050     , reFather_(f)
00051     , reSon_(s)
00052     , realFather_(rf) 
00053     , realSon_(rs) 
00054     , rp_(rp) 
00055     , maxlevel_(-1) 
00056   {
00057   }
00058 
00059   virtual ~AdaptRestrictProlong2dImpl () 
00060   {}
00061 
00063   int preCoarsening ( HElementType &father )
00064   {
00065     maxlevel_ = std::max( maxlevel_, father.level() );
00066     //father.resetRefinedTag();
00067     realFather_.setElement( father );
00068     rp_.preCoarsening( reFather_ );
00069 
00070     return 0;
00071   }
00072 
00074   int postRefinement ( HElementType &father )
00075   {
00076     maxlevel_ = std::max( maxlevel_, father.level()+1 );
00077     //father.resetRefinedTag();
00078     realFather_.setElement( father );
00079     rp_.postRefinement( reFather_ );
00080 
00081     return 0;
00082   }
00083 
00084   int maxLevel () const { return maxlevel_; }
00085 };
00086 
00087 } // namespace ALU2DSPACENAME
00088 
00089 #endif // #ifndef DUNE_ALU2DGRIDDATAHANDLE_HH