1 #ifndef DUNE_ALU3DGRIDGEOMETRY_HH
2 #define DUNE_ALU3DGRIDGEOMETRY_HH
7 #include <dune/common/misc.hh>
19 template<
int cd,
int dim,
class Gr
idImp>
20 class ALU3dGridEntity;
21 template<
int cd,
class Gr
idImp >
22 class ALU3dGridEntityPointer;
23 template<
int mydim,
int coorddim,
class Gr
idImp>
24 class ALU3dGridGeometry;
25 template< ALU3dGr
idElementType,
class >
27 class BilinearSurfaceMapping;
28 class TrilinearMapping;
30 template<
class Gr
idImp >
31 class ALU3dGridIntersectionIterator;
47 template <
class CoordPtrType>
48 static inline void copy(
const CoordPtrType& p,
57 template <
class CoordPtrType>
65 const CoordPtrType& )
const
67 DUNE_THROW(InvalidStateException,
"This method should not be called!");
70 template <
class CoordPtrType>
74 const CoordPtrType& )
const
76 DUNE_THROW(InvalidStateException,
"This method should not be called!");
79 template <
class CoordPtrType>
82 const CoordPtrType& )
const
84 DUNE_THROW(InvalidStateException,
"This method should not be called!");
89 template <
int dummy,
int dim,
93 template <
int dummy,
int dim, ALU3dGr
idElementType eltype>
98 enum { corners_ = dim+1 };
100 typedef FieldMatrix<alu3d_ctype, corners_ , cdim> CoordinateMatrixType;
104 CoordinateMatrixType coord_;
113 : coord_(other.coord_),
114 liMap_(other.liMap_),
115 status_(other.status_)
122 assert( i>=0 && i<corners_ );
137 template <
class CoordPtrType>
138 inline void update(
const CoordPtrType& p0)
140 assert( corners_ == 1 );
141 copy( p0, coord_[0] );
154 template <
int dummy, ALU3dGr
idElementType eltype>
160 enum { corners_ = dim+1 };
162 typedef FieldMatrix<alu3d_ctype, corners_ , cdim> CoordinateMatrixType;
169 CoordinateMatrixType coord_;
178 : coord_(other.coord_),
179 liMap_(other.liMap_),
180 status_(other.status_)
187 assert( i>=0 && i<corners_ );
202 template <
class CoordPtrType>
203 inline void update(
const CoordPtrType& p0,
204 const CoordPtrType& p1)
206 assert( corners_ == 2 );
207 copy( p0, coord_[0] );
208 copy( p1, coord_[1] );
225 enum { corners_ = 3 };
228 typedef FieldMatrix<alu3d_ctype, corners_ , cdim> CoordinateMatrixType;
232 CoordinateMatrixType coord_;
244 coord_(other.coord_),
245 liMap_(other.liMap_),
246 status_(other.status_)
253 assert( i>=0 && i<corners_ );
258 template <
class CoordPtrType>
259 inline void update(
const CoordPtrType& p0,
260 const CoordPtrType& p1,
261 const CoordPtrType& p2)
263 copy(p0, coord_[0] );
264 copy(p1, coord_[1] );
265 copy(p2, coord_[2] );
299 enum { corners_ = 4 };
302 typedef FieldMatrix<alu3d_ctype, corners_ , cdim> CoordinateMatrixType;
306 CoordinateMatrixType coord_;
318 coord_(other.coord_),
319 biMap_(other.biMap_),
320 status_(other.status_)
327 assert( i>=0 && i<corners_ );
332 template <
class CoordPtrType>
333 inline void update(
const CoordPtrType& p0,
334 const CoordPtrType& p1,
335 const CoordPtrType& p2,
336 const CoordPtrType& p3)
338 copy(p0, coord_[0] );
339 copy(p1, coord_[1] );
340 copy(p2, coord_[2] );
341 copy(p3, coord_[3] );
351 biMap_.buildMapping( coord_[0], coord_[1], coord_[2], coord_[3] );
367 enum { corners_ = 8 };
373 typedef FieldMatrix<alu3d_ctype, corners_ , cdim> CoordinateMatrixType;
380 CoordinateMatrixType* fatherCoord_;
393 for(
int i=0; i<corners_; ++i )
400 triMap_(other.triMap_),
402 status_(other.status_)
405 for(
int i=0; i<corners_; ++i )
406 coordPtr_[ i ] = other.coordPtr_[ i ];
409 if( other.fatherCoord_ )
411 fatherCoord_ =
new CoordinateMatrixType(*other.fatherCoord_);
412 CoordinateMatrixType& coord = *fatherCoord_;
413 for(
int i=0; i<corners_; ++i)
415 coordPtr_[i] = (&(coord[i][0]));
423 if( fatherCoord_ )
delete fatherCoord_;
429 assert( i>=0 && i<corners_ );
430 assert( coordPtr_[i] );
431 return coordPtr_[ i ];
438 copy( point( i ), coord );
443 inline void update(
const CoordPtrType& p0,
444 const CoordPtrType& p1,
445 const CoordPtrType& p2,
446 const CoordPtrType& p3,
447 const CoordPtrType& p4,
448 const CoordPtrType& p5,
449 const CoordPtrType& p6,
450 const CoordPtrType& p7)
452 coordPtr_[0] = &p0[ 0 ];
453 coordPtr_[1] = &p1[ 0 ];
454 coordPtr_[2] = &p2[ 0 ];
455 coordPtr_[3] = &p3[ 0 ];
456 coordPtr_[4] = &p4[ 0 ];
457 coordPtr_[5] = &p5[ 0 ];
458 coordPtr_[6] = &p6[ 0 ];
459 coordPtr_[7] = &p7[ 0 ];
464 template <
class GeometryImp>
465 inline void updateInFather(
const GeometryImp &fatherGeom ,
466 const GeometryImp &myGeom)
468 if( fatherCoord_ == 0 )
470 fatherCoord_ =
new CoordinateMatrixType();
473 CoordinateMatrixType& coord = *fatherCoord_;
475 for(
int i=0; i < myGeom.corners() ; ++i)
478 coord[i] = fatherGeom.local( myGeom.corner( i ) );
481 coordPtr_[i] = (&(coord[i][0]));
484 for(
int j=0; j<cdim; ++j)
486 if ( coord[i][j] < 1e-16) coord[i][j] = 0.0;
499 triMap_.buildMapping( point( 0 ), point( 1 ), point( 2 ), point( 3 ),
500 point( 4 ), point( 5 ), point( 6 ), point( 7 ) );
518 enum { corners_ = 4 };
524 typedef FieldMatrix<alu3d_ctype, corners_ , cdim> CoordinateMatrixType;
531 CoordinateMatrixType* fatherCoord_;
544 for(
int i=0; i<corners_; ++i )
550 liMap_(other.liMap_),
552 status_(other.status_)
555 for(
int i=0; i<corners_; ++i )
556 coordPtr_[ i ] = other.coordPtr_[ i ];
559 if( other.fatherCoord_ )
561 fatherCoord_ =
new CoordinateMatrixType(*other.fatherCoord_);
562 CoordinateMatrixType& coord = *fatherCoord_;
563 for(
int i=0; i<corners_; ++i)
565 coordPtr_[i] = (&(coord[i][0]));
573 if( fatherCoord_ )
delete fatherCoord_;
579 assert( i>=0 && i<corners_ );
580 assert( coordPtr_[ i ] );
581 return coordPtr_[ i ];
588 copy( point( i ), coord );
593 inline void update(
const CoordPtrType& p0,
594 const CoordPtrType& p1,
595 const CoordPtrType& p2,
596 const CoordPtrType& p3)
598 coordPtr_[0] = &p0[ 0 ];
599 coordPtr_[1] = &p1[ 0 ];
600 coordPtr_[2] = &p2[ 0 ];
601 coordPtr_[3] = &p3[ 0 ];
606 template <
class GeometryImp>
607 inline void updateInFather(
const GeometryImp &fatherGeom ,
608 const GeometryImp & myGeom)
610 if( fatherCoord_ == 0 )
612 fatherCoord_ =
new CoordinateMatrixType();
615 CoordinateMatrixType& coord = *fatherCoord_;
617 for(
int i=0; i < myGeom.corners() ; ++i)
620 coord[i] = fatherGeom.local( myGeom.corner( i ) );
623 coordPtr_[i] = (&(coord[i][0]));
626 for(
int j=0; j<cdim; ++j)
628 if ( coord[i][j] < 1e-16) coord[i][j] = 0.0;
641 liMap_.
buildMapping( point( 0 ), point( 1 ), point( 2 ), point( 3 ) );
655 template <
int mydim,
int cdim,
class Gr
idImp>
661 typedef typename GridImp::MPICommunicatorType Comm;
665 typedef typename ALU3dImplTraits< elementType, Comm >::IMPLElementType IMPLElementType;
666 typedef typename ALU3dImplTraits< elementType, Comm >::GEOFaceType GEOFaceType;
667 typedef typename ALU3dImplTraits< elementType, Comm >::GEOEdgeType GEOEdgeType;
668 typedef typename ALU3dImplTraits< elementType, Comm >::GEOVertexType GEOVertexType;
671 typedef typename ALU3dImplTraits< elementType, Comm >::HFaceType HFaceType;
672 typedef typename ALU3dImplTraits< elementType, Comm >::HEdgeType HEdgeType;
673 typedef typename ALU3dImplTraits< elementType, Comm >::VertexType VertexType;
678 enum { corners_ = (elementType ==
hexa) ? Power_m_p<2,mydim>::power : mydim+1 };
682 template GeometryImpl<0, mydim, elementType > GeometryImplType;
685 typedef typename GridImp :: ctype
ctype;
700 typedef FieldMatrix<
ctype,
715 const GlobalCoordinate&
operator[] (
int i)
const;
718 GlobalCoordinate
corner (
int i)
const;
722 GlobalCoordinate
global (
const LocalCoordinate&
local)
const;
726 LocalCoordinate
local (
const GlobalCoordinate&
global)
const;
739 inline bool affine ()
const;
748 bool buildGeom(
const IMPLElementType & item);
749 bool buildGeom(
const HFaceType & item,
int twist,
int faceNum);
750 bool buildGeom(
const HEdgeType & item,
int twist,
int);
751 bool buildGeom(
const VertexType & item,
int twist,
int);
754 bool buildGeom(
const FaceCoordinatesType& coords);
757 template <
class coord_t>
764 template <
class coord_t>
770 template <
class GeometryType>
775 void print (std::ostream& ss)
const;
781 bool valid ()
const ;
785 mutable GeometryImplType geoImpl_;
787 mutable ctype volume_;
792 #include "geometry_imp.cc"