5#ifndef DUNE_GEOGRID_CACHEDCOORDFUNCTION_HH
6#define DUNE_GEOGRID_CACHEDCOORDFUNCTION_HH
11#include <dune/common/typetraits.hh>
25 template<
class HostGr
id,
class CoordFunction >
26 class CachedCoordFunction;
36 template<
class HostGr
id,
class Coordinate >
41 static const unsigned int dimension = HostGrid::dimension;
43 typedef typename HostGrid::template Codim< dimension >::Entity Vertex;
49 : data_( hostGrid, dimension )
52 template<
class Entity >
55 return data_( entity, corner );
60 assert( corner == 0 );
64 template<
class Entity >
67 return data_( entity,corner) ;
72 assert( corner == 0 );
84 This &operator= (
const This & );
96 template<
class HostGr
id,
class CoordFunction >
98 :
public DiscreteCoordFunction< typename CoordFunction::ctype, CoordFunction::dimRange, CachedCoordFunction< HostGrid, CoordFunction > >
114 const CoordFunction &coordFunction = CoordFunction() )
115 : hostGrid_( hostGrid ),
116 coordFunction_( coordFunction ),
130 template<
class HostEntity >
133 template<
class HostEntity >
136 y = cache_( hostEntity, corner );
142 CoordFunctionCaller coordFunctionCaller( hostEntity, coordFunction_ );
143 coordFunctionCaller.evaluate( corner, z );
144 assert( ((y - z).two_norm() < 1e-6) );
149 const HostGrid &hostGrid_;
150 const CoordFunction &coordFunction_;
159 template<
class HostGr
id,
class CoordFunction >
162 typedef typename HostGrid::template Codim< 0 >::Entity
Element;
163 typedef typename HostGrid::LevelGridView MacroView;
164 typedef typename HostGrid::HierarchicIterator HierarchicIterator;
166 typedef typename MacroView::template Codim< 0 >::template Partition< All_Partition >::Iterator MacroIterator;
168 const MacroView macroView = hostGrid_.levelGridView( 0 );
169 const int maxLevel = hostGrid_.maxLevel();
171 const MacroIterator mend = macroView.template end< 0, All_Partition >();
172 for( MacroIterator mit = macroView.template begin< 0, All_Partition >(); mit != mend; ++mit )
174 const Element ¯oElement = *mit;
175 insertEntity( macroElement );
177 const HierarchicIterator hend = macroElement.hend( maxLevel );
178 for( HierarchicIterator hit = macroElement.hbegin( maxLevel ); hit != hend; ++hit )
179 insertEntity( *hit );
184 template<
class HostGr
id,
class CoordFunction >
185 template<
class HostEntity >
192 CoordFunctionCaller coordFunctionCaller( hostEntity, coordFunction_ );
193 auto refElement = referenceElement< ctype, HostEntity::dimension >( hostEntity.type() );
195 const unsigned int numCorners = refElement.size( HostEntity::dimension );
196 for(
unsigned int i = 0; i < numCorners; ++i )
197 coordFunctionCaller.evaluate( i, cache_( hostEntity, i ) );
Include standard header files.
Definition: agrid.hh:60
ALBERTA EL Element
Definition: misc.hh:54
@ vertex
Definition: common.hh:133
Definition: cachedcoordfunction.hh:99
void adapt()
Definition: cachedcoordfunction.hh:122
CachedCoordFunction(const HostGrid &hostGrid, const CoordFunction &coordFunction=CoordFunction())
Definition: cachedcoordfunction.hh:113
void evaluate(const HostEntity &hostEntity, unsigned int corner, RangeVector &y) const
Definition: cachedcoordfunction.hh:134
Base::ctype ctype
Definition: cachedcoordfunction.hh:104
Base::RangeVector RangeVector
Definition: cachedcoordfunction.hh:106
void buildCache()
Definition: cachedcoordfunction.hh:160
void insertEntity(const HostEntity &hostEntity)
Definition: cachedcoordfunction.hh:187
Definition: cachedcoordfunction.hh:38
void adapt()
Definition: cachedcoordfunction.hh:76
CoordCache(const HostGrid &hostGrid)
Definition: cachedcoordfunction.hh:48
const Coordinate & operator()(const Entity &entity, unsigned int corner) const
Definition: cachedcoordfunction.hh:53
Derive an implementation of a discrete coordinate function from this class.
Definition: coordfunction.hh:248
Base::RangeVector RangeVector
Definition: coordfunction.hh:253
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:185
Definition: coordfunctioncaller.hh:21
DUNE-conform implementation of the entity.
Definition: geometrygrid/entity.hh:694
void resize(const Value &value=Value())
Definition: persistentcontainermap.hh:87
void shrinkToFit()
Definition: persistentcontainermap.hh:93