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 
00020   class TrilinearMapping {
00021     typedef FieldVector<double, 3> coord_t;
00022     typedef FieldMatrix<double, 3, 3> mat_t;
00023     static const double _epsilon ;
00024 
00025     // the internal mapping 
00026     double a [8][3] ;
00027     mat_t Df; 
00028     mat_t Dfi; 
00029     double DetDf ;
00030     void linear (const coord_t&) ;
00031     void inverse (const coord_t&) ;
00032   public :
00033     TrilinearMapping (const coord_t&, const coord_t&,
00034                       const coord_t&, const coord_t&,
00035                       const coord_t&, const coord_t&,
00036                       const coord_t&, const coord_t&);
00037     TrilinearMapping (const TrilinearMapping &) ;
00038     ~TrilinearMapping () {}
00039     double det (const coord_t&) ;
00040     mat_t jacobianInverse(const coord_t&);
00041     void map2world (const coord_t&, coord_t&) const ;
00042     void map2world (const double , const double , const double , 
00043                     coord_t&) const ;
00044     void world2map (const coord_t&, coord_t&) ;
00045   };
00046 
00048   // NOTE: this class is different to the BilinearSurfaceMapping in
00049   // ALUGrid, for example the reference elements differ 
00050   // here we have [0,1]^2 and in ALUGrid its [-1,1]^2
00051   // also the point numbering is different 
00052   class BilinearSurfaceMapping {
00053     // our coordinate types  
00054     typedef FieldVector<double, 3> coord3_t;
00055     typedef FieldVector<double, 2> coord2_t;
00056 
00057     // type of coordinate vectors from elements 
00058     typedef double double3_t[3];
00059 
00060     // type for helper matrices 
00061     typedef FieldMatrix<double,3,3> mat3_t;
00062     typedef FieldMatrix<double,2,2> mat2_t;
00063 
00064     mutable mat3_t Df,Dfi;
00065     mutable mat2_t inv_;
00066     mutable double DetDf;
00067     double _b [4][3] ;
00068     double _n [3][3] ;
00069 
00070     mutable coord3_t normal_;
00071     mutable coord3_t tmp_;
00072     static const double _epsilon ;
00073 
00074   public :
00076     BilinearSurfaceMapping (double);
00077 
00079     BilinearSurfaceMapping (const coord3_t&, const coord3_t&,
00080                             const coord3_t&, const coord3_t&) ;
00082     BilinearSurfaceMapping (const double3_t &, const double3_t &,
00083                             const double3_t &, const double3_t &) ;
00084     BilinearSurfaceMapping (const BilinearSurfaceMapping &) ;
00085     ~BilinearSurfaceMapping () {}
00086 
00087     void inverse (const coord3_t&) const;
00088     mat2_t jacobianInverse(const coord2_t&) const ;
00089 
00090     // calculates determinant of mapping 
00091     double det(const coord3_t&) const;
00092     
00093     // maps from local coordinates to global coordinates 
00094     void world2map(const coord3_t &, coord2_t & ) const;
00095 
00096     // calcuates normal 
00097     void normal(const coord2_t&, coord3_t&) const ;
00098     void normal(const double, const double, coord3_t&)const;
00099     
00100     // maps form global coordinates to local (within reference element)
00101     // coordinates 
00102     void map2world(const coord2_t&, coord3_t&) const ;
00103     void map2world(const double ,const double , coord3_t&) const ;
00104     
00105   private:  
00106     void map2worldnormal(const double, const double, const double , coord3_t&)const;
00107     void map2worldlinear(const double, const double, const double ) const;
00108 
00109   public:
00110     // builds _b and _n, called from the constructors 
00111     // public because also used in faceutility 
00112     template <class vector_t>
00113     void buildMapping (const vector_t & , const vector_t & ,
00114                        const vector_t & , const vector_t & );
00115   } ;  
00116 
00119   template <ALU3dGridElementType type>
00120   class NonConformingFaceMapping {};
00121 
00123   template <>
00124   class NonConformingFaceMapping<tetra> {
00125   private:
00126     //- private typedefs and enums
00127   public:
00128     //- public typedefs and enums
00129     typedef FieldVector<alu3d_ctype, 3> CoordinateType;
00130     typedef ALU3DSPACE Hface3RuleType RefinementRuleType;
00131     
00132   public:
00133     //- public interface methods
00134     NonConformingFaceMapping(RefinementRuleType rule,
00135                              int nChild);
00136     NonConformingFaceMapping(const NonConformingFaceMapping<tetra>& orig);
00137     ~NonConformingFaceMapping();
00138     
00139     void child2parent(const CoordinateType& childCoordinates, 
00140                       CoordinateType& parentCoordinates) const ;
00141 
00142   private:
00143     void child2parentNosplit(const CoordinateType& childCoordinates,
00144                              CoordinateType& parentCoordinates) const;
00145     void child2parentE01(const CoordinateType& childCoordinates,
00146                          CoordinateType& parentCoordinates) const;
00147     void child2parentE12(const CoordinateType& childCoordinates,
00148                          CoordinateType& parentCoordinates) const;
00149     void child2parentE20(const CoordinateType& childCoordinates,
00150                          CoordinateType& parentCoordinates) const;
00151     void child2parentIso4(const CoordinateType& childCoordinates,
00152                           CoordinateType& parentCoordinates) const;
00153   private:
00154     //- private data
00155     RefinementRuleType rule_;
00156     int nChild_;
00157   };
00158 
00160   template <>
00161   class NonConformingFaceMapping<hexa> {
00162   private:
00163     //- private typedefs and enums
00164   public:
00165     //- public typedefs and enums
00166     typedef FieldVector<alu3d_ctype, 2> CoordinateType;
00167     typedef ALU3DSPACE Hface4RuleType RefinementRuleType;
00168   public:
00169     NonConformingFaceMapping(RefinementRuleType rule, int nChild);
00170     NonConformingFaceMapping(const NonConformingFaceMapping<hexa>& orig);
00171     ~NonConformingFaceMapping();
00172 
00173     void child2parent(const CoordinateType& childCoordinates,
00174                       CoordinateType& parentCoordinates) const;
00175   private:
00176     void child2parentNosplit(const CoordinateType& childCoordinates,
00177                              CoordinateType& parentCoordinates) const;
00178     void child2parentIso4(const CoordinateType& childCoordinates,
00179                           CoordinateType& parentCoordinates) const;
00180 
00181   private:
00182     RefinementRuleType rule_;
00183     int nChild_; 
00184   };
00185 
00186 } // end namespace Dune
00187 
00188 #include "mappings_imp.cc"
00189 
00190 #endif

Generated on 12 Dec 2007 with Doxygen (ver 1.5.1)