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 std::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 )
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 );
165 assert( (i >= 0) && (i <
corners()) );
176 GlobalCoordinate
global (
const LocalCoordinate &local )
const;
188 assert( calcedDet_ );
212 const JacobianTransposed &
226 const JacobianInverseTransposed &
245 template<
class CoordReader >
246 void build (
const CoordReader &coordReader );
248 void print ( std::ostream &out )
const;
252 ctype elDeterminant ()
const
261 GlobalCoordinate centroid_;
264 mutable JacobianTransposed jT_;
267 mutable JacobianInverseTransposed jTInv_;
270 mutable bool builtJT_;
272 mutable bool builtJTInv_;
274 mutable bool calcedDet_;
275 mutable ctype elDet_;
283 template<
int mydim,
int cdim,
class Gr
idImp >
284 class AlbertaGridGlobalGeometry
285 :
public AlbertaGridGeometry< mydim, cdim, GridImp >
287 typedef AlbertaGridGlobalGeometry< mydim, cdim, GridImp > This;
288 typedef AlbertaGridGeometry< mydim, cdim, GridImp > Base;
291 AlbertaGridGlobalGeometry ()
295 template<
class CoordReader >
296 AlbertaGridGlobalGeometry (
const CoordReader &coordReader )
297 : Base( coordReader )
302#if !DUNE_ALBERTA_CACHE_COORDINATES
303 template<
int dim,
int cdim >
304 class AlbertaGridGlobalGeometry< dim, cdim, const AlbertaGrid< dim, cdim > >
306 typedef AlbertaGridGlobalGeometry< dim, cdim, const AlbertaGrid< dim, cdim > > This;
309 typedef AlbertaGrid< dim, cdim > Grid;
312 static const int dimbary = dim + 1;
314 typedef Alberta::ElementInfo< dim > ElementInfo;
318 typedef Alberta::Real ctype;
321 static const int mydimension = dimension;
322 static const int codimension = dimension - mydimension;
323 static const int coorddimension = cdim;
325 typedef FieldVector< ctype, mydimension > LocalCoordinate;
332 static const int numCorners = mydimension + 1;
337 AlbertaGridGlobalGeometry ()
342 template<
class CoordReader >
343 AlbertaGridGlobalGeometry (
const CoordReader &coordReader )
345 build( coordReader );
361 GlobalCoordinate
corner (
const int i )
const
363 assert( (i >= 0) && (i <
corners()) );
364 const Alberta::GlobalCoordinate &x = elementInfo_.coordinate( i );
366 for(
int j = 0; j < coorddimension; ++j )
372 GlobalCoordinate
center ()
const
374 GlobalCoordinate centroid_ =
corner( 0 );
375 for(
int i = 1; i < numCorners; ++i )
377 centroid_ *= ctype( 1 ) / ctype( numCorners );
382 GlobalCoordinate
global (
const LocalCoordinate &local )
const;
385 LocalCoordinate local (
const GlobalCoordinate &global )
const;
394 return elementInfo_.geometryCache().integrationElement();
416 return elementInfo_.geometryCache().jacobianTransposed();
420 const JacobianTransposed &
433 return elementInfo_.geometryCache().jacobianInverseTransposed();
437 const JacobianInverseTransposed &
450 elementInfo_ = ElementInfo();
454 template<
class CoordReader >
455 void build (
const CoordReader &coordReader )
457 elementInfo_ = coordReader.elementInfo();
461 ElementInfo elementInfo_;
470 template<
class Gr
id >
471 class AlbertaGridLocalGeometryProvider
473 typedef AlbertaGridLocalGeometryProvider< Grid > This;
480 template<
int codim >
483 typedef AlbertaGridGeometry< dimension-codim, dimension, Grid > LocalGeometry;
486 typedef typename Codim< 0 >::LocalGeometry LocalElementGeometry;
487 typedef typename Codim< 1 >::LocalGeometry LocalFaceGeometry;
489 static const int numChildren = 2;
490 static const int numFaces = dimension + 1;
492 static const int minFaceTwist = Alberta::Twist< dimension, dimension-1 >::minTwist;
493 static const int maxFaceTwist = Alberta::Twist< dimension, dimension-1 >::maxTwist;
494 static const int numFaceTwists = maxFaceTwist - minFaceTwist + 1;
497 struct GeoInFatherCoordReader;
498 struct FaceCoordReader;
500 AlbertaGridLocalGeometryProvider ()
502 buildGeometryInFather();
506 ~AlbertaGridLocalGeometryProvider ()
508 for(
int child = 0; child < numChildren; ++child )
510 delete geometryInFather_[ child ][ 0 ];
511 delete geometryInFather_[ child ][ 1 ];
514 for(
int i = 0; i < numFaces; ++i )
516 for(
int j = 0; j < numFaceTwists; ++j )
517 delete faceGeometry_[ i ][ j ];
521 void buildGeometryInFather();
522 void buildFaceGeometry();
525 const LocalElementGeometry &
526 geometryInFather (
int child,
const int orientation = 1 )
const
528 assert( (child >= 0) && (child < numChildren) );
529 assert( (orientation == 1) || (orientation == -1) );
530 return *geometryInFather_[ child ][ (orientation + 1) / 2 ];
533 const LocalFaceGeometry &
534 faceGeometry (
int face,
int twist = 0 )
const
536 assert( (face >= 0) && (face < numFaces) );
537 assert( (twist >= minFaceTwist) && (twist <= maxFaceTwist) );
538 return *faceGeometry_[ face ][ twist - minFaceTwist ];
541 static const This &instance ()
543 static This theInstance;
548 template<
int codim >
549 static int mapVertices (
int subEntity,
int i )
554 const LocalElementGeometry *geometryInFather_[ numChildren ][ 2 ];
555 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:170
const JacobianTransposed & jacobianTransposed(const LocalCoordinate &local) const
transposed of the geometry mapping's Jacobian
Definition: geometry.hh:213
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:157
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:163
ctype integrationElement() const
integration element of the geometry mapping
Definition: geometry.hh:186
ctype integrationElement(const LocalCoordinate &local) const
integration element of the geometry mapping
Definition: geometry.hh:193
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:199
const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &local) const
transposed inverse of the geometry mapping's Jacobian
Definition: geometry.hh:227
void invalidate()
invalidate the geometry
Definition: geometry.hh:237
bool affine() const
returns always true since we only have simplices
Definition: geometry.hh:154
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:277
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:393
@ dimension
The dimension of the grid.
Definition: grid.hh:387
ct ctype
Define type used for coordinates in grid module.
Definition: grid.hh:522
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
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:58
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:696
Dune namespace.
Definition: alignedallocator.hh:10
Calculates the factorial of m at compile time.
Definition: math.hh:89