00001 #ifndef DUNE_ALU3DGRIDGEOMETRY_HH
00002 #define DUNE_ALU3DGRIDGEOMETRY_HH
00003
00004
00005
00006
00007 #include <dune/common/misc.hh>
00008 #include <dune/grid/common/grid.hh>
00009
00010
00011 #include "alu3dinclude.hh"
00012 #include "topology.hh"
00013
00014 namespace Dune {
00015
00016 template<int cd, int dim, class GridImp>
00017 class ALU3dGridEntity;
00018 template<int cd, class GridImp >
00019 class ALU3dGridEntityPointer;
00020 template<int mydim, int coorddim, class GridImp>
00021 class ALU3dGridGeometry;
00022 template<int dim, int dimworld, ALU3dGridElementType elType>
00023 class ALU3dGrid;
00024 class BilinearSurfaceMapping;
00025 class TrilinearMapping;
00026
00027
00028
00029
00030
00042
00043
00044 template <int mydim, int cdim, class GridImp>
00045 class ALU3dGridGeometry :
00046 public GeometryDefaultImplementation <mydim,cdim,GridImp,ALU3dGridGeometry> {};
00047
00049 template <int mydim, int cdim>
00050 class ALU3dGridGeometry<mydim, cdim, const ALU3dGrid<3, 3, tetra> > :
00051 public GeometryDefaultImplementation<mydim, cdim, const ALU3dGrid<3, 3, tetra>,
00052 ALU3dGridGeometry> {
00053 typedef const ALU3dGrid<3, 3, tetra> GridImp;
00054
00055 typedef typename ALU3dImplTraits<tetra>::IMPLElementType IMPLElementType;
00056 typedef typename ALU3dImplTraits<tetra>::PLLBndFaceType PLLBndFaceType;
00057 typedef typename ALU3dImplTraits<tetra>::GEOFaceType GEOFaceType;
00058 typedef typename ALU3dImplTraits<tetra>::GEOEdgeType GEOEdgeType;
00059 typedef typename ALU3dImplTraits<tetra>::GEOVertexType GEOVertexType;
00060
00061 typedef ElementTopologyMapping<tetra> ElementTopo;
00062 typedef FaceTopologyMapping<tetra> FaceTopo;
00064 enum { corners_ = mydim+1 };
00065 public:
00066 typedef FieldMatrix<alu3d_ctype, 3, 3> FaceCoordinatesType;
00069 inline ALU3dGridGeometry();
00070
00073 inline const GeometryType & type () const;
00074
00076 inline int corners () const;
00077
00079 inline const FieldVector<alu3d_ctype, cdim>& operator[] (int i) const;
00080
00083 inline FieldVector<alu3d_ctype, cdim> global (const FieldVector<alu3d_ctype, mydim>& local) const;
00084
00087 inline FieldVector<alu3d_ctype, mydim> local (const FieldVector<alu3d_ctype, cdim>& global) const;
00088
00090 inline bool checkInside(const FieldVector<alu3d_ctype, mydim>& local) const;
00091
00093 inline alu3d_ctype integrationElement (const FieldVector<alu3d_ctype, mydim>& local) const;
00094
00096 inline const FieldMatrix<alu3d_ctype,mydim,mydim>& jacobianInverseTransposed (const FieldVector<alu3d_ctype, mydim>& local) const;
00097
00099 inline alu3d_ctype volume () const;
00100
00102
00104 inline bool buildGeom(const IMPLElementType & item);
00105 inline bool buildGeom(const ALU3DSPACE HFaceType & item, int twist, int face );
00106 inline bool buildGeom(const FaceCoordinatesType& coords);
00107 inline bool buildGeom(const ALU3DSPACE HEdgeType & item, int twist, int );
00108 inline bool buildGeom(const ALU3DSPACE VertexType & item, int twist, int);
00109
00111 template <class GeometryImpType>
00112 inline bool buildGeomInFather(const GeometryImpType &fatherGeom , const GeometryImpType & myGeom);
00113
00116 inline void print (std::ostream& ss) const;
00117
00118 private:
00119
00120 void calculateDeterminant () const ;
00121
00124 inline int faceIndex(int faceIdx, int vtxIdx) const;
00125
00126
00127 inline void buildJacobianInverseTransposed() const;
00128
00129
00130 inline void calcElMatrix () const;
00131
00132
00133 inline void copyCoordVec (const alu3d_ctype (& point)[cdim] ,
00134 FieldVector<alu3d_ctype,cdim> & coord ) const;
00135
00137 mutable FieldMatrix<alu3d_ctype, corners_, cdim> coord_;
00138
00139 mutable FieldMatrix<alu3d_ctype,mydim,mydim> Jinv_;
00140 mutable alu3d_ctype detDF_;
00141 mutable alu3d_ctype volume_;
00142 mutable FieldMatrix<alu3d_ctype, cdim , mydim> A_;
00143 mutable FieldMatrix<alu3d_ctype, mydim, mydim> AT_A_;
00144
00145 mutable FieldVector<alu3d_ctype, mydim> AT_x_;
00146 mutable FieldVector<alu3d_ctype, mydim> localCoord_;
00147 mutable FieldVector<alu3d_ctype, cdim> globalCoord_;
00148
00149 mutable FieldVector<alu3d_ctype,cdim> tmpV_;
00150 mutable FieldVector<alu3d_ctype,cdim> tmpU_;
00151
00152 const GeometryType myGeomType_;
00153
00155 mutable bool builtinverse_;
00156 mutable bool builtA_;
00157 mutable bool builtDetDF_;
00158 };
00159
00161 template <int mydim, int cdim>
00162 class ALU3dGridGeometry<mydim, cdim, const ALU3dGrid<3, 3, hexa> > :
00163 public GeometryDefaultImplementation<mydim, cdim, const ALU3dGrid<3, 3, hexa>,
00164 ALU3dGridGeometry> {
00165 typedef const ALU3dGrid<3, 3, hexa> GridImp;
00166 friend class ALU3dGridIntersectionIterator<GridImp>;
00167
00168 typedef typename ALU3dImplTraits<hexa>::IMPLElementType IMPLElementType;
00169 typedef typename ALU3dImplTraits<hexa>::PLLBndFaceType PLLBndFaceType;
00170 typedef typename ALU3dImplTraits<hexa>::GEOFaceType GEOFaceType;
00171 typedef typename ALU3dImplTraits<hexa>::GEOEdgeType GEOEdgeType;
00172 typedef typename ALU3dImplTraits<hexa>::GEOVertexType GEOVertexType;
00173
00174 typedef ElementTopologyMapping<hexa> ElementTopo;
00175 typedef FaceTopologyMapping<hexa> FaceTopo;
00176
00177 template <int dummy, int dim>
00178 struct MappingChooser
00179 {
00180 typedef bool TrilinearMappingType;
00181 typedef bool BilinearSurfaceMappingType;
00182 };
00183
00184 template <int dummy>
00185 struct MappingChooser<dummy,2>
00186 {
00187 typedef bool TrilinearMappingType;
00188 typedef BilinearSurfaceMapping BilinearSurfaceMappingType;
00189 };
00190
00191 template <int dummy>
00192 struct MappingChooser<dummy,3>
00193 {
00194 typedef TrilinearMapping TrilinearMappingType;
00195 typedef bool BilinearSurfaceMappingType;
00196 };
00197
00198 typedef typename MappingChooser<0,mydim> :: TrilinearMappingType TrilinearMappingType;
00199 typedef typename MappingChooser<0,mydim> :: BilinearSurfaceMappingType BilinearSurfaceMappingType;
00200
00201 enum { corners_ = Power_m_p<2,mydim>::power };
00202 public:
00203 typedef FieldMatrix<alu3d_ctype, 4, 3> FaceCoordinatesType;
00204
00207 ALU3dGridGeometry();
00208
00210 ~ALU3dGridGeometry();
00211
00214 const GeometryType & type () const;
00215
00217 int corners () const;
00218
00220 const FieldVector<alu3d_ctype, cdim>& operator[] (int i) const;
00221
00224 FieldVector<alu3d_ctype, cdim> global (const FieldVector<alu3d_ctype, mydim>& local) const;
00225
00228 FieldVector<alu3d_ctype, mydim> local (const FieldVector<alu3d_ctype, cdim>& global) const;
00229
00232 bool checkInside(const FieldVector<alu3d_ctype, mydim>& local) const;
00233
00235 alu3d_ctype integrationElement (const FieldVector<alu3d_ctype, mydim>& local) const;
00236
00239 const FieldMatrix<alu3d_ctype,mydim,mydim>& jacobianInverseTransposed (const FieldVector<alu3d_ctype, mydim>& local) const;
00240
00242 alu3d_ctype volume () const;
00243
00244
00246
00248 bool buildGeom(const IMPLElementType & item);
00249 bool buildGeom(const ALU3DSPACE HFaceType & item, int twist, int faceNum);
00250 bool buildGeom(const FaceCoordinatesType& coords);
00251 bool buildGeom(const ALU3DSPACE HEdgeType & item, int twist, int);
00252 bool buildGeom(const ALU3DSPACE VertexType & item, int twist, int);
00253
00255 bool buildGhost(const PLLBndFaceType & ghost);
00256
00258 template <class GeometryType>
00259 bool buildGeomInFather(const GeometryType &fatherGeom , const GeometryType & myGeom);
00260
00263 void print (std::ostream& ss) const;
00264
00265 private:
00266
00267 void buildMapping() const;
00268
00269
00270 void buildBilinearMapping() const;
00271
00273 mutable FieldMatrix<alu3d_ctype, corners_ , cdim> coord_;
00274
00276 typedef double CoordPtrType[cdim];
00277 mutable FieldVector<const CoordPtrType*, corners_ > coordPtr_;
00278
00279 mutable FieldVector<alu3d_ctype, mydim> tmp1_;
00280 mutable FieldVector<alu3d_ctype, cdim> tmp2_;
00281
00282 const GeometryType myGeomType_;
00283
00284 mutable TrilinearMappingType triMap_;
00285 mutable BilinearSurfaceMappingType biMap_;
00286
00287 mutable bool buildTriMap_;
00288 mutable bool buildBiMap_;
00289
00290 mutable FieldVector<alu3d_ctype, mydim> localBaryCenter_;
00291 mutable alu3d_ctype volume_;
00292 };
00293
00294 }
00295
00296 #include "geometry_imp.cc"
00297
00298 #endif