1 #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_MAPPINGPROVIDER_HH
2 #define DUNE_GEOMETRY_GENERICGEOMETRY_MAPPINGPROVIDER_HH
4 #include <dune/common/typetraits.hh>
14 namespace GenericGeometry
20 template<
class Topology,
class GeometryTraits >
30 template<
class CoordVector >
34 assert( (topologyId >> 1) == (Topology::id >> 1) );
35 return new( mappingStorage )
Mapping( coords );
49 template<
unsigned int dim,
class GeometryTraits >
54 static const unsigned int numTopologies = (1 << dim);
56 template<
int topologyId >
62 static void apply ( std::size_t (&
mappingSize)[ numTopologies ] )
68 template<
class CoordVector >
71 struct MappingSizeCache;
78 template<
class CoordVector >
82 static ConstructorTable< CoordVector >
construct;
83 return construct[
topologyId ]( coords, mappingStorage );
97 template<
unsigned int dim,
class GeometryTraits >
98 template<
class CoordVector >
101 typedef Mapping* (*Construct) (
const CoordVector &coords,
char *mappingStorage );
109 ForLoop< Builder, 0, numTopologies-1 >::apply( construct_ );
114 assert( topologyId < numTopologies );
119 template<
class Topology >
121 construct (
const CoordVector &coords,
char *mappingStorage )
124 return new( mappingStorage ) VMapping( coords );
127 Construct construct_[ numTopologies ];
134 template<
unsigned int dim,
class GeometryTraits >
135 template<
class CoordVector >
136 template<
int topologyId >
139 static void apply ( Construct (&
construct)[ numTopologies ] )
151 template<
unsigned int dim,
class GeometryTraits >
156 ForLoop< MappingSize, 0, numTopologies-1 >::apply( size_ );
161 assert( topologyId < numTopologies );
166 std::size_t size_[ numTopologies ];
174 template<
class ElementMapping,
unsigned int codim >
175 class MappingProvider;
178 template<
unsigned int dim,
class GeometryTraits,
unsigned int codim >
181 typedef MappingProvider< HybridMapping< dim, GeometryTraits >, codim >
This;
184 static const unsigned int dimension = dim;
185 static const unsigned int codimension = codim;
186 static const unsigned int mydimension = dimension - codimension;
193 static const unsigned int maxMappingSize = Factory::maxMappingSize;
197 template<
class CoordVector >
199 construct (
const unsigned int topologyId,
const CoordVector &coords,
char *mappingStorage )
201 return Factory::construct( topologyId, coords, mappingStorage );
204 template<
class CoordVector >
207 char *mapping =
new char[ mappingSize( topologyId ) ];
208 return construct( topologyId, coords, mapping );
211 static std::size_t mappingSize (
const unsigned int topologyId )
213 return Factory::mappingSize( topologyId );
218 template<
class Topology,
class GeometryTraits,
unsigned int codim >
221 typedef MappingProvider< NonHybridMapping< Topology, GeometryTraits >, codim >
This;
224 static const unsigned int dimension = Topology::dimension;
225 static const unsigned int codimension = codim;
226 static const unsigned int mydimension = dimension - codimension;
237 struct NonHybridFactory
239 < typename SubTopology< Topology, codim, 0 >::type, GeometryTraits >
242 typedef typename SelectType< hybrid, HybridFactory<true>, NonHybridFactory<false> >::Type Factory;
246 static const unsigned int maxMappingSize = Factory::maxMappingSize;
250 template<
class CoordVector >
252 construct (
const unsigned int topologyId,
const CoordVector &coords,
char *mappingStorage )
254 return Factory::construct( topologyId, coords, mappingStorage );
257 template<
class CoordVector >
260 Mapping *mapping =
static_cast< Mapping *
>(
operator new( mappingSize( topologyId ) ) );
261 construct( topologyId, coords, mapping );
265 static std::size_t mappingSize (
const unsigned int topologyId )
267 return Factory::mappingSize( topologyId );
275 #endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_MAPPINGPROVIDER_HH