common/gridfactory.hh

Go to the documentation of this file.
00001 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002 // vi: set et ts=8 sw=4 sts=4:
00003 #ifndef DUNE_GRID_FACTORY_HH
00004 #define DUNE_GRID_FACTORY_HH
00005 
00010 #include <vector>
00011 
00012 #include <dune/common/function.hh>
00013 #include <dune/common/fvector.hh>
00014 #include <dune/common/geometrytype.hh>
00015 #include <dune/common/shared_ptr.hh>
00016 
00017 #include <dune/grid/common/boundarysegment.hh>
00018 #include <dune/grid/common/grid.hh>
00019 
00020 namespace Dune
00021 {
00022 
00071     template <class GridType>
00072     class GridFactoryInterface
00073     {
00074 
00075     protected:
00077         static const int dimension = GridType::dimension;
00078 
00080         enum {dimworld = GridType::dimensionworld};
00081 
00083         typedef typename GridType::ctype ctype;
00084 
00085     public:
00086         template< int codim >
00087         struct Codim
00088         {
00089             typedef typename GridType::template Codim< codim >::Entity Entity;
00090         };
00091 
00093         GridFactoryInterface()
00094         {}
00095 
00097         virtual ~GridFactoryInterface ()
00098         {}
00099 
00101         virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) = 0;
00102         
00110         virtual void insertElement(const GeometryType& type,
00111                                    const std::vector<unsigned int>& vertices) = 0;
00112 
00121         virtual void insertElement(const GeometryType& type,
00122                                    const std::vector<unsigned int>& vertices,
00123                                    const shared_ptr<VirtualFunction<FieldVector<ctype,dimension>,FieldVector<ctype,dimworld> > >& elementParametrization)
00124         {
00125             DUNE_THROW(GridError, "This grid does not support parametrized elements!");
00126         }
00127 
00141         virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices) = 0;
00142         
00150         virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices,
00151                                            const shared_ptr<BoundarySegment<dimension,dimworld> >& boundarySegment)
00152         {
00153             DUNE_THROW(GridError, "This grid does not support parametrized boundary segments!");
00154         }
00155         
00160         virtual GridType* createGrid() = 0;
00161 
00177         virtual unsigned int
00178         insertionIndex ( const typename Codim< 0 >::Entity &entity ) const
00179         {
00180           DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
00181         }
00182 
00198         virtual unsigned int
00199         insertionIndex ( const typename Codim< dimension >::Entity &entity ) const
00200         {
00201           DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
00202         }
00203 
00223         virtual unsigned int
00224         insertionIndex ( const typename GridType::LeafIntersection &intersection ) const
00225         {
00226           DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
00227         }
00228 
00229 
00243         virtual bool
00244         wasInserted ( const typename GridType::LeafIntersection &intersection ) const
00245         {
00246           DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." );
00247         }
00248 
00249     };
00250 
00251 
00261     template <class GridType>
00262     class GridFactory : public GridFactoryInterface<GridType> {
00263 
00265         enum {dimworld = GridType::dimensionworld};
00266 
00268         typedef typename GridType::ctype ctype;
00269 
00270     public:
00271         
00273         GridFactory() {
00274             DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00275         }
00276 
00278         virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) {
00279             DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00280         }
00281 
00289         virtual void insertElement(const GeometryType& type,
00290                                    const std::vector<unsigned int>& vertices) {
00291             DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00292         }
00293 
00307         virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices) {
00308             DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00309         }
00310         
00315         virtual GridType* createGrid() {
00316             DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00317         }
00318 
00319     };
00320 
00321 }
00322 
00323 #endif

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].