dune-grid
2.2.0
|
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/shared_ptr.hh> 00015 00016 #include <dune/geometry/type.hh> 00017 00018 #include <dune/grid/common/boundarysegment.hh> 00019 #include <dune/grid/common/grid.hh> 00020 00021 namespace Dune 00022 { 00023 00072 template <class GridType> 00073 class GridFactoryInterface 00074 { 00075 00076 protected: 00078 static const int dimension = GridType::dimension; 00079 00081 enum {dimworld = GridType::dimensionworld}; 00082 00084 typedef typename GridType::ctype ctype; 00085 00086 public: 00087 template< int codim > 00088 struct Codim 00089 { 00090 typedef typename GridType::template Codim< codim >::Entity Entity; 00091 }; 00092 00094 GridFactoryInterface() 00095 {} 00096 00098 virtual ~GridFactoryInterface () 00099 {} 00100 00102 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) = 0; 00103 00111 virtual void insertElement(const GeometryType& type, 00112 const std::vector<unsigned int>& vertices) = 0; 00113 00122 virtual void insertElement(const GeometryType& type, 00123 const std::vector<unsigned int>& vertices, 00124 const shared_ptr<VirtualFunction<FieldVector<ctype,dimension>,FieldVector<ctype,dimworld> > >& elementParametrization) 00125 { 00126 DUNE_THROW(GridError, "This grid does not support parametrized elements!"); 00127 } 00128 00142 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices) = 0; 00143 00151 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices, 00152 const shared_ptr<BoundarySegment<dimension,dimworld> >& boundarySegment) 00153 { 00154 DUNE_THROW(GridError, "This grid does not support parametrized boundary segments!"); 00155 } 00156 00161 virtual GridType* createGrid() = 0; 00162 00178 virtual unsigned int 00179 insertionIndex ( const typename Codim< 0 >::Entity &entity ) const 00180 { 00181 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." ); 00182 } 00183 00199 virtual unsigned int 00200 insertionIndex ( const typename Codim< dimension >::Entity &entity ) const 00201 { 00202 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." ); 00203 } 00204 00224 virtual unsigned int 00225 insertionIndex ( const typename GridType::LeafIntersection &intersection ) const 00226 { 00227 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." ); 00228 } 00229 00230 00244 virtual bool 00245 wasInserted ( const typename GridType::LeafIntersection &intersection ) const 00246 { 00247 DUNE_THROW( NotImplemented, "insertion indices have not yet been implemented." ); 00248 } 00249 00250 }; 00251 00252 00262 template <class GridType> 00263 class GridFactory : public GridFactoryInterface<GridType> { 00264 00266 enum {dimworld = GridType::dimensionworld}; 00267 00269 typedef typename GridType::ctype ctype; 00270 00271 public: 00272 00274 GridFactory() { 00275 DUNE_THROW(GridError, "There is no grid factory for this grid type!"); 00276 } 00277 00279 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) { 00280 DUNE_THROW(GridError, "There is no grid factory for this grid type!"); 00281 } 00282 00290 virtual void insertElement(const GeometryType& type, 00291 const std::vector<unsigned int>& vertices) { 00292 DUNE_THROW(GridError, "There is no grid factory for this grid type!"); 00293 } 00294 00308 virtual void insertBoundarySegment(const std::vector<unsigned int>& vertices) { 00309 DUNE_THROW(GridError, "There is no grid factory for this grid type!"); 00310 } 00311 00316 virtual GridType* createGrid() { 00317 DUNE_THROW(GridError, "There is no grid factory for this grid type!"); 00318 } 00319 00320 }; 00321 00322 } 00323 00324 #endif