3 #ifndef DUNE_GEOGRID_CACHEDCOORDFUNCTION_HH
4 #define DUNE_GEOGRID_CACHEDCOORDFUNCTION_HH
9 #include <dune/common/typetraits.hh>
23 template<
class HostGr
id,
class CoordFunction >
34 template<
class HostGr
id,
class Coordinate >
39 static const unsigned int dimension = HostGrid::dimension;
41 typedef typename HostGrid::template Codim< dimension >::Entity Vertex;
47 : data_( hostGrid, dimension )
50 template<
class Entity >
53 return data_( entity, corner );
58 assert( corner == 0 );
62 template<
class Entity >
65 return data_( entity,corner) ;
70 assert( corner == 0 );
82 This &operator= (
const This & );
94 template<
class HostGr
id,
class CoordFunction >
95 class CachedCoordFunction
96 :
public DiscreteCoordFunction< typename CoordFunction::ctype, CoordFunction::dimRange, CachedCoordFunction< HostGrid, CoordFunction > >
98 typedef CachedCoordFunction< HostGrid, CoordFunction > This;
99 typedef DiscreteCoordFunction< typename CoordFunction::ctype, CoordFunction::dimRange, This > Base;
112 const CoordFunction &coordFunction = CoordFunction() )
113 : hostGrid_( hostGrid ),
114 coordFunction_( coordFunction ),
128 template<
class HostEntity >
131 template<
class HostEntity >
134 y = cache_( hostEntity, corner );
140 CoordFunctionCaller coordFunctionCaller( hostEntity, coordFunction_ );
141 coordFunctionCaller.evaluate( corner, z );
142 assert( ((y - z).two_norm() < 1e-6) );
147 const HostGrid &hostGrid_;
148 const CoordFunction &coordFunction_;
157 template<
class HostGr
id,
class CoordFunction >
160 typedef typename HostGrid::template Codim< 0 >::Entity
Element;
161 typedef typename HostGrid::LevelGridView MacroView;
162 typedef typename HostGrid::HierarchicIterator HierarchicIterator;
164 typedef typename MacroView::template Codim< 0 >::template Partition< All_Partition >::Iterator MacroIterator;
166 const MacroView macroView = hostGrid_.levelGridView( 0 );
167 const int maxLevel = hostGrid_.maxLevel();
169 const MacroIterator mend = macroView.template end< 0, All_Partition >();
170 for( MacroIterator mit = macroView.template begin< 0, All_Partition >(); mit != mend; ++mit )
172 const Element ¯oElement = *mit;
173 insertEntity( macroElement );
175 const HierarchicIterator hend = macroElement.hend( maxLevel );
176 for( HierarchicIterator hit = macroElement.hbegin( maxLevel ); hit != hend; ++hit )
177 insertEntity( *hit );
182 template<
class HostGr
id,
class CoordFunction >
183 template<
class HostEntity >
190 CoordFunctionCaller coordFunctionCaller( hostEntity, coordFunction_ );
191 const ReferenceElement< ctype, HostEntity::dimension > &refElement
192 = ReferenceElements< ctype, HostEntity::dimension >::general( hostEntity.type() );
194 const unsigned int numCorners = refElement.size( HostEntity::dimension );
195 for(
unsigned int i = 0; i < numCorners; ++i )
196 coordFunctionCaller.evaluate( i, cache_( hostEntity, i ) );
201 #endif // #ifndef DUNE_GEOGRID_CACHEDCOORDFUNCTION_HH