1#ifndef DUNE_ALUGRID_GEOMETRY_IMP_CC
2#define DUNE_ALUGRID_GEOMETRY_IMP_CC
4#include <dune/geometry/genericgeometry/topologytypes.hh>
15template<
int mydim,
int cdim,
class Gr
idImp>
19 return GeometryType( (elementType ==
tetra) ?
20 GenericGeometry :: SimplexTopology< mydim > :: type :: id :
21 GenericGeometry :: CubeTopology < mydim > :: type :: id,
25template<
int mydim,
int cdim,
class Gr
idImp>
32template<
int mydim,
int cdim,
class Gr
idImp>
37 return geoImpl()[ i ];
41template<
int mydim,
int cdim,
class Gr
idImp>
47 geoImpl().mapping().map2world(local, global);
51template<
int mydim,
int cdim,
class Gr
idImp >
57 geoImpl().mapping().world2map(global, local);
61template<
int mydim,
int cdim,
class Gr
idImp>
67 if( mydim == 3 && elementType ==
tetra )
70 return 6.0 * geoImpl().volume();
73 return geoImpl().mapping().det( local );
76template<
int mydim,
int cdim,
class Gr
idImp>
84 return geoImpl().volume() ;
86 else if ( mydim == 2 && elementType ==
tetra )
88 enum { factor = Factorial<mydim>::factorial };
91 return integrationElement( dummy ) / ((
ctype) factor);
99template<
int mydim,
int cdim,
class Gr
idImp>
104 return geoImpl().mapping().affine();
107template<
int mydim,
int cdim,
class Gr
idImp>
112 return geoImpl().mapping().jacobianInverseTransposed( local );
115template<
int mydim,
int cdim,
class Gr
idImp>
120 return geoImpl().mapping().jacobianTransposed( local );
123template <
int mydim,
int cdim,
class Gr
idImp>
126print (std::ostream& ss)
const
128 const char* charElType = (elementType ==
tetra) ?
"tetra" :
"hexa";
129 ss <<
"ALU3dGridGeometry<" << mydim <<
", " << cdim <<
", " << charElType <<
"> = {\n";
130 for(
int i=0; i<corners(); ++i)
132 ss <<
" corner " << i <<
" ";
133 ss <<
"{" << corner(i) <<
"}"; ss << std::endl;
139template <
int mydim,
int cdim,
class Gr
idImp>
140template <
class GeometryType>
146 geoImpl().updateInFather( fatherGeom, myGeom );
149 double volume = myGeom.volume() / fatherGeom.volume() ;
150 if( elementType ==
tetra && mydim == 3 )
153 geoImpl().setVolume( volume );
156 alugrid_assert ( std::abs( 6.0 * geoImpl().volume() - integrationElement( local ) ) < 1e-12 );
160 geoImpl().setVolume( volume );
166template <
int mydim,
int cdim,
class Gr
idImp>
173 if ( elementType ==
hexa )
189 geoImpl().update( item.myvertex(0)->Point(),
190 item.myvertex(1)->Point(),
191 item.myvertex(3)->Point(),
192 item.myvertex(2)->Point(),
193 item.myvertex(4)->Point(),
194 item.myvertex(5)->Point(),
195 item.myvertex(7)->Point(),
196 item.myvertex(6)->Point() );
198 else if ( mydim == 2 )
201 geoImpl().update( item.myvertex(0)->Point(),
202 item.myvertex(1)->Point(),
203 item.myvertex(3)->Point(),
204 item.myvertex(2)->Point() );
207 else if( elementType ==
tetra )
219 geoImpl().update( item.myvertex(0)->Point(),
220 item.myvertex(1)->Point(),
221 item.myvertex(2)->Point(),
222 item.myvertex(3)->Point() );
224 else if( mydim == 2 )
227 geoImpl().update( item.myvertex(1)->Point(),
228 item.myvertex(2)->Point(),
229 item.myvertex(3)->Point() );
236 geoImpl().setVolume( item.volume() );
243template <
int mydim,
int cdim,
class Gr
idImp>
251 const int numVertices = ElementTopo::numVerticesPerFace;
253 const Twist twist( t );
256 int rotatedALUIndex[ 4 ];
257 for(
int i = 0; i < numVertices; ++i )
258 rotatedALUIndex[ i ] = (elementType ==
tetra ? twist( i ) : twist( i ) ^ (twist( i ) >> 1));
260 if( elementType ==
hexa )
265 geoImpl().update( face.myvertex(rotatedALUIndex[0])->Point(),
266 face.myvertex(rotatedALUIndex[1])->Point(),
267 face.myvertex(rotatedALUIndex[2])->Point(),
268 face.myvertex(rotatedALUIndex[3])->Point() );
270 else if ( mydim == 1)
274 geoImpl().update( face.myvertex(t < 0 ? 0 : 3)->Point(),
275 face.myvertex(t < 0 ? 3 : 0)->Point() );
278 else if ( elementType ==
tetra )
283 geoImpl().update( face.myvertex(rotatedALUIndex[0])->Point(),
284 face.myvertex(rotatedALUIndex[1])->Point(),
285 face.myvertex(rotatedALUIndex[2])->Point());
287 else if ( mydim == 1 )
290 geoImpl().update( face.myvertex( rotatedALUIndex[1])->Point(),
291 face.myvertex( rotatedALUIndex[2])->Point() );
299template <
int mydim,
int cdim,
class Gr
idImp>
300template <
class coord_t>
309 geoImpl().update( p0, p1, p2, p3 );
314template <
int mydim,
int cdim,
class Gr
idImp>
315template <
class coord_t>
323 geoImpl().update( p0, p1, p2 );
329template <
int mydim,
int cdim,
class Gr
idImp>
330template <
class coord_t>
338 geoImpl().update( p0, p1 );
343template <
int mydim,
int cdim,
class Gr
idImp>
348 if ( elementType ==
hexa )
351 return buildGeom( coords[0], coords[1], coords[2], coords[3] );
352 else if ( mydim == 1 )
353 return buildGeom( coords[0], coords[1] );
359 return buildGeom( coords[0], coords[1], coords[2] );
360 else if ( mydim == 1 )
361 return buildGeom( coords[0], coords[1] );
365template <
int mydim,
int cdim,
class Gr
idImp>
375 geoImpl().update( edge.myvertex((twist) %2)->Point(),
376 edge.myvertex((1+twist)%2)->Point() );
378 else if ( mydim == 0)
380 if (elementType ==
hexa)
383 geoImpl().update( edge.myvertex(0)->Point() );
385 else if ( elementType ==
tetra)
388 geoImpl().update( edge.myvertex(1)->Point() );
394template <
int mydim,
int cdim,
class Gr
idImp>
400 geoImpl().update(
static_cast<const GEOVertexType &
> (item).Point() );
#define alugrid_assert(EX)
Definition alugrid_assert.hh:20
Definition alu3dinclude.hh:80
@ hexa
Definition topology.hh:12
@ tetra
Definition topology.hh:12
Definition geometry.hh:632
const JacobianTransposed & jacobianTransposed(const LocalCoordinate &local) const
jacobian transposed
Definition geometry_imp.cc:118
const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &local) const
Definition geometry_imp.cc:110
ALU3dImplTraitsType::GEOFaceType GEOFaceType
Definition geometry.hh:642
FieldMatrix< ctype, GridImp::dimension==3 ? EntityCount< elementType >::numVerticesPerFace :2, cdim > FaceCoordinatesType
Definition geometry.hh:678
FieldMatrix< ctype, cdim, mydim > JacobianInverseTransposed
type of jacobian inverse transposed
Definition geometry.hh:671
LocalCoordinate local(const GlobalCoordinate &global) const
Definition geometry_imp.cc:54
GlobalCoordinate corner(int i) const
access to coordinates of corners. Index is the number of the corner
Definition geometry_imp.cc:35
int corners() const
return the number of corners of this element. Corners are numbered 0..n-1
Definition geometry_imp.cc:27
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition geometry.hh:668
ALU3dImplTraitsType::HEdgeType HEdgeType
Definition geometry.hh:648
ALU3dImplTraitsType::VertexType VertexType
Definition geometry.hh:649
ALU3dImplTraitsType::GEOEdgeType GEOEdgeType
Definition geometry.hh:643
bool buildGeom(const IMPLElementType &item)
Methods that not belong to the Interface, but have to be public.
Definition geometry_imp.cc:169
bool buildGeomInFather(const GeometryType &fatherGeom, const GeometryType &myGeom)
build geometry of local coordinates relative to father
Definition geometry_imp.cc:143
ctype integrationElement(const LocalCoordinate &local) const
A(l) , see grid.hh.
Definition geometry_imp.cc:64
GridImp::ctype ctype
Definition geometry.hh:662
ALU3dImplTraitsType::IMPLElementType IMPLElementType
Definition geometry.hh:641
void print(std::ostream &ss) const
Definition geometry_imp.cc:126
bool affine() const
returns true if mapping is affine
Definition geometry_imp.cc:102
ctype volume() const
returns volume of geometry
Definition geometry_imp.cc:79
GlobalCoordinate global(const LocalCoordinate &local) const
Definition geometry_imp.cc:44
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition geometry.hh:665
ALU3dImplTraitsType::GEOVertexType GEOVertexType
Definition geometry.hh:644
ALU3dImplTraitsType::HFaceType HFaceType
Definition geometry.hh:647
FieldMatrix< ctype, mydim, cdim > JacobianTransposed
type of jacobian transposed
Definition geometry.hh:674