00001 #ifndef DUNE_ALU2DGRIDGEOMETRY_HH
00002 #define DUNE_ALU2DGRIDGEOMETRY_HH
00003
00004
00005
00006
00007 #include <dune/common/misc.hh>
00008 #include <dune/grid/common/grid.hh>
00009
00010
00011
00012 namespace Dune {
00013
00014 template<int cd, int dim, class GridImp>
00015 class ALU2dGridEntity;
00016 template<int cd, class GridImp >
00017 class ALU2dGridEntityPointer;
00018 template<int mydim, int cdim, class GridImp>
00019 class ALU2dGridGeometry;
00020 template<int dim, int dimworld>
00021 class ALU2dGrid;
00022
00023
00024
00025
00026
00027
00040
00041
00042 template <int mydim, int cdim, class GridImp>
00043 class ALU2dGridGeometry :
00044 public GeometryDefaultImplementation <mydim,cdim,GridImp,ALU2dGridGeometry>
00045 {
00046
00048 typedef typename GridImp::template Codim<0>::Geometry Geometry;
00050 typedef ALU2dGridGeometry<mydim,cdim,GridImp> GeometryImp;
00052 enum { dimbary=mydim+1};
00053
00054 typedef typename ALU2DSPACE Hmesh_basic::helement_t HElementType ;
00055
00056 public:
00059 ALU2dGridGeometry();
00060
00062 ALU2dGridGeometry(const int child, const int orientation );
00063
00066 const GeometryType & type () const;
00067
00069 int corners () const;
00070
00072 const FieldVector<alu2d_ctype, cdim>& operator[] (int i) const;
00073
00076 FieldVector<alu2d_ctype, cdim> global (const FieldVector<alu2d_ctype, mydim>& local) const;
00077
00080 FieldVector<alu2d_ctype, mydim> local (const FieldVector<alu2d_ctype, cdim>& global) const;
00081
00083 bool checkInside(const FieldVector<alu2d_ctype, mydim>& local) const;
00084
00086 alu2d_ctype integrationElement (const FieldVector<alu2d_ctype, mydim>& local) const;
00087
00088 alu2d_ctype volume () const;
00089
00091 const FieldMatrix<alu2d_ctype,mydim,mydim>& jacobianInverseTransposed (const FieldVector<alu2d_ctype, mydim>& local) const;
00092
00093
00095
00097 bool builtGeom(const ALU2DSPACE Vertex & item, int );
00098 bool builtGeom(const HElementType & item, int face);
00099
00102
00103
00104
00105 template <class GeometryType, class LocalGeomType >
00106 bool builtLocalGeom(const GeometryType & geo , const LocalGeomType & lg);
00107
00108
00109
00111 void initGeom();
00112 FieldVector<alu2d_ctype, cdim>& getCoordVec (int i);
00113
00115 void print (std::ostream& ss) const;
00116
00118
00119 inline bool buildGeomInFather(const Geometry &fatherGeom , const Geometry & myGeom);
00120
00121 private:
00122
00124 void buildJacobianInverseTransposed () const;
00125
00127 void calcElMatrix () const;
00128
00130 alu2d_ctype elDeterminant () const;
00131
00133 mutable FieldVector<alu2d_ctype, mydim+1> tmpVec_;
00134
00136 mutable FieldMatrix<alu2d_ctype, mydim+1, cdim> coord_;
00137
00139 mutable FieldVector<alu2d_ctype, cdim> globalCoord_;
00140
00142 mutable FieldVector<alu2d_ctype, mydim> localCoord_;
00143
00144
00145
00146
00147
00148
00150 int face_;
00151
00152
00153 enum { matdim = (mydim > 0) ? mydim : 1 };
00154 mutable FieldMatrix<alu2d_ctype,matdim,matdim> Jinv_;
00155 mutable FieldMatrix<alu2d_ctype,matdim,matdim> Mtmp_;
00156
00157 mutable FieldMatrix<alu2d_ctype,cdim,mydim> elMat_;
00158 mutable FieldMatrix<alu2d_ctype,matdim,matdim> elMatT_elMat_;
00159
00161 mutable bool builtElMat_;
00163 mutable bool builtinverse_;
00164
00165 mutable bool calcedDet_;
00166 mutable alu2d_ctype elDet_;
00167
00168
00169 mutable FieldVector<alu2d_ctype,cdim> tmpV_;
00170 mutable FieldVector<alu2d_ctype,cdim> tmpU_;
00171 mutable FieldVector<alu2d_ctype,cdim> tmpZ_;
00172
00173 mutable FieldVector<alu2d_ctype,mydim> AT_x_;
00174 GeometryType myGeomType_;
00175
00176 };
00177
00178 template <class GeometryImp, int nChild>
00179 class ALU2DLocalGeometryStorage {
00180
00181
00182 std::vector < GeometryImp * > geoms_;
00183
00184 int count_;
00185 public:
00186
00187 ALU2DLocalGeometryStorage () : geoms_ (nChild) , count_ (0) {
00188 for(size_t i=0 ;i<geoms_.size(); ++i) geoms_[i] = 0;
00189 }
00190
00191
00192 ~ALU2DLocalGeometryStorage () {
00193 for(size_t i=0 ;i<geoms_.size(); ++i)
00194 if(geoms_[i]) delete geoms_[i];
00195 }
00196
00197
00198 bool geomCreated(int child) const { return geoms_[child] != 0; }
00199
00200
00201 template <class GridImp, class Geometry>
00202 void create (const GridImp & grid, const Geometry & father, const Geometry & son, const int child)
00203 {
00204 assert( !geomCreated(child) );
00205 assert( child >=0 && child < nChild );
00206
00207 assert( count_ < nChild );
00208 ++count_;
00209
00210 typedef typename GeometryImp :: ImplementationType ImplType;
00211 GeometryImp * g = new GeometryImp(ImplType());
00212 geoms_[child] = g;
00213 GeometryImp & geo = *g;
00214 grid.getRealImplementation(geo).buildGeomInFather( father, son );
00215 }
00216
00217 const GeometryImp & operator [] (int child) const
00218 {
00219 assert( geomCreated(child) );
00220 return *(geoms_[child]);
00221 }
00222 };
00223
00224 }
00225
00226 #include "geometry_imp.cc"
00227
00228 #endif