alugrid/3d/geometry.hh

00001 #ifndef DUNE_ALU3DGRIDGEOMETRY_HH
00002 #define DUNE_ALU3DGRIDGEOMETRY_HH
00003 
00004 // System includes
00005 
00006 // Dune includes
00007 #include <dune/common/misc.hh>
00008 #include <dune/grid/common/grid.hh>
00009 
00010 // Local includes
00011 #include "alu3dinclude.hh"
00012 #include "topology.hh"
00013 
00014 namespace Dune {
00015   // Forward declarations
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   // --ALU3dGridGeometry
00030   // --Geometry
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 { dimbary=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     // calculates determinant and volume 
00120     void calculateDeterminant () const ;
00121     
00124     inline int faceIndex(int faceIdx, int vtxIdx) const;
00125 
00126     // generate transposed Jacobian Inverse and calculate integration_element 
00127     inline void buildJacobianInverseTransposed() const; 
00128 
00129     // calculates the element matrix for calculation of the jacobian inverse
00130     inline void calcElMatrix () const;
00131 
00132     // copies the values of point to the values of coord 
00133     inline void copyCoordVec (const alu3d_ctype (& point)[cdim] ,
00134             FieldVector<alu3d_ctype,cdim> & coord ) const;
00135 
00137     mutable FieldMatrix<alu3d_ctype, mydim+1, 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   public:
00177     typedef FieldMatrix<alu3d_ctype, 4, 3> FaceCoordinatesType;
00178 
00181     ALU3dGridGeometry();
00182 
00184     ~ALU3dGridGeometry();
00185 
00188     const GeometryType & type () const;
00189 
00191     int corners () const;
00192   
00194     const FieldVector<alu3d_ctype, cdim>& operator[] (int i) const;
00195 
00198     FieldVector<alu3d_ctype, cdim> global (const FieldVector<alu3d_ctype, mydim>& local) const;
00199   
00202     FieldVector<alu3d_ctype,  mydim> local (const FieldVector<alu3d_ctype, cdim>& global) const;
00203   
00206     bool checkInside(const FieldVector<alu3d_ctype, mydim>& local) const;
00207 
00209     alu3d_ctype integrationElement (const FieldVector<alu3d_ctype, mydim>& local) const;
00210 
00213     const FieldMatrix<alu3d_ctype,mydim,mydim>& jacobianInverseTransposed (const FieldVector<alu3d_ctype, mydim>& local) const;
00214 
00216     alu3d_ctype volume () const;
00217 
00218     //***********************************************************************
00220     //***********************************************************************
00222     bool buildGeom(const IMPLElementType & item);
00223     bool buildGeom(const ALU3DSPACE HFaceType & item, int twist, int faceNum);
00224     bool buildGeom(const FaceCoordinatesType& coords);
00225     bool buildGeom(const ALU3DSPACE HEdgeType & item, int twist, int);
00226     bool buildGeom(const ALU3DSPACE VertexType & item, int twist, int);
00227  
00229     bool buildGhost(const PLLBndFaceType & ghost);
00230  
00232     template <class GeometryType>
00233     bool buildGeomInFather(const GeometryType &fatherGeom , const GeometryType & myGeom);
00234         
00237     void print (std::ostream& ss) const;
00238 
00239   private:
00240     // create triMap from coordinates , deletes old mapping 
00241     void buildMapping();
00242     
00244     mutable FieldMatrix<alu3d_ctype, Power_m_p<2,mydim>::power, cdim> coord_;
00245     mutable FieldVector<alu3d_ctype, mydim> tmp1_;
00246     mutable FieldVector<alu3d_ctype, cdim> tmp2_;
00247 
00248     const GeometryType myGeomType_;
00249 
00250     TrilinearMapping* triMap_;
00251     BilinearSurfaceMapping* biMap_;
00252 
00253     mutable FieldMatrix<alu3d_ctype, mydim, mydim> jInv_;
00254 
00255     mutable FieldVector<alu3d_ctype, mydim> localBaryCenter_;
00256     mutable alu3d_ctype volume_;
00257   };
00258 
00259 } // end namespace Dune
00260 
00261 #include "geometry_imp.cc"
00262 
00263 #endif

Generated on 12 Dec 2007 with Doxygen (ver 1.5.1)