faceutility.hh

00001 #ifndef DUNE_ALU3DGRIDFACEUTILITY_HH
00002 #define DUNE_ALU3DGRIDFACEUTILITY_HH
00003 
00004 #include <dune/common/misc.hh>
00005 #include <dune/grid/common/referenceelements.hh>
00006 
00007 #include "mappings.hh"
00008 #include "alu3dinclude.hh"
00009 #include "topology.hh"
00010 
00011 namespace Dune {
00012 
00013 
00014   // * Note: reconsider lazy evaluation of coordinates
00015 
00016   //- class ALU3dGridFaceInfo
00017   /* \brief Stores face and adjoining elements of the underlying ALU3dGrid
00018      The class has the same notion of inner and outer element as the 
00019      intersection iterator.
00020   */
00021   template <ALU3dGridElementType type> 
00022   class ALU3dGridFaceInfo {
00023   private:
00024     //- private typedefs
00025     typedef typename ALU3dImplTraits<type>::HasFaceType HasFaceType;
00026   public:
00027     enum ConformanceState {CONFORMING, REFINED_INNER, REFINED_OUTER};
00028     //- typedefs
00029     typedef typename ALU3dImplTraits<type>::GEOFaceType GEOFaceType;
00030     typedef typename ALU3dImplTraits<type>::GEOElementType GEOElementType;
00031     typedef typename ALU3dImplTraits<type>::IMPLElementType IMPLElementType;
00032     typedef typename ALU3dImplTraits<type>::GhostPairType GhostPairType; 
00033 #if ALU3DGRID_PARALLEL
00034     typedef typename ALU3dImplTraits<type>::PLLBndFaceType BndFaceType;
00035 #else
00036     typedef typename ALU3dImplTraits<type>::BNDFaceType BndFaceType;
00037 #endif
00038 
00039   public:
00041     ALU3dGridFaceInfo();
00042     void updateFaceInfo(const GEOFaceType& face, int innerTwist);
00043 
00044     //- constructors and destructors
00049     ALU3dGridFaceInfo(const GEOFaceType& face, int innerTwist);
00051     ALU3dGridFaceInfo(const ALU3dGridFaceInfo<type>& orig);
00053     ~ALU3dGridFaceInfo();
00054 
00055     //- queries
00057     bool outerBoundary() const;
00059     bool boundary() const;
00060   
00063     bool ghostBoundary () const;
00064     
00066     const GEOFaceType& face() const;
00068     const GEOElementType& innerEntity() const;
00071     const GEOElementType& outerEntity() const;
00074     const BndFaceType& boundaryFace() const;
00075 
00077     int innerTwist() const;
00079     int outerTwist() const;
00080   
00082     int innerALUFaceIndex() const;
00084     int outerALUFaceIndex() const;
00085   
00087     ConformanceState conformanceState() const;
00088    
00089   private:
00090     //- forbidden methods
00091     const ALU3dGridFaceInfo<type>& 
00092     operator=(const ALU3dGridFaceInfo<type>& orig);
00093 
00094   private:
00095     //- member data
00096     const GEOFaceType* face_;
00097     const HasFaceType* innerElement_;
00098     const HasFaceType* outerElement_;
00099 
00100     int innerFaceNumber_;
00101     int outerFaceNumber_;
00102 
00103     int innerTwist_;
00104     int outerTwist_;
00105 
00106     bool outerBoundary_; 
00107     bool ghostBoundary_; 
00108   };
00109 
00112   template <ALU3dGridElementType type> 
00113   class ALU3dGridGeometricFaceInfoBase {
00114   public:
00115     //- private typedefs
00116     typedef ElementTopologyMapping<type> ElementTopo;
00117     typedef FaceTopologyMapping<type> FaceTopo;
00118     typedef NonConformingFaceMapping<type> NonConformingMappingType;
00119     typedef typename SelectType<
00120       SameType<Int2Type<tetra>,Int2Type<type> >::value,
00121       ALU3DSPACE LinearSurfaceMapping,
00122       BilinearSurfaceMapping
00123       >::Type SurfaceMappingType;
00124     
00125     typedef typename SelectType<
00126       SameType<Int2Type<tetra>, Int2Type<type> >::value,
00127       ReferenceSimplex<alu3d_ctype, 3>,    
00128       ReferenceCube<alu3d_ctype, 3>
00129     >::Type ReferenceElementType;
00130 
00131     typedef typename SelectType<
00132       SameType<Int2Type<tetra>, Int2Type<type> >::value,
00133       ReferenceSimplex<alu3d_ctype, 2>,    
00134       ReferenceCube<alu3d_ctype, 2>
00135     >::Type ReferenceFaceType;
00136 
00137 
00138     enum SideIdentifier { INNER, OUTER };
00139     enum { dimworld = 3 }; // ALU is a pure 3d grid
00140     enum { numVerticesPerFace = 
00141            EntityCount<type>::numVerticesPerFace };
00142   public:
00143     //- public typedefs
00144     typedef FieldVector<alu3d_ctype, 3> NormalType;
00145     typedef FieldMatrix<alu3d_ctype, 
00146                         numVerticesPerFace,
00147                         dimworld> CoordinateType;
00148 
00149     typedef typename ALU3dGridFaceInfo<type>::GEOFaceType GEOFaceType;
00150   public:
00151     typedef ALU3dGridFaceInfo<type> ConnectorType;
00152 
00153     //- constructors and destructors
00154     ALU3dGridGeometricFaceInfoBase(const ConnectorType& ctor);
00155     ALU3dGridGeometricFaceInfoBase(const ALU3dGridGeometricFaceInfoBase<type> & orig);
00156    
00158     void resetFaceGeom();
00159 
00160     //- functions
00161     const CoordinateType& intersectionGlobal() const;
00162     const CoordinateType& intersectionSelfLocal() const;
00163     const CoordinateType& intersectionNeighborLocal() const;
00164 
00165     //NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
00166 
00167   private:
00168     //- forbidden methods
00169     const ALU3dGridGeometricFaceInfoBase<type>& operator=(const ALU3dGridGeometricFaceInfoBase<type>&);
00170   
00171   private:
00172     //- private methods
00173     void generateGlobalGeometry() const;
00174     void generateLocalGeometries() const;
00175   
00176     int globalVertexIndex(int duneFaceIndex, 
00177                           int faceTwist,
00178                           int duneFaceVertexIndex) const;
00179 
00180     void referenceElementCoordinatesRefined(SideIdentifier side, 
00181                                             CoordinateType& result) const;
00182     void referenceElementCoordinatesUnrefined(SideIdentifier side,
00183                                               CoordinateType& result) const;
00184   
00185     // old method , copies values for tetra twice 
00186     SurfaceMappingType* buildSurfaceMapping(const CoordinateType& coords) const;
00187 
00188     // get face and doesnt copy values twice
00189     SurfaceMappingType* buildSurfaceMapping(const GEOFaceType & face) const;
00190  
00191     void convert2CArray(const FieldVector<alu3d_ctype, 3>& in, 
00192                         alu3d_ctype (&out)[3]) const;
00193     void convert2FieldVector(const alu3d_ctype (&in)[3],
00194                              FieldVector<alu3d_ctype, 3>& out) const;
00195   protected:
00196     //- private data
00197     const ConnectorType& connector_; 
00198     
00199     mutable bool generatedGlobal_;
00200     mutable bool generatedLocal_;
00201 
00202     mutable CoordinateType coordsGlobal_;
00203     mutable CoordinateType coordsSelfLocal_;
00204     mutable CoordinateType coordsNeighborLocal_;
00205 
00206     static ReferenceElementType refElem_;
00207     static ReferenceFaceType refFace_;
00208 
00209   private:
00210     // convert FieldVectors to alu3dtypes 
00211     // only used for calculating the normals because the method of the
00212     // mapping classes want double (&)[3] and we have FieldVectors which store an
00213     // double [3] this is why we can cast here
00214     // plz say notin' Adrian 
00215     template <int dim>
00216     alu3d_ctype (& fieldVector2alu3d_ctype ( FieldVector <alu3d_ctype,dim> & val ) const )[dim]  
00217     {
00218       return ((alu3d_ctype (&)[dim]) (*( &(val[0])) ));
00219     }
00220 
00221     // convert const FieldVectors to const alu3dtypes 
00222     template <int dim>
00223     const alu3d_ctype (& fieldVector2alu3d_ctype ( const FieldVector <alu3d_ctype,dim> & val ) const )[dim] 
00224     {
00225       return ((const alu3d_ctype (&)[dim]) (*( &(val[0])) ) );
00226     }
00227   };
00228 
00231   class ALU3dGridGeometricFaceInfoTetra : public  ALU3dGridGeometricFaceInfoBase<tetra> 
00232   {
00233   public:
00234     //- public typedefs
00235     typedef FieldVector<alu3d_ctype, 3> NormalType;
00236     typedef FieldMatrix<alu3d_ctype, 
00237                         numVerticesPerFace,
00238                         dimworld> CoordinateType;
00239 
00240     typedef ALU3dGridFaceInfo<tetra>::GEOFaceType GEOFaceType;
00241   public:
00242     typedef ALU3dGridFaceInfo<tetra> ConnectorType;
00243 
00244     //- constructors and destructors
00245     ALU3dGridGeometricFaceInfoTetra(const ConnectorType& ctor);
00246     ALU3dGridGeometricFaceInfoTetra(const ALU3dGridGeometricFaceInfoTetra & orig);
00247    
00248     NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
00249     
00251     void resetFaceGeom();
00252     
00253   private:
00254     //- forbidden methods
00255     const ALU3dGridGeometricFaceInfoTetra & operator=(const ALU3dGridGeometricFaceInfoTetra &);
00256   
00257   private:
00258     //- private data 
00259     mutable NormalType outerNormal_;
00260     
00261     // false if surface mapping needs a update 
00262     mutable bool normalUp2Date_; 
00263   };
00264 
00267   class ALU3dGridGeometricFaceInfoHexa : public  ALU3dGridGeometricFaceInfoBase<hexa> 
00268   {
00269   public:
00270     //- public typedefs
00271     typedef FieldVector<alu3d_ctype, 3> NormalType;
00272     typedef FieldMatrix<alu3d_ctype, 
00273                         numVerticesPerFace,
00274                         dimworld> CoordinateType;
00275 
00276     typedef ALU3dGridFaceInfo<hexa>::GEOFaceType GEOFaceType;
00277     typedef BilinearSurfaceMapping SurfaceMappingType;
00278   public:
00279     typedef ALU3dGridFaceInfo<hexa> ConnectorType;
00280 
00281     //- constructors and destructors
00282     ALU3dGridGeometricFaceInfoHexa(const ConnectorType& ctor);
00283     ALU3dGridGeometricFaceInfoHexa(const ALU3dGridGeometricFaceInfoHexa & orig);
00284    
00285     NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
00286     
00288     void resetFaceGeom();
00289     
00290   private:
00291     //- forbidden methods
00292     const ALU3dGridGeometricFaceInfoHexa & operator=(const ALU3dGridGeometricFaceInfoHexa &);
00293   
00294   private:
00295     //- private data 
00296     mutable NormalType outerNormal_;
00297   
00298     // surface mapping for calculating the outer normal 
00299     mutable SurfaceMappingType mappingGlobal_;
00300     // false if surface mapping needs a update 
00301     mutable bool mappingGlobalUp2Date_; 
00302   };
00303 
00304 } // end namespace Dune
00305 
00306 #include "faceutility_imp.cc"
00307 
00308 #endif

Generated on 12 Dec 2007 with Doxygen (ver 1.5.1)