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, UNDEFINED };
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 innerLevel, 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:
00091     ConformanceState getConformanceState(const int innerLevel) const;
00092    
00093     //- forbidden methods
00094     const ALU3dGridFaceInfo<type>& 
00095     operator=(const ALU3dGridFaceInfo<type>& orig);
00096 
00097   private:
00098     //- member data
00099     const GEOFaceType* face_;
00100     const HasFaceType* innerElement_;
00101     const HasFaceType* outerElement_;
00102 
00103     int innerFaceNumber_;
00104     int outerFaceNumber_;
00105 
00106     int innerTwist_;
00107     int outerTwist_;
00108 
00109     bool outerBoundary_; 
00110     bool ghostBoundary_; 
00111 
00112     ConformanceState conformanceState_;
00113   };
00114 
00117   template <ALU3dGridElementType type> 
00118   class ALU3dGridGeometricFaceInfoBase {
00119   public:
00120     //- private typedefs
00121     typedef ElementTopologyMapping<type> ElementTopo;
00122     typedef FaceTopologyMapping<type> FaceTopo;
00123     typedef NonConformingFaceMapping<type> NonConformingMappingType;
00124     typedef typename SelectType<
00125       is_same<Int2Type<tetra>,Int2Type<type> >::value,
00126       ALU3DSPACE LinearSurfaceMapping,
00127       BilinearSurfaceMapping
00128       >::Type SurfaceMappingType;
00129     
00130     typedef typename SelectType<
00131       is_same<Int2Type<tetra>, Int2Type<type> >::value,
00132       ReferenceSimplex<alu3d_ctype, 3>,    
00133       ReferenceCube<alu3d_ctype, 3>
00134     >::Type ReferenceElementType;
00135 
00136     typedef typename SelectType<
00137       is_same<Int2Type<tetra>, Int2Type<type> >::value,
00138       ReferenceSimplex<alu3d_ctype, 2>,    
00139       ReferenceCube<alu3d_ctype, 2>
00140     >::Type ReferenceFaceType;
00141 
00142 
00143     enum SideIdentifier { INNER, OUTER };
00144     enum { dimworld = 3 }; // ALU is a pure 3d grid
00145     enum { numVerticesPerFace = 
00146            EntityCount<type>::numVerticesPerFace };
00147   public:
00148     //- public typedefs
00149     typedef FieldVector<alu3d_ctype, 3> NormalType;
00150     typedef FieldMatrix<alu3d_ctype, 
00151                         numVerticesPerFace,
00152                         dimworld> CoordinateType;
00153 
00154     typedef typename ALU3dGridFaceInfo<type>::GEOFaceType GEOFaceType;
00155   public:
00156     typedef ALU3dGridFaceInfo<type> ConnectorType;
00157 
00158     //- constructors and destructors
00159     ALU3dGridGeometricFaceInfoBase(const ConnectorType& ctor);
00160     ALU3dGridGeometricFaceInfoBase(const ALU3dGridGeometricFaceInfoBase<type> & orig);
00161    
00163     void resetFaceGeom();
00164 
00165     //- functions
00166     const CoordinateType& intersectionGlobal() const;
00167     const CoordinateType& intersectionSelfLocal() const;
00168     const CoordinateType& intersectionNeighborLocal() const;
00169 
00170     //NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
00171 
00172   private:
00173     //- forbidden methods
00174     const ALU3dGridGeometricFaceInfoBase<type>& operator=(const ALU3dGridGeometricFaceInfoBase<type>&);
00175   
00176   private:
00177     //- private methods
00178     void generateGlobalGeometry() const;
00179     void generateLocalGeometries() const;
00180   
00181     int globalVertexIndex(int duneFaceIndex, 
00182                           int faceTwist,
00183                           int duneFaceVertexIndex) const;
00184 
00185     void referenceElementCoordinatesRefined(SideIdentifier side, 
00186                                             CoordinateType& result) const;
00187     void referenceElementCoordinatesUnrefined(SideIdentifier side,
00188                                               CoordinateType& result) const;
00189   
00190     // old method , copies values for tetra twice 
00191     SurfaceMappingType* buildSurfaceMapping(const CoordinateType& coords) const;
00192 
00193     // get face and doesnt copy values twice
00194     SurfaceMappingType* buildSurfaceMapping(const GEOFaceType & face) const;
00195  
00196     void convert2CArray(const FieldVector<alu3d_ctype, 3>& in, 
00197                         alu3d_ctype (&out)[3]) const;
00198     void convert2FieldVector(const alu3d_ctype (&in)[3],
00199                              FieldVector<alu3d_ctype, 3>& out) const;
00200   protected:
00201     //- private data
00202     const ConnectorType& connector_; 
00203     
00204     mutable bool generatedGlobal_;
00205     mutable bool generatedLocal_;
00206 
00207     mutable CoordinateType coordsGlobal_;
00208     mutable CoordinateType coordsSelfLocal_;
00209     mutable CoordinateType coordsNeighborLocal_;
00210 
00211     const ReferenceElementType& refElem_;
00212     const ReferenceFaceType& refFace_;
00213 
00214     inline static const ReferenceElementType& getReferenceElement() 
00215     {
00216       static ReferenceElementType refElem;
00217       return refElem;
00218     }
00219 
00220     inline static const ReferenceFaceType& getReferenceFace() 
00221     {
00222       static ReferenceFaceType refFace;
00223       return refFace;
00224     }
00225 
00226   private:
00227     // convert FieldVectors to alu3dtypes 
00228     // only used for calculating the normals because the method of the
00229     // mapping classes want double (&)[3] and we have FieldVectors which store an
00230     // double [3] this is why we can cast here
00231     // plz say notin' Adrian 
00232     template <int dim>
00233     alu3d_ctype (& fieldVector2alu3d_ctype ( FieldVector <alu3d_ctype,dim> & val ) const )[dim]  
00234     {
00235       return ((alu3d_ctype (&)[dim]) (*( &(val[0])) ));
00236     }
00237 
00238     // convert const FieldVectors to const alu3dtypes 
00239     template <int dim>
00240     const alu3d_ctype (& fieldVector2alu3d_ctype ( const FieldVector <alu3d_ctype,dim> & val ) const )[dim] 
00241     {
00242       return ((const alu3d_ctype (&)[dim]) (*( &(val[0])) ) );
00243     }
00244   };
00245 
00248   class ALU3dGridGeometricFaceInfoTetra : public  ALU3dGridGeometricFaceInfoBase<tetra> 
00249   {
00250   public:
00251     //- public typedefs
00252     typedef FieldVector<alu3d_ctype, 3> NormalType;
00253     typedef FieldMatrix<alu3d_ctype, 
00254                         numVerticesPerFace,
00255                         dimworld> CoordinateType;
00256 
00257     typedef ALU3dGridFaceInfo<tetra>::GEOFaceType GEOFaceType;
00258   public:
00259     typedef ALU3dGridFaceInfo<tetra> ConnectorType;
00260 
00261     //- constructors and destructors
00262     ALU3dGridGeometricFaceInfoTetra(const ConnectorType& ctor);
00263     ALU3dGridGeometricFaceInfoTetra(const ALU3dGridGeometricFaceInfoTetra & orig);
00264    
00265     NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
00266     
00268     void resetFaceGeom();
00269     
00270   private:
00271     //- forbidden methods
00272     const ALU3dGridGeometricFaceInfoTetra & operator=(const ALU3dGridGeometricFaceInfoTetra &);
00273   
00274   private:
00275     //- private data 
00276     mutable NormalType outerNormal_;
00277     
00278     // false if surface mapping needs a update 
00279     mutable bool normalUp2Date_; 
00280   };
00281 
00284   class ALU3dGridGeometricFaceInfoHexa : public  ALU3dGridGeometricFaceInfoBase<hexa> 
00285   {
00286   public:
00287     //- public typedefs
00288     typedef FieldVector<alu3d_ctype, 3> NormalType;
00289     typedef FieldMatrix<alu3d_ctype, 
00290                         numVerticesPerFace,
00291                         dimworld> CoordinateType;
00292 
00293     typedef ALU3dGridFaceInfo<hexa>::GEOFaceType GEOFaceType;
00294     typedef BilinearSurfaceMapping SurfaceMappingType;
00295   public:
00296     typedef ALU3dGridFaceInfo<hexa> ConnectorType;
00297 
00298     //- constructors and destructors
00299     ALU3dGridGeometricFaceInfoHexa(const ConnectorType& ctor);
00300     ALU3dGridGeometricFaceInfoHexa(const ALU3dGridGeometricFaceInfoHexa & orig);
00301    
00302     NormalType & outerNormal(const FieldVector<alu3d_ctype, 2>& local) const;
00303     
00305     void resetFaceGeom();
00306     
00307   private:
00308     //- forbidden methods
00309     const ALU3dGridGeometricFaceInfoHexa & operator=(const ALU3dGridGeometricFaceInfoHexa &);
00310   
00311   private:
00312     //- private data 
00313     mutable NormalType outerNormal_;
00314   
00315     // surface mapping for calculating the outer normal 
00316     mutable SurfaceMappingType mappingGlobal_;
00317     // false if surface mapping needs a update 
00318     mutable bool mappingGlobalUp2Date_; 
00319   };
00320 
00321 } // end namespace Dune
00322 
00323 #include "faceutility_imp.cc"
00324 
00325 #endif

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