3#ifndef DUNE_ALBERTA_COORDCACHE_HH
4#define DUNE_ALBERTA_COORDCACHE_HH
7#include <dune/grid/albertagrid/dofadmin.hh>
8#include <dune/grid/albertagrid/dofvector.hh>
24 typedef DofVectorPointer< GlobalVector > CoordVectorPointer;
25 typedef Alberta::DofAccess< dim, dim > DofAccess;
31 static const int dimension = dim;
33 typedef Alberta::ElementInfo< dimension > ElementInfo;
34 typedef Alberta::MeshPointer< dimension > MeshPointer;
35 typedef HierarchyDofNumbering< dimension > DofNumbering;
37 GlobalVector &operator() (
const Element *element,
int vertex )
const
39 assert( !(!coords_) );
40 GlobalVector *array = (GlobalVector *)coords_;
41 return array[ dofAccess_( element, vertex ) ];
44 GlobalVector &operator() (
const ElementInfo &elementInfo,
int vertex )
const
46 return (*
this)( elementInfo.el(), vertex );
49 void create (
const DofNumbering &dofNumbering )
51 MeshPointer mesh = dofNumbering.mesh();
52 const DofSpace *dofSpace = dofNumbering.dofSpace( dimension );
54 coords_.create( dofSpace,
"Coordinate Cache" );
55 LocalCaching localCaching( coords_ );
56 mesh.hierarchicTraverse( localCaching, FillFlags< dimension >::coords );
57 coords_.template setupInterpolation< Interpolation >();
59 dofAccess_ = DofAccess( dofSpace );
68 CoordVectorPointer coords_;
78 class CoordCache< dim >::LocalCaching
80 CoordVectorPointer coords_;
84 explicit LocalCaching (
const CoordVectorPointer &coords )
86 dofAccess_( coords.dofSpace() )
89 void operator() (
const ElementInfo &elementInfo )
const
91 GlobalVector *array = (GlobalVector *)coords_;
92 for(
int i = 0; i < DofAccess::numSubEntities; ++i )
94 const GlobalVector &x = elementInfo.coordinate( i );
95 GlobalVector &y = array[ dofAccess_( elementInfo.el(), i ) ];
96 for(
int i = 0; i < dimWorld; ++i )
108 struct CoordCache< dim >::Interpolation
110 static const int dimension = dim;
112 typedef Alberta::Patch< dimension > Patch;
115 interpolateVector (
const CoordVectorPointer &dofVector,
const Patch &patch )
117 DofAccess dofAccess( dofVector.dofSpace() );
118 GlobalVector *array = (GlobalVector *)dofVector;
120 const Element *element = patch[ 0 ];
123 assert( element->child[ 0 ] != NULL );
124 GlobalVector &newCoord = array[ dofAccess( element->child[ 0 ], dimension ) ];
126 if( element->new_coord != NULL )
128 for(
int j = 0; j < dimWorld; ++j )
129 newCoord[ j ] = element->new_coord[ j ];
135 const GlobalVector &coord0 = array[ dofAccess( element, 0 ) ];
136 const GlobalVector &coord1 = array[ dofAccess( element, 1 ) ];
137 for(
int j = 0; j < dimWorld; ++j )
138 newCoord[ j ] = 0.5 * (coord0[ j ] + coord1[ j ]);
provides a wrapper for ALBERTA's mesh structure
Dune namespace.
Definition: alignment.hh:10