3 #ifndef DUNE_ALU2DGRIDGEOMETRY_HH
4 #define DUNE_ALU2DGRIDGEOMETRY_HH
8 #include <dune/geometry/genericgeometry/topologytypes.hh>
18 template<
int cd,
int dim,
class Gr
idImp>
19 class ALU2dGridEntity;
20 template<
int cd,
class Gr
idImp >
21 class ALU2dGridEntityPointer;
22 template<
int mydim,
int cdim,
class Gr
idImp>
23 class ALU2dGridGeometry;
24 template<
int dim,
int dimworld, ALU2DSPACE ElementType eltype >
28 template<
int mydim,
int cdim, ALU2DSPACE ElementType eltype >
31 template <
int ncorners,
class Mapping>
54 enum { mydim = ncorners < 3 ? ncorners-1 : 2 };
82 referenceElement_( ReferenceElements< ctype, mydim >::general( type ) ),
132 map2world( referenceElement_.position( i, mydim ), coordinate );
139 return mapping().map2world( m, w );
145 return mapping().world2map( w, m );
151 return mapping().jacobianTransposed( m );
157 return mapping().jacobianInverseTransposed( m );
161 ctype
det (
const map_t &m )
const {
return mapping().det( m ); }
165 template<
int cdim, ALU2DSPACE ElementType eltype >
171 using BaseType :: mapping_ ;
172 using BaseType :: valid_ ;
175 using BaseType :: valid ;
176 using BaseType :: invalidate ;
177 using BaseType :: corners ;
189 GenericGeometry :: SimplexTopology< 0 > :: type :: id :
190 GenericGeometry :: CubeTopology < 0 > :: type :: id),
195 template<
class Vector >
198 mapping_.buildMapping( p0 );
203 ctype
det (
const map_t &m )
const {
return 1.0; }
207 template<
int cdim, ALU2DSPACE ElementType eltype >
213 using BaseType :: mapping_ ;
214 using BaseType :: valid_ ;
215 using BaseType :: volume_ ;
216 using BaseType :: corners_ ;
219 using BaseType :: valid ;
220 using BaseType :: invalidate ;
221 using BaseType :: corners ;
233 GenericGeometry :: SimplexTopology< 1 > :: type :: id :
234 GenericGeometry :: CubeTopology < 1 > :: type :: id),
239 template<
class Geo,
class LocalGeo >
242 assert( localGeo.corners() == corners_ );
244 FieldMatrix< alu2d_ctype, corners_, cdim > coord;
245 for(
int i = 0; i < corners_; ++i )
248 coord[ i ] = geo.local( localGeo.corner( i ) );
250 for(
int j = 0; j < cdim; ++j )
251 coord[ i ][ j ] = (coord[ i ][ j ] < 1e-14 ? 0 : coord[ i ][ j ]);
253 mapping_.buildMapping( coord[ 0 ], coord[ 1 ] );
254 volume_ = mapping_.det( map_t(0.25) );
259 template<
class Vector >
260 void update (
const Vector &p0,
const Vector &p1,
const double volume )
262 mapping_.buildMapping( p0, p1 );
268 ctype
det (
const map_t &m )
const {
return volume_; }
278 using BaseType :: mapping_ ;
279 using BaseType :: valid_ ;
280 using BaseType :: volume_ ;
281 using BaseType :: corners_ ;
282 using BaseType :: referenceElement_;
285 using BaseType :: valid ;
286 using BaseType :: invalidate ;
287 using BaseType :: corners ;
296 assert(
std::abs( referenceElement_.volume() - 0.5 ) < 1e-10 );
301 return GeometryType( GenericGeometry :: SimplexTopology< 2 > :: type :: id , 2 );
305 template<
class Geo,
class LocalGeo >
308 assert( localGeo.corners() == corners_ );
310 FieldMatrix< alu2d_ctype, corners_, cdim > coord;
311 for(
int i = 0; i < corners_; ++i )
314 coord[ i ] = geo.local( localGeo.corner( i ) );
316 for(
int j = 0; j < cdim; ++j )
317 coord[ i ][ j ] = (coord[ i ][ j ] < 1e-14 ? 0 : coord[ i ][ j ]);
319 mapping_.buildMapping( coord[ 0 ], coord[ 1 ], coord[ 2 ] );
321 volume_ = referenceElement_.volume() * ( localGeo.volume() / geo.volume() );
322 assert( (volume_ > 0.0) && (volume_ < referenceElement_.volume() ) );
326 template<
class HElement >
329 mapping_.buildMapping( item.getVertex( 0 )->coord(), item.getVertex( 1 )->coord(),
330 item.getVertex( 2 )->coord() );
331 volume_ = item.area();
336 ctype
det (
const map_t &m )
const
338 return 2.0 * volume_ ;
349 using BaseType :: mapping_ ;
350 using BaseType :: valid_ ;
351 using BaseType :: volume_ ;
352 using BaseType :: corners_ ;
353 using BaseType :: referenceElement_;
356 using BaseType :: valid ;
357 using BaseType :: invalidate ;
358 using BaseType :: corners ;
365 return GeometryType( GenericGeometry :: CubeTopology< 2 > :: type :: id, 2 ) ;
369 template<
class Geo,
class LocalGeo >
372 assert( localGeo.corners() == corners_ );
374 FieldMatrix< alu2d_ctype, corners_, cdim > coord;
375 for(
int i = 0; i < corners_; ++i )
378 coord[ i ] = geo.local( localGeo.corner( i ) );
380 for(
int j = 0; j < cdim; ++j )
381 coord[ i ][ j ] = (coord[ i ][ j ] < 1e-14 ? 0 : coord[ i ][ j ]);
383 mapping_.buildMapping( coord[ 0 ], coord[ 1 ], coord[ 2 ], coord[ 3 ] );
384 volume_ = referenceElement_.volume() * ( localGeo.volume() / geo.volume() );
385 assert( (volume_ > 0.0) && (volume_ < referenceElement_.volume() ) );
389 template<
class HElement >
392 mapping_.buildMapping( item.getVertex( 0 )->coord(), item.getVertex( 1 )->coord(),
393 item.getVertex( 3 )->coord(), item.getVertex( 2 )->coord() );
394 volume_ = item.area();
409 using BaseType :: mapping_ ;
410 using BaseType :: volume_ ;
411 using BaseType :: valid_ ;
412 using BaseType :: referenceElement_ ;
431 using BaseType :: valid ;
432 using BaseType :: invalidate ;
436 : BaseType( type( 4 ) ),
437 simplexReferenceElement_( ReferenceElements< ctype, 2 >::general( type( 3 ) ) ),
441 assert(
sizeof( BilinearMappingType ) >=
sizeof( LinearMappingType ) );
448 return (corners() == 3 ? linearMapping().affine() : bilinearMapping().affine());
459 linearMapping().map2world( simplexReferenceElement_.position( i, 2 ), coordinate );
461 bilinearMapping().map2world( referenceElement_.position( i, 2 ), coordinate );
473 GenericGeometry :: SimplexTopology< 2 > :: type :: id :
474 GenericGeometry :: CubeTopology < 2 > :: type :: id), 2);
481 linearMapping().map2world( m, w );
483 bilinearMapping().map2world( m, w );
489 linearMapping().world2map( w, m );
491 bilinearMapping().world2map( w, m );
496 return (corners() == 3 ? linearMapping().jacobianTransposed( m ) : bilinearMapping().jacobianTransposed( m ));
501 return (corners() == 3 ? linearMapping().jacobianInverseTransposed( m ) : bilinearMapping().jacobianInverseTransposed( m ));
504 ctype
det (
const map_t &m )
const
506 return (corners() == 3 ? linearMapping().det( m ) : bilinearMapping().det( m ));
510 template<
class Geo,
class LocalGeo >
513 const int corners = localGeo.corners();
516 FieldMatrix< alu2d_ctype, 4, cdim > coord;
517 for(
int i = 0; i < corners; ++i )
520 coord[ i ] = geo.local( localGeo.corner( i ) );
522 for(
int j = 0; j < cdim; ++j )
523 coord[ i ][ j ] = (coord[ i ][ j ] < 1e-14 ? 0 : coord[ i ][ j ]);
526 updateMapping( corners );
529 linearMapping().buildMapping( coord[ 0 ], coord[ 1 ], coord[ 2 ] );
530 volume_ = simplexReferenceElement_.volume() * ( localGeo.volume() / geo.volume() );
534 bilinearMapping().buildMapping( coord[ 0 ], coord[ 1 ], coord[ 2 ], coord[ 3 ] );
535 volume_ = referenceElement_.volume() * ( localGeo.volume() / geo.volume() );
538 assert( (volume_ > 0.0) && (volume_ < 1.0) );
542 template<
class HElement >
545 const int corners = item.numvertices();
546 updateMapping( corners );
548 linearMapping().buildMapping( item.getVertex( 0 )->coord(), item.getVertex( 1 )->coord(),
549 item.getVertex( 2 )->coord() );
551 bilinearMapping().buildMapping( item.getVertex( 0 )->coord(), item.getVertex( 1 )->coord(),
552 item.getVertex( 3 )->coord(), item.getVertex( 2 )->coord() );
554 volume_ = item.area();
561 const LinearMappingType &linearMapping ()
const
564 return static_cast< const LinearMappingType *
>( &mapping_ );
567 LinearMappingType &linearMapping ()
570 return static_cast< LinearMappingType *
>( &mapping_ );
573 const BilinearMappingType &bilinearMapping ()
const
576 return static_cast< const BilinearMappingType *
>( &mapping_ );
579 BilinearMappingType &bilinearMapping ()
582 return static_cast< BilinearMappingType *
>( &mapping_ );
585 void updateMapping (
const int corners )
587 assert( (corners == 3) || (corners == 4) );
588 if( corners != myCorners_ )
591 corners = myCorners_;
593 new( &mapping_ )LinearMappingType;
595 new( &mapping_ )BilinearMappingType;
599 void destroyMapping ()
602 linearMapping().~LinearMappingType();
603 else if( corners() == 4 )
604 bilinearMapping().~BilinearMappingType();
626 template<
int mydim,
int cdim,
class Gr
idImp >
629 class ALU2dGridGeometry
630 :
public GeometryDefaultImplementation< mydim, cdim, GridImp, ALU2dGridGeometry >
635 typedef typename GridImp::template Codim<0>::Geometry Geometry;
637 typedef ALU2dGridGeometry<mydim,cdim,GridImp> GeometryImp;
639 enum { dimbary=mydim+1};
641 typedef typename ALU2dImplTraits< GridImp::dimensionworld, eltype >::HElementType HElementType ;
642 typedef typename ALU2dImplInterface< 0, GridImp::dimensionworld, eltype >::Type VertexType;
645 typedef MyALU2dGridGeometryImpl< mydim, cdim, eltype > GeometryImplType;
673 GlobalCoordinate
corner (
int i )
const;
677 GlobalCoordinate
global (
const LocalCoordinate&
local )
const;
681 LocalCoordinate
local (
const GlobalCoordinate&
global)
const;
703 bool buildGeom(
const HElementType & item);
705 bool buildGeom(
const HElementType & item,
const int aluFace);
707 bool buildGeom(
const VertexType & item,
const int );
711 template <
class GeometryType,
class LocalGeomType >
721 void print (std::ostream& ss)
const;
725 const Geometry & myGeom );
735 static std::pair< FieldMatrix< alu2d_ctype, 4, 2 >, FieldVector< alu2d_ctype, 4 > >
751 #ifdef USE_SMP_PARALLEL
753 static std::vector< GeometryProviderType > storage( GridObjectFactoryType :: maxThreads() );
754 return storage[ GridObjectFactoryType :: threadNumber () ];
756 static GeometryProviderType storage;
774 #include "geometry_imp.cc"
LinearMappingType::world_t world_t
Definition: alugrid/2d/geometry.hh:417
int myCorners_
Definition: alugrid/2d/geometry.hh:428
const inv_t & jacobianInverseTransposed(const map_t &m) const
Definition: alugrid/2d/geometry.hh:499
LocalCoordinate local(const GlobalCoordinate &global) const
BaseType::ctype ctype
Definition: alugrid/2d/geometry.hh:179
GlobalCoordinate corner(int i) const
access to coordinates of corners. Index is the number of the corner
Definition: alugrid/2d/geometry.hh:29
const MappingType & mapping() const
Definition: alugrid/2d/geometry.hh:72
const matrix_t & jacobianTransposed(const map_t &m) const
Definition: alugrid/2d/geometry.hh:149
bool affine() const
return true if geometry has affine mapping
Definition: alugrid/2d/geometry.hh:690
bool affine() const
Definition: alugrid/2d/geometry.hh:446
BaseType::map_t map_t
Definition: alugrid/2d/geometry.hh:224
MappingType::matrix_t matrix_t
Definition: alugrid/2d/geometry.hh:50
GeometryType type() const
Definition: alugrid/2d/geometry.hh:299
Definition: alu2dinclude.hh:55
BaseType::ctype ctype
Definition: alugrid/2d/geometry.hh:223
MyALU2dGridGeometryImpl()
Definition: alugrid/2d/geometry.hh:293
static GeometryProviderType & geoProvider()
return storage provider for geometry objects
Definition: alugrid/2d/geometry.hh:749
LinearMappingType::matrix_t matrix_t
Definition: alugrid/2d/geometry.hh:419
GeometryType type(const int corners) const
Definition: alugrid/2d/geometry.hh:470
void updateLocal(const Geo &geo, const LocalGeo &localGeo)
Definition: alugrid/2d/geometry.hh:240
alu2d_ctype integrationElement(const LocalCoordinate &local) const
A(l) , see grid.hh.
MyALU2dGridGeometryImplBase(const GeometryType type)
default constructor
Definition: alugrid/2d/geometry.hh:80
bool stillUsed() const
return true if there exists more then on reference
Definition: alugrid/2d/geometry.hh:107
bool buildGeom(const HElementType &item)
Methods that not belong to the Interface, but have to be public.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
void update(const Vector &p0)
Definition: alugrid/2d/geometry.hh:196
BaseType::map_t map_t
Definition: alugrid/2d/geometry.hh:180
MyALU2dGridGeometryImpl()
Definition: alugrid/2d/geometry.hh:361
int corners() const
Definition: alugrid/2d/geometry.hh:126
Include standard header files.
Definition: agrid.hh:59
alu3d_ctype ctype
Definition: mappings.hh:287
const inv_t & jacobianInverseTransposed(const map_t &m) const
Definition: alugrid/2d/geometry.hh:155
double volume() const
Definition: alugrid/2d/geometry.hh:116
GeometryType type() const
Definition: alugrid/2d/geometry.hh:466
Definition: topology.hh:13
int corners() const
return the number of corners of this element. Corners are numbered 0...n-1
Definition: alugrid/2d/geometry.hh:670
void update(const HElement &item)
Definition: alugrid/2d/geometry.hh:390
Definition: alu2dinclude.hh:55
FieldVector< ctype, cdim > world_t
Definition: mappings.hh:291
ctype det(const map_t &m) const
Definition: alugrid/2d/geometry.hh:504
ElementType
Definition: alu2dinclude.hh:55
const FieldMatrix< alu2d_ctype, cdim, mydim > & jacobianInverseTransposed(const LocalCoordinate &local) const
jacobian inverse transposed
BaseType::ctype ctype
Definition: alugrid/2d/geometry.hh:289
const ReferenceElementType & referenceElement_
reference element
Definition: alugrid/2d/geometry.hh:61
alu2d_ctype volume() const
return volume of geometry
FieldVector< alu2d_ctype, cdim > GlobalCoordinate
Definition: alugrid/2d/geometry.hh:648
world_t corner(int i) const
Definition: alugrid/2d/geometry.hh:129
A bilinear mapping.
Definition: mappings.hh:227
void operator++()
increase reference count
Definition: alugrid/2d/geometry.hh:98
unsigned int refCount_
the reference counter
Definition: alugrid/2d/geometry.hh:67
MappingType::ctype ctype
Definition: alugrid/2d/geometry.hh:45
int corners() const
Definition: alugrid/2d/geometry.hh:452
GeometryType type() const
Definition: alugrid/2d/geometry.hh:185
FieldVector< ctype, mydim > map_t
Definition: mappings.hh:292
LinearMappingType::ctype ctype
Definition: alugrid/2d/geometry.hh:414
ctype det(const map_t &m) const
Definition: alugrid/2d/geometry.hh:203
ctype det(const map_t &m) const
Definition: alugrid/2d/geometry.hh:161
double volume_
volume of element
Definition: alugrid/2d/geometry.hh:64
organize the memory management for entitys used by the NeighborIterator
Definition: alugrid/2d/grid.hh:68
Different resources needed by all grid implementations.
static const int corners_
number of corners
Definition: alugrid/2d/geometry.hh:40
GeometryType type() const
Definition: alugrid/2d/geometry.hh:363
BaseType::ReferenceElementType ReferenceElementType
Definition: alugrid/2d/geometry.hh:422
void map2world(const map_t &m, world_t &w) const
Definition: alugrid/2d/geometry.hh:137
MappingType mapping_
the mapping
Definition: alugrid/2d/geometry.hh:58
GlobalCoordinate & getCoordVec(int i)
return non-const reference to coord vecs
void world2map(const world_t &w, map_t &m) const
Definition: alugrid/2d/geometry.hh:486
ctype det(const map_t &m) const
Definition: alugrid/2d/geometry.hh:268
FieldMatrix< ctype, cdim, mydim > inv_t
Definition: mappings.hh:295
GlobalCoordinate global(const LocalCoordinate &local) const
void invalidate()
Definition: alugrid/2d/geometry.hh:110
ReferenceElement< ctype, mydim > ReferenceElementType
Definition: alugrid/2d/geometry.hh:55
void update(const Vector &p0, const Vector &p1, const double volume)
Definition: alugrid/2d/geometry.hh:260
bool buildLocalGeometry(const int faceNumber, const int twist, const int coorns)
build local geometry given local face number
LinearMappingType::map_t map_t
Definition: alugrid/2d/geometry.hh:416
BaseType::map_t map_t
Definition: alugrid/2d/geometry.hh:290
void map2world(const map_t &m, world_t &w) const
Definition: alugrid/2d/geometry.hh:478
~ALU2dGridGeometry()
destructor releasing object
void updateLocal(const Geo &geo, const LocalGeo &localGeo)
Definition: alugrid/2d/geometry.hh:370
bool valid() const
Definition: alugrid/2d/geometry.hh:113
void print(std::ostream &ss) const
print internal data
bool valid_
valid flag, true if mapping was built
Definition: alugrid/2d/geometry.hh:70
bool operator!() const
return true if object has no references anymore
Definition: alugrid/2d/geometry.hh:104
const matrix_t & jacobianTransposed(const map_t &m) const
Definition: alugrid/2d/geometry.hh:494
void removeObj()
remove pointer object
Mapping MappingType
the type of the mapping
Definition: alugrid/2d/geometry.hh:43
void getObject()
get a new pointer object
const ReferenceElementType & simplexReferenceElement_
reference element
Definition: alugrid/2d/geometry.hh:425
void updateLocal(const Geo &geo, const LocalGeo &localGeo)
Definition: alugrid/2d/geometry.hh:511
Dune::LinearMapping< cdim, 2 > LinearMappingType
Definition: alugrid/2d/geometry.hh:407
void abs(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:326
GeometryImplType & geoImpl() const
Definition: alugrid/2d/geometry.hh:762
bool buildGeomInFather(const Geometry &fatherGeom, const Geometry &myGeom)
build geometry with local coords of child in reference element
double alu2d_ctype
Definition: alu2dinclude.hh:63
Definition: alugrid/2d/entity.hh:26
const FieldMatrix< alu2d_ctype, mydim, cdim > & jacobianTransposed(const LocalCoordinate &local) const
jacobian transposed
void reset()
reset status and reference count
Definition: alugrid/2d/geometry.hh:89
Definition: alugrid/2d/geometry.hh:32
LinearMappingType::inv_t inv_t
Definition: alugrid/2d/geometry.hh:420
bool affine() const
Definition: alugrid/2d/geometry.hh:119
const GeometryType type() const
Definition: alugrid/2d/geometry.hh:667
ALUMemoryProvider< GeometryImplType > GeometryProviderType
Definition: alugrid/2d/geometry.hh:746
void updateLocal(const Geo &geo, const LocalGeo &localGeo)
Definition: alugrid/2d/geometry.hh:306
#define ALU2DSPACE
Definition: alu2dinclude.hh:34
MyALU2dGridGeometryImpl()
Definition: alugrid/2d/geometry.hh:435
BaseType::MappingType BilinearMappingType
Definition: alugrid/2d/geometry.hh:406
void update(const HElement &item)
Definition: alugrid/2d/geometry.hh:327
void operator--()
decrease reference count
Definition: alugrid/2d/geometry.hh:101
MyALU2dGridGeometryImpl()
Definition: alugrid/2d/geometry.hh:227
GeometryImplType * geoImpl_
Definition: alugrid/2d/geometry.hh:769
bool valid() const
Definition: alugrid/2d/geometry.hh:728
ctype det(const map_t &m) const
Definition: alugrid/2d/geometry.hh:336
void update(const HElement &item)
Definition: alugrid/2d/geometry.hh:543
Definition: objectfactory.hh:26
MappingType::inv_t inv_t
Definition: alugrid/2d/geometry.hh:51
GeometryType type() const
Definition: alugrid/2d/geometry.hh:229
bool buildLocalGeom(const GeometryType &geo, const LocalGeomType &lg)
ALU2dGridGeometry & operator=(const ALU2dGridGeometry &)
assigment operator
void assign(const ALU2dGridGeometry &other)
assign pointer
static std::pair< FieldMatrix< alu2d_ctype, 4, 2 >, FieldVector< alu2d_ctype, 4 > > calculateReferenceCoords(const int corners)
MyALU2dGridGeometryImpl()
Definition: alugrid/2d/geometry.hh:183
FieldMatrix< ctype, mydim, cdim > matrix_t
Definition: mappings.hh:294
world_t corner(int i) const
Definition: alugrid/2d/geometry.hh:455
MappingType::map_t map_t
Definition: alugrid/2d/geometry.hh:47
FieldVector< alu2d_ctype, mydim > LocalCoordinate
Definition: alugrid/2d/geometry.hh:649
void world2map(const world_t &w, map_t &m) const
Definition: alugrid/2d/geometry.hh:143
MappingType::world_t world_t
Definition: alugrid/2d/geometry.hh:48