5#ifndef DUNE_ALBERTA_COORDCACHE_HH
6#define DUNE_ALBERTA_COORDCACHE_HH
9#include <dune/grid/albertagrid/dofadmin.hh>
10#include <dune/grid/albertagrid/dofvector.hh>
26 typedef DofVectorPointer< GlobalVector > CoordVectorPointer;
27 typedef Alberta::DofAccess< dim, dim > DofAccess;
33 static const int dimension = dim;
35 typedef Alberta::ElementInfo< dimension > ElementInfo;
36 typedef Alberta::MeshPointer< dimension > MeshPointer;
37 typedef HierarchyDofNumbering< dimension > DofNumbering;
39 GlobalVector &operator() (
const Element *element,
int vertex )
const
41 assert( !(!coords_) );
42 GlobalVector *array = (GlobalVector *)coords_;
43 return array[ dofAccess_( element,
vertex ) ];
46 GlobalVector &operator() (
const ElementInfo &elementInfo,
int vertex )
const
48 return (*
this)( elementInfo.el(),
vertex );
51 void create (
const DofNumbering &dofNumbering )
53 MeshPointer mesh = dofNumbering.mesh();
54 const DofSpace *dofSpace = dofNumbering.dofSpace( dimension );
56 coords_.create( dofSpace,
"Coordinate Cache" );
57 LocalCaching localCaching( coords_ );
58 mesh.hierarchicTraverse( localCaching, FillFlags< dimension >::coords );
59 coords_.template setupInterpolation< Interpolation >();
61 dofAccess_ = DofAccess( dofSpace );
70 CoordVectorPointer coords_;
80 class CoordCache< dim >::LocalCaching
82 CoordVectorPointer coords_;
86 explicit LocalCaching (
const CoordVectorPointer &coords )
88 dofAccess_( coords.dofSpace() )
91 void operator() (
const ElementInfo &elementInfo )
const
93 GlobalVector *array = (GlobalVector *)coords_;
94 for(
int i = 0; i < DofAccess::numSubEntities; ++i )
96 const GlobalVector &x = elementInfo.coordinate( i );
97 GlobalVector &y = array[ dofAccess_( elementInfo.el(), i ) ];
98 for(
int i = 0; i < dimWorld; ++i )
110 struct CoordCache< dim >::Interpolation
112 static const int dimension = dim;
114 typedef Alberta::Patch< dimension > Patch;
117 interpolateVector (
const CoordVectorPointer &dofVector,
const Patch &patch )
119 DofAccess dofAccess( dofVector.dofSpace() );
120 GlobalVector *array = (GlobalVector *)dofVector;
122 const Element *element = patch[ 0 ];
125 assert( element->child[ 0 ] != NULL );
126 GlobalVector &newCoord = array[ dofAccess( element->child[ 0 ], dimension ) ];
128 if( element->new_coord != NULL )
130 for(
int j = 0; j < dimWorld; ++j )
131 newCoord[ j ] = element->new_coord[ j ];
137 const GlobalVector &coord0 = array[ dofAccess( element, 0 ) ];
138 const GlobalVector &coord1 = array[ dofAccess( element, 1 ) ];
139 for(
int j = 0; j < dimWorld; ++j )
140 newCoord[ j ] = 0.5 * (coord0[ j ] + coord1[ j ]);
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:492
provides a wrapper for ALBERTA's mesh structure
Dune namespace.
Definition: alignedallocator.hh:13