datahandle.hh

00001 #ifndef DUNE_ALBERTAGRIDDATAHANDLE_HH
00002 #define DUNE_ALBERTAGRIDDATAHANDLE_HH
00003 
00004 #include <iostream>
00005 
00006 #include <dune/grid/common/grid.hh>
00007 
00008 #include <dune/grid/albertagrid/misc.hh>
00009 #include <dune/grid/albertagrid/albertaheader.hh>
00010 #include <dune/grid/albertagrid/elementinfo.hh>
00011 #include <dune/grid/albertagrid/refinement.hh>
00012 
00013 #if HAVE_ALBERTA
00014 
00015 namespace Dune
00016 {
00017 
00018   namespace Alberta
00019   {
00020 
00021     template< class Grid, class RestrictProlongOperator >
00022     class AdaptRestrictProlongHandler
00023     {
00024       static const int dimension = Grid::dimension;
00025 
00026       typedef typename Grid::template Codim< 0 >::Entity Entity;
00027       typedef Dune::MakeableInterfaceObject< Entity > EntityObject;
00028       typedef typename EntityObject::ImplementationType EntityImp;
00029 
00030       typedef Alberta::ElementInfo< dimension > ElementInfo;
00031       typedef Alberta::Patch< dimension > Patch;
00032       
00033       Grid &grid_;
00034       RestrictProlongOperator &rpOp_;
00035       EntityObject father_;
00036 
00037     public:
00038       AdaptRestrictProlongHandler ( Grid &grid, RestrictProlongOperator &rpOp )
00039       : grid_( grid ),
00040         rpOp_( rpOp ),
00041         father_( EntityImp( grid_ ) )
00042       {}
00043 
00044       void restrictLocal ( const Patch &patch, int i )
00045       {
00046         ElementInfo fatherInfo = patch.elementInfo( i, grid_.levelProvider() );
00047         Grid::getRealImplementation( father_ ).setElement( fatherInfo, 0 );
00048         rpOp_.preCoarsening( (const Entity &)father_ );
00049       }
00050 
00051       void prolongLocal ( const Patch &patch, int i )
00052       {
00053         ElementInfo fatherInfo = patch.elementInfo( i, grid_.levelProvider() );
00054         Grid::getRealImplementation( father_ ).setElement( fatherInfo, 0 );
00055         rpOp_.postRefinement( (const Entity &)father_ );
00056       }
00057     };
00058 
00059   }
00060 
00061 }
00062 
00063 #endif // #if HAVE_ALBERTA
00064 
00065 #endif

Generated on Thu Apr 2 10:40:38 2009 for dune-grid by  doxygen 1.5.6