mappings.hh

00001 #ifndef DUNE_ALU3DGRIDMAPPINGS_HH
00002 #define DUNE_ALU3DGRIDMAPPINGS_HH
00003 
00004 // System includes
00005 #include <limits>
00006 
00007 // Dune includes
00008 #include <dune/common/fvector.hh>
00009 #include <dune/common/fmatrix.hh>
00010 
00011 // Local includes
00012 #include "alu3dinclude.hh"
00013 
00014 namespace Dune {
00015 
00016   static const alu3d_ctype ALUnumericEpsilon = 10.0 * std::numeric_limits< alu3d_ctype >::epsilon();
00017 
00018   template<int mydim, int coorddim, class GridImp>
00019   class ALU3dGridGeometry;
00020 
00021   template <int dim, int dimworld, ALU3dGridElementType elType> 
00022   class ALU3dGrid;
00023 
00026   class TrilinearMapping {
00027     typedef FieldVector<double, 3> coord_t;
00028     typedef FieldMatrix<double, 3, 3> mat_t;
00029     static const double _epsilon ;
00030 
00031     // the internal mapping 
00032     double a [8][3] ;
00033     mat_t Df; 
00034     mat_t Dfi; 
00035     mat_t invTransposed_; 
00036     double DetDf ;
00037 
00038     bool calcedDet_; 
00039     bool calcedInv_; 
00040     bool affine_;
00041 
00042     void linear (const double, const double, const double) ;
00043     void linear (const coord_t&) ;
00044     void inverse (const coord_t&) ;
00045   public :
00046     TrilinearMapping (const coord_t&, const coord_t&,
00047                       const coord_t&, const coord_t&,
00048                       const coord_t&, const coord_t&,
00049                       const coord_t&, const coord_t&);
00050     
00051     // only to call from geometry class 
00052     TrilinearMapping () {}
00053     
00054     TrilinearMapping (const TrilinearMapping &) ;
00055     
00056     ~TrilinearMapping () {}
00057     double det (const coord_t&) ;
00058     const mat_t& jacobianInverseTransposed(const coord_t&);
00059     void map2world (const coord_t&, coord_t&) const ;
00060     void map2world (const double , const double , const double , 
00061                     coord_t&) const ;
00062     void world2map (const coord_t&, coord_t&) ;
00063 
00064     template <class vector_t>
00065     void buildMapping(const vector_t&, const vector_t&,
00066                       const vector_t&, const vector_t&,  
00067                       const vector_t&, const vector_t&,  
00068                       const vector_t&, const vector_t&); 
00069 
00070     // returns true if mapping is affine 
00071     inline bool affine () const;
00072   };
00073 
00075   // NOTE: this class is different to the BilinearSurfaceMapping in
00076   // ALUGrid, for example the reference elements differ 
00077   // here we have [0,1]^2 and in ALUGrid its [-1,1]^2
00078   // also the point numbering is different 
00079   class BilinearSurfaceMapping {
00080     // our coordinate types  
00081     typedef FieldVector<double, 3> coord3_t;
00082     typedef FieldVector<double, 2> coord2_t;
00083 
00084     // type of coordinate vectors from elements 
00085     typedef double double3_t[3];
00086 
00087     // type for helper matrices 
00088     typedef FieldMatrix<double,3,3> mat3_t;
00089     typedef FieldMatrix<double,2,2> mat2_t;
00090 
00091     mutable mat3_t Df,Dfi;
00092     mutable mat2_t invTransposed_;
00093     mutable double DetDf;
00094     double _b [4][3] ;
00095     double _n [3][3] ;
00096 
00097     mutable coord3_t normal_;
00098     mutable coord3_t tmp_;
00099     static const double _epsilon ;
00100 
00101     bool _affine;
00102     mutable bool _calcedDet;
00103     mutable bool _calcedInv;
00104 
00105   public :
00107     BilinearSurfaceMapping (double);
00108 
00110     BilinearSurfaceMapping (const coord3_t&, const coord3_t&,
00111                             const coord3_t&, const coord3_t&) ;
00113     BilinearSurfaceMapping (const double3_t &, const double3_t &,
00114                             const double3_t &, const double3_t &) ;
00115     BilinearSurfaceMapping (const BilinearSurfaceMapping &) ;
00116     ~BilinearSurfaceMapping () {}
00117 
00118     void inverse (const coord3_t&) const;
00119     const mat2_t& jacobianInverseTransposed(const coord2_t&) const ;
00120 
00121     // calculates determinant of mapping 
00122     double det(const coord3_t&) const;
00123     
00124     // maps from local coordinates to global coordinates 
00125     void world2map(const coord3_t &, coord2_t & ) const;
00126 
00127     // calcuates normal 
00128     void normal(const coord2_t&, coord3_t&) const ;
00129     void normal(const double, const double, coord3_t&)const;
00130     
00131     // maps form global coordinates to local (within reference element)
00132     // coordinates 
00133     void map2world(const coord2_t&, coord3_t&) const ;
00134     void map2world(const double ,const double , coord3_t&) const ;
00135     
00136   private:  
00137     void map2worldnormal(const double, const double, const double , coord3_t&)const;
00138     void map2worldlinear(const double, const double, const double ) const;
00139 
00140   public:
00141     // builds _b and _n, called from the constructors 
00142     // public because also used in faceutility 
00143     template <class vector_t>
00144     void buildMapping (const vector_t & , const vector_t & ,
00145                        const vector_t & , const vector_t & );
00146   } ;  
00147 
00150   template <ALU3dGridElementType type>
00151   class NonConformingFaceMapping {};
00152 
00154   template <>
00155   class NonConformingFaceMapping<tetra> {
00156   private:
00157     //- private typedefs and enums
00158   public:
00159     //- public typedefs and enums
00160     typedef FieldVector<alu3d_ctype, 3> CoordinateType;
00161     typedef ALU3DSPACE Hface3RuleType RefinementRuleType;
00162     
00163   public:
00164     //- public interface methods
00165     NonConformingFaceMapping(RefinementRuleType rule,
00166                              int nChild);
00167     NonConformingFaceMapping(const NonConformingFaceMapping<tetra>& orig);
00168     ~NonConformingFaceMapping();
00169     
00170     void child2parent(const CoordinateType& childCoordinates, 
00171                       CoordinateType& parentCoordinates) const ;
00172 
00173   private:
00174     void child2parentNosplit(const CoordinateType& childCoordinates,
00175                              CoordinateType& parentCoordinates) const;
00176     void child2parentE01(const CoordinateType& childCoordinates,
00177                          CoordinateType& parentCoordinates) const;
00178     void child2parentE12(const CoordinateType& childCoordinates,
00179                          CoordinateType& parentCoordinates) const;
00180     void child2parentE20(const CoordinateType& childCoordinates,
00181                          CoordinateType& parentCoordinates) const;
00182     void child2parentIso4(const CoordinateType& childCoordinates,
00183                           CoordinateType& parentCoordinates) const;
00184   private:
00185     //- private data
00186     RefinementRuleType rule_;
00187     int nChild_;
00188   };
00189 
00191   template <>
00192   class NonConformingFaceMapping<hexa> {
00193   private:
00194     //- private typedefs and enums
00195   public:
00196     //- public typedefs and enums
00197     typedef FieldVector<alu3d_ctype, 2> CoordinateType;
00198     typedef ALU3DSPACE Hface4RuleType RefinementRuleType;
00199   public:
00200     NonConformingFaceMapping(RefinementRuleType rule, int nChild);
00201     NonConformingFaceMapping(const NonConformingFaceMapping<hexa>& orig);
00202     ~NonConformingFaceMapping();
00203 
00204     void child2parent(const CoordinateType& childCoordinates,
00205                       CoordinateType& parentCoordinates) const;
00206   private:
00207     void child2parentNosplit(const CoordinateType& childCoordinates,
00208                              CoordinateType& parentCoordinates) const;
00209     void child2parentIso4(const CoordinateType& childCoordinates,
00210                           CoordinateType& parentCoordinates) const;
00211 
00212   private:
00213     RefinementRuleType rule_;
00214     int nChild_; 
00215   };
00216 
00217 } // end namespace Dune
00218 
00219 #include "mappings_imp.cc"
00220 
00221 #endif

Generated on 9 Apr 2008 with Doxygen (ver 1.5.2) [logfile].