3#ifndef DUNE_ALBERTA_GEOMETRY_HH
4#define DUNE_ALBERTA_GEOMETRY_HH
7#include <dune/grid/albertagrid/misc.hh>
18 template<
int dim,
int dimworld >
26 template<
int codim,
class Gr
idImp >
27 struct AlbertaGridCoordinateReader
29 typedef typename remove_const< GridImp >::type Grid;
32 static const int codimension = codim;
33 static const int mydimension = dimension - codimension;
36 typedef Alberta::Real ctype;
38 typedef Alberta::ElementInfo< dimension > ElementInfo;
41 AlbertaGridCoordinateReader (
const GridImp &grid,
42 const ElementInfo &elementInfo,
45 elementInfo_( elementInfo ),
46 subEntity_( subEntity )
49 const ElementInfo &elementInfo ()
const
54 void coordinate (
int i, Coordinate &x )
const
56 assert( !elementInfo_ ==
false );
57 assert( (i >= 0) && (i <= mydimension) );
59 const int k = mapVertices( subEntity_, i );
60 const Alberta::GlobalVector &coord = grid_.getCoord( elementInfo_, k );
61 for(
int j = 0; j < coorddimension; ++j )
65 bool hasDeterminant ()
const
70 ctype determinant ()
const
72 assert( hasDeterminant() );
77 static int mapVertices (
int subEntity,
int i )
79 return Alberta::MapVertices< dimension, codimension >::apply( subEntity, i );
83 const ElementInfo &elementInfo_;
104 template<
int mydim,
int cdim,
class Gr
idImp >
110 typedef GridImp Grid;
113 static const int dimbary = mydim + 1;
120 static const int mydimension = mydim;
121 static const int codimension = dimension - mydimension;
122 static const int coorddimension = cdim;
131 static const int numCorners = mydimension + 1;
141 template<
class CoordReader >
144 build( coordReader );
150 typedef typename GenericGeometry::SimplexTopology< mydimension >::type Topology;
166 assert( (i >= 0) && (i <
corners()) );
177 GlobalCoordinate
global (
const LocalCoordinate &local )
const;
189 assert( calcedDet_ );
213 const JacobianTransposed &
227 const JacobianInverseTransposed &
246 template<
class CoordReader >
247 void build (
const CoordReader &coordReader );
249 void print ( std::ostream &out )
const;
253 ctype elDeterminant ()
const
262 GlobalCoordinate centroid_;
265 mutable JacobianTransposed jT_;
268 mutable JacobianInverseTransposed jTInv_;
271 mutable bool builtJT_;
273 mutable bool builtJTInv_;
275 mutable bool calcedDet_;
276 mutable ctype elDet_;
284 template<
int mydim,
int cdim,
class Gr
idImp >
285 class AlbertaGridGlobalGeometry
286 :
public AlbertaGridGeometry< mydim, cdim, GridImp >
288 typedef AlbertaGridGlobalGeometry< mydim, cdim, GridImp > This;
289 typedef AlbertaGridGeometry< mydim, cdim, GridImp > Base;
292 AlbertaGridGlobalGeometry ()
296 template<
class CoordReader >
297 AlbertaGridGlobalGeometry (
const CoordReader &coordReader )
298 : Base( coordReader )
303#if !DUNE_ALBERTA_CACHE_COORDINATES
304 template<
int dim,
int cdim >
305 class AlbertaGridGlobalGeometry< dim, cdim, const AlbertaGrid< dim, cdim > >
307 typedef AlbertaGridGlobalGeometry< dim, cdim, const AlbertaGrid< dim, cdim > > This;
310 typedef AlbertaGrid< dim, cdim > Grid;
313 static const int dimbary = dim + 1;
315 typedef Alberta::ElementInfo< dim > ElementInfo;
319 typedef Alberta::Real ctype;
322 static const int mydimension = dimension;
323 static const int codimension = dimension - mydimension;
324 static const int coorddimension = cdim;
326 typedef FieldVector< ctype, mydimension > LocalCoordinate;
333 static const int numCorners = mydimension + 1;
338 AlbertaGridGlobalGeometry ()
343 template<
class CoordReader >
344 AlbertaGridGlobalGeometry (
const CoordReader &coordReader )
346 build( coordReader );
352 typedef typename GenericGeometry::SimplexTopology< mydimension >::type Topology;
363 GlobalCoordinate
corner (
const int i )
const
365 assert( (i >= 0) && (i <
corners()) );
366 const Alberta::GlobalCoordinate &x = elementInfo_.coordinate( i );
368 for(
int j = 0; j < coorddimension; ++j )
374 GlobalCoordinate
center ()
const
376 GlobalCoordinate centroid_ =
corner( 0 );
377 for(
int i = 1; i < numCorners; ++i )
379 centroid_ *= ctype( 1 ) / ctype( numCorners );
384 GlobalCoordinate
global (
const LocalCoordinate &local )
const;
387 LocalCoordinate local (
const GlobalCoordinate &global )
const;
396 return elementInfo_.geometryCache().integrationElement();
418 return elementInfo_.geometryCache().jacobianTransposed();
422 const JacobianTransposed &
435 return elementInfo_.geometryCache().jacobianInverseTransposed();
439 const JacobianInverseTransposed &
452 elementInfo_ = ElementInfo();
456 template<
class CoordReader >
457 void build (
const CoordReader &coordReader )
459 elementInfo_ = coordReader.elementInfo();
463 ElementInfo elementInfo_;
472 template<
class Gr
id >
473 class AlbertaGridLocalGeometryProvider
475 typedef AlbertaGridLocalGeometryProvider< Grid > This;
482 template<
int codim >
485 typedef AlbertaGridGeometry< dimension-codim, dimension, Grid > LocalGeometry;
488 typedef typename Codim< 0 >::LocalGeometry LocalElementGeometry;
489 typedef typename Codim< 1 >::LocalGeometry LocalFaceGeometry;
491 static const int numChildren = 2;
492 static const int numFaces = dimension + 1;
494 static const int minFaceTwist = Alberta::Twist< dimension, dimension-1 >::minTwist;
495 static const int maxFaceTwist = Alberta::Twist< dimension, dimension-1 >::maxTwist;
496 static const int numFaceTwists = maxFaceTwist - minFaceTwist + 1;
499 struct GeoInFatherCoordReader;
500 struct FaceCoordReader;
502 AlbertaGridLocalGeometryProvider ()
504 buildGeometryInFather();
508 ~AlbertaGridLocalGeometryProvider ()
510 for(
int child = 0; child < numChildren; ++child )
512 delete geometryInFather_[ child ][ 0 ];
513 delete geometryInFather_[ child ][ 1 ];
516 for(
int i = 0; i < numFaces; ++i )
518 for(
int j = 0; j < numFaceTwists; ++j )
519 delete faceGeometry_[ i ][ j ];
523 void buildGeometryInFather();
524 void buildFaceGeometry();
527 const LocalElementGeometry &
528 geometryInFather (
int child,
const int orientation = 1 )
const
530 assert( (child >= 0) && (child < numChildren) );
531 assert( (orientation == 1) || (orientation == -1) );
532 return *geometryInFather_[ child ][ (orientation + 1) / 2 ];
535 const LocalFaceGeometry &
536 faceGeometry (
int face,
int twist = 0 )
const
538 assert( (face >= 0) && (face < numFaces) );
539 assert( (twist >= minFaceTwist) && (twist <= maxFaceTwist) );
540 return *faceGeometry_[ face ][ twist - minFaceTwist ];
543 static const This &instance ()
545 static This theInstance;
550 template<
int codim >
551 static int mapVertices (
int subEntity,
int i )
553 return Alberta::MapVertices< dimension, codim >::apply( subEntity, i );
556 const LocalElementGeometry *geometryInFather_[ numChildren ][ 2 ];
557 const LocalFaceGeometry *faceGeometry_[ numFaces ][ numFaceTwists ];
geometry implementation for AlbertaGrid
Definition: geometry.hh:106
GeometryType type() const
obtain the type of reference element
Definition: geometry.hh:148
GlobalCoordinate center() const
return center of geometry
Definition: geometry.hh:171
const JacobianTransposed & jacobianTransposed(const LocalCoordinate &local) const
transposed of the geometry mapping's Jacobian
Definition: geometry.hh:214
const JacobianTransposed & jacobianTransposed() const
transposed of the geometry mapping's Jacobian
Definition: geometry.cc:53
int corners() const
number of corner the geometry
Definition: geometry.hh:158
const JacobianInverseTransposed & jacobianInverseTransposed() const
transposed inverse of the geometry mapping's Jacobian
Definition: geometry.cc:71
GlobalCoordinate corner(const int i) const
obtain the i-th corner of this geometry
Definition: geometry.hh:164
ctype integrationElement() const
integration element of the geometry mapping
Definition: geometry.hh:187
ctype integrationElement(const LocalCoordinate &local) const
integration element of the geometry mapping
Definition: geometry.hh:194
GlobalCoordinate global(const LocalCoordinate &local) const
map a point from the refence element to the geometry
Definition: geometry.cc:32
Alberta::Real ctype
type of coordinates
Definition: geometry.hh:117
ctype volume() const
volume of geometry
Definition: geometry.hh:200
const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &local) const
transposed inverse of the geometry mapping's Jacobian
Definition: geometry.hh:228
void invalidate()
invalidate the geometry
Definition: geometry.hh:238
bool affine() const
returns always true since we only have simplices
Definition: geometry.hh:155
void build(const CoordReader &coordReader)
build the geometry from a coordinate reader
Definition: geometry.cc:88
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:408
@ dimension
The dimension of the grid.
Definition: grid.hh:402
ct ctype
Define type used for coordinates in grid module.
Definition: grid.hh:548
Wrapper and interface classes for element geometries.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
provides a wrapper for ALBERTA's el_info structure
Dune namespace.
Definition: alignment.hh:10
Calculates the factorial of m at compile time.
Definition: math.hh:87