dune-grid  2.1.1
albertagrid/intersection.hh
Go to the documentation of this file.
00001 #ifndef DUNE_ALBERTA_INTERSECTION_HH
00002 #define DUNE_ALBERTA_INTERSECTION_HH
00003 
00004 #include <dune/grid/common/intersection.hh>
00005 
00006 #include <dune/grid/albertagrid/transformation.hh>
00007 #include <dune/grid/albertagrid/elementinfo.hh>
00008 #include <dune/grid/albertagrid/geometry.hh>
00009 
00010 #define ALBERTA_CACHED_LOCAL_INTERSECTION_GEOMETRIES 1
00011 
00012 #if HAVE_ALBERTA
00013 
00014 namespace Dune
00015 {
00016 
00017   // External Forward Declarations
00018   // -----------------------------
00019 
00020   template< int codim, int dim, class GridImp >
00021   class AlbertaGridEntity;
00022 
00023 
00024 
00025   // AlbertaGridIntersectionBase
00026   // ---------------------------
00027 
00028   template< class Grid >
00029   class AlbertaGridIntersectionBase
00030   {
00031     typedef AlbertaGridIntersectionBase< Grid > This;
00032 
00033   public:
00034     typedef typename Grid::ctype ctype;
00035 
00036     static const int dimension = Grid::dimension;
00037     static const int dimensionworld = Grid::dimensionworld;
00038 
00039     typedef FieldVector< ctype, dimensionworld > NormalVector;
00040     typedef FieldVector< ctype, dimension-1 > LocalCoordType;
00041   
00042     typedef typename Grid::template Codim< 0 >::Entity Entity;
00043     typedef typename Grid::template Codim< 0 >::EntityPointer EntityPointer;
00044 
00045     typedef typename Grid::template Codim< 1 >::Geometry Geometry;
00046     typedef typename Grid::template Codim< 1 >::LocalGeometry LocalGeometry;
00047 
00048     typedef Alberta::ElementInfo< dimension > ElementInfo;
00049 
00050   protected:
00051     typedef AlbertaGridEntity< 0, dimension, Grid > EntityImp;
00052     typedef AlbertaGridGeometry< dimension-1, dimensionworld, Grid > GeometryImp;
00053     typedef AlbertaGridGeometry< dimension-1, dimension, Grid > LocalGeometryImp;
00054 
00055     struct GlobalCoordReader;
00056     struct LocalCoordReader;
00057 
00058   public:
00059     AlbertaGridIntersectionBase ( const EntityImp &entity, const int oppVertex );
00060 
00061     EntityPointer inside () const;
00062 
00063     bool boundary () const;
00064     int boundaryId () const;
00065     size_t boundarySegmentIndex () const;
00066 
00067     int indexInInside () const;
00068 
00069     GeometryType type () const;
00070 
00071     NormalVector centerIntegrationOuterNormal () const;
00072     NormalVector centerOuterNormal () const;
00073     NormalVector centerUnitOuterNormal () const;
00074 
00075     NormalVector integrationOuterNormal ( const LocalCoordType &local ) const;
00076     NormalVector outerNormal ( const LocalCoordType &local ) const;
00077     NormalVector unitOuterNormal ( const LocalCoordType &local ) const;
00078 
00079 
00080     AlbertaTransformation transformation () const;
00081 
00082 
00083     const Grid &grid () const;
00084     const ElementInfo &elementInfo () const;
00085 
00086   protected:
00087     const Grid *grid_;
00088     ElementInfo elementInfo_;
00089     int oppVertex_;
00090   };
00091 
00092 
00093 
00094   // AlbertaGridLeafIntersection
00095   // ---------------------------
00096 
00097   template< class GridImp >
00098   class AlbertaGridLeafIntersection
00099   : public AlbertaGridIntersectionBase< GridImp >
00100   {
00101     typedef AlbertaGridLeafIntersection< GridImp > This;
00102     typedef AlbertaGridIntersectionBase< GridImp > Base;
00103 
00104     friend class AlbertaGridEntity< 0, GridImp::dimension, GridImp >;
00105 
00106   public:
00107     typedef This ImplementationType;
00108 
00109     static const int dimension = Base::dimension;
00110 
00111     typedef typename Base::NormalVector NormalVector;
00112     typedef typename Base::LocalCoordType LocalCoordType;
00113 
00114     typedef typename Base::Entity Entity;
00115     typedef typename Base::EntityPointer EntityPointer;
00116 
00117     typedef typename Base::Geometry Geometry;
00118     typedef typename Base::LocalGeometry LocalGeometry;
00119 
00120     typedef typename Base::ElementInfo ElementInfo;
00121 
00122   protected:
00123     typedef typename Base::EntityImp EntityImp;
00124     typedef typename Base::GeometryImp GeometryImp;
00125     typedef typename Base::LocalGeometryImp LocalGeometryImp;
00126 
00127     typedef typename Base::GlobalCoordReader GlobalCoordReader;
00128     typedef typename Base::LocalCoordReader LocalCoordReader;
00129 
00130   public:
00131     using Base::grid;
00132     using Base::elementInfo;
00133 
00134     using Base::inside;
00135 
00136     AlbertaGridLeafIntersection ( const EntityImp &entity, const int n );
00137 
00138     AlbertaGridLeafIntersection ( const This &other );
00139 
00140     This &operator= ( const This &other );
00141 
00142     bool operator== ( const This &other ) const;
00143 
00144     void next ();
00145 
00146     EntityPointer outside () const;
00147 
00148     bool neighbor () const; 
00149 
00150     bool conforming () const;
00151 
00152     const LocalGeometry &geometryInInside () const;
00153     const LocalGeometry &geometryInOutside () const;
00154 
00155     const Geometry &geometry () const;
00156 
00157     int indexInOutside () const;
00158 
00159 
00160     int twistInInside () const;
00161     int twistInOutside () const;
00162 
00163   protected:
00164     using Base::oppVertex_;
00165 
00166   private:
00167     mutable ElementInfo neighborInfo_;
00168     mutable MakeableInterfaceObject< Geometry > geo_;
00169 #if not ALBERTA_CACHED_LOCAL_INTERSECTION_GEOMETRIES
00170     mutable MakeableInterfaceObject< LocalGeometry > fakeNeighObj_;
00171     mutable MakeableInterfaceObject< LocalGeometry > fakeSelfObj_;
00172 #endif
00173   };
00174 
00175 }
00176 
00177 #endif // #if HAVE_ALBERTA
00178 
00179 #endif // #ifndef DUNE_ALBERTA_INTERSECTION_HH