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()) );
182 assert( (i >= 0) && (i <
corners()) );
187 GlobalCoordinate
global (
const LocalCoordinate &local )
const;
199 assert( calcedDet_ );
223 const JacobianTransposed &
237 const JacobianInverseTransposed &
256 template<
class CoordReader >
257 void build (
const CoordReader &coordReader );
259 void print ( std::ostream &out )
const;
263 ctype elDeterminant ()
const
272 GlobalCoordinate centroid_;
275 mutable JacobianTransposed jT_;
278 mutable JacobianInverseTransposed jTInv_;
281 mutable bool builtJT_;
283 mutable bool builtJTInv_;
285 mutable bool calcedDet_;
286 mutable ctype elDet_;
294 template<
int mydim,
int cdim,
class Gr
idImp >
295 class AlbertaGridGlobalGeometry
296 :
public AlbertaGridGeometry< mydim, cdim, GridImp >
298 typedef AlbertaGridGlobalGeometry< mydim, cdim, GridImp > This;
299 typedef AlbertaGridGeometry< mydim, cdim, GridImp > Base;
302 AlbertaGridGlobalGeometry ()
306 template<
class CoordReader >
307 AlbertaGridGlobalGeometry (
const CoordReader &coordReader )
308 : Base( coordReader )
313#if !DUNE_ALBERTA_CACHE_COORDINATES
314 template<
int dim,
int cdim >
315 class AlbertaGridGlobalGeometry< dim, cdim, const AlbertaGrid< dim, cdim > >
317 typedef AlbertaGridGlobalGeometry< dim, cdim, const AlbertaGrid< dim, cdim > > This;
320 typedef AlbertaGrid< dim, cdim > Grid;
323 static const int dimbary = dim + 1;
325 typedef Alberta::ElementInfo< dim > ElementInfo;
329 typedef Alberta::Real ctype;
332 static const int mydimension = dimension;
333 static const int codimension = dimension - mydimension;
334 static const int coorddimension = cdim;
336 typedef FieldVector< ctype, mydimension > LocalCoordinate;
343 static const int numCorners = mydimension + 1;
348 AlbertaGridGlobalGeometry ()
353 template<
class CoordReader >
354 AlbertaGridGlobalGeometry (
const CoordReader &coordReader )
356 build( coordReader );
362 typedef typename GenericGeometry::SimplexTopology< mydimension >::type Topology;
373 GlobalCoordinate
corner (
const int i )
const
375 assert( (i >= 0) && (i <
corners()) );
376 const Alberta::GlobalCoordinate &x = elementInfo_.coordinate( i );
378 for(
int j = 0; j < coorddimension; ++j )
386 const GlobalCoordinate &operator[] (
const int i )
const
389 return reinterpret_cast< const GlobalCoordinate &
>( elementInfo_.coordinate( i ) );
393 GlobalCoordinate
center ()
const
395 GlobalCoordinate centroid_ =
corner( 0 );
396 for(
int i = 1; i < numCorners; ++i )
398 centroid_ *= ctype( 1 ) / ctype( numCorners );
403 GlobalCoordinate
global (
const LocalCoordinate &local )
const;
406 LocalCoordinate local (
const GlobalCoordinate &global )
const;
415 return elementInfo_.geometryCache().integrationElement();
437 return elementInfo_.geometryCache().jacobianTransposed();
441 const JacobianTransposed &
454 return elementInfo_.geometryCache().jacobianInverseTransposed();
458 const JacobianInverseTransposed &
471 elementInfo_ = ElementInfo();
475 template<
class CoordReader >
476 void build (
const CoordReader &coordReader )
478 elementInfo_ = coordReader.elementInfo();
482 ElementInfo elementInfo_;
491 template<
class Gr
id >
492 class AlbertaGridLocalGeometryProvider
494 typedef AlbertaGridLocalGeometryProvider< Grid > This;
501 template<
int codim >
504 typedef AlbertaGridGeometry< dimension-codim, dimension, Grid > LocalGeometry;
507 typedef typename Codim< 0 >::LocalGeometry LocalElementGeometry;
508 typedef typename Codim< 1 >::LocalGeometry LocalFaceGeometry;
510 static const int numChildren = 2;
511 static const int numFaces = dimension + 1;
513 static const int minFaceTwist = Alberta::Twist< dimension, dimension-1 >::minTwist;
514 static const int maxFaceTwist = Alberta::Twist< dimension, dimension-1 >::maxTwist;
515 static const int numFaceTwists = maxFaceTwist - minFaceTwist + 1;
518 struct GeoInFatherCoordReader;
519 struct FaceCoordReader;
521 AlbertaGridLocalGeometryProvider ()
523 buildGeometryInFather();
527 ~AlbertaGridLocalGeometryProvider ()
529 for(
int child = 0; child < numChildren; ++child )
531 delete geometryInFather_[ child ][ 0 ];
532 delete geometryInFather_[ child ][ 1 ];
535 for(
int i = 0; i < numFaces; ++i )
537 for(
int j = 0; j < numFaceTwists; ++j )
538 delete faceGeometry_[ i ][ j ];
542 void buildGeometryInFather();
543 void buildFaceGeometry();
546 const LocalElementGeometry &
547 geometryInFather (
int child,
const int orientation = 1 )
const
549 assert( (child >= 0) && (child < numChildren) );
550 assert( (orientation == 1) || (orientation == -1) );
551 return *geometryInFather_[ child ][ (orientation + 1) / 2 ];
554 const LocalFaceGeometry &
555 faceGeometry (
int face,
int twist = 0 )
const
557 assert( (face >= 0) && (face < numFaces) );
558 assert( (twist >= minFaceTwist) && (twist <= maxFaceTwist) );
559 return *faceGeometry_[ face ][ twist - minFaceTwist ];
562 static const This &instance ()
564 static This theInstance;
569 template<
int codim >
570 static int mapVertices (
int subEntity,
int i )
572 return Alberta::MapVertices< dimension, codim >::apply( subEntity, i );
575 const LocalElementGeometry *geometryInFather_[ numChildren ][ 2 ];
576 const LocalFaceGeometry *faceGeometry_[ numFaces ][ numFaceTwists ];
584 namespace FacadeOptions
587 template<
int mydim,
int cdim,
class Gr
id >
588 struct StoreGeometryReference< mydim, cdim, Grid, AlbertaGridGlobalGeometry >
590 static const bool v =
false;
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:224
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
const GlobalCoordinate & operator[](const int i) const
deprecated way of obtaining the i-th corner
Definition: geometry.hh:179
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:197
ctype integrationElement(const LocalCoordinate &local) const
integration element of the geometry mapping
Definition: geometry.hh:204
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:210
const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &local) const
transposed inverse of the geometry mapping's Jacobian
Definition: geometry.hh:238
void invalidate()
invalidate the geometry
Definition: geometry.hh:248
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
@ dimension
The dimension of the grid.
Definition: grid.hh:400
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:406
ct ctype
Define type used for coordinates in grid module.
Definition: grid.hh:546
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Wrapper and interface classes for element geometries.
provides a wrapper for ALBERTA's el_info structure
Dune namespace.
Definition: alignment.hh:14
struct DUNE_DEPRECATED_MSG("Use class StaticPower from file power.hh instead") Power_m_p
Calculates m^p at compile time.
Definition: misc.hh:54
static const bool v
Whether to store by reference.
Definition: geometry.hh:49
Calculates the factorial of m at compile time.
Definition: math.hh:87