common/gridfactory.hh
Go to the documentation of this file.00001 #ifndef DUNE_GRID_FACTORY_HH
00002 #define DUNE_GRID_FACTORY_HH
00003
00008 #include <vector>
00009
00010 #include <dune/common/fvector.hh>
00011 #include <dune/common/geometrytype.hh>
00012
00013 #include <dune/grid/common/grid.hh>
00014 #include <dune/grid/common/boundarysegment.hh>
00015
00016 namespace Dune {
00017
00018
00023 template <class GridType>
00024 class GridFactoryInterface {
00025
00027 enum {dimworld = GridType::dimensionworld};
00028
00029 protected:
00030
00032 typedef typename GridType::ctype ctype;
00033
00034 public:
00035
00037 GridFactoryInterface()
00038 {}
00039
00050 GridFactoryInterface(GridType* grid)
00051 {}
00052
00053 virtual ~GridFactoryInterface ()
00054 {}
00055
00057 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) = 0;
00058
00063 virtual void insertElement(const GeometryType& type,
00064 const std::vector<unsigned int>& vertices) = 0;
00065
00071 virtual void insertBoundarySegment(const std::vector<unsigned int> vertices,
00072 const BoundarySegment<dimworld>* boundarySegment) {
00073 DUNE_THROW(GridError, "This grid does not support parametrized boundary segments!");
00074 }
00075
00080 virtual GridType* createGrid() = 0;
00081
00082 };
00083
00084
00090 template <class GridType>
00091 class GridFactory : public GridFactoryInterface<GridType> {
00092
00094 enum {dimworld = GridType::dimensionworld};
00095
00097 typedef typename GridType::ctype ctype;
00098
00099 public:
00100
00102 GridFactory();
00103
00114 GridFactory(GridType* grid)
00115 {
00116 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00117 }
00118
00119
00121 virtual void insertVertex(const FieldVector<ctype,dimworld>& pos) {
00122 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00123 }
00124
00129 virtual void insertElement(GeometryType type,
00130 const std::vector<unsigned int>& vertices) {
00131 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00132 }
00133
00138 virtual GridType* createGrid() {
00139 DUNE_THROW(GridError, "There is no grid factory for this grid type!");
00140 }
00141
00142 };
00143
00144 }
00145
00146 #endif