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;
183 dune_static_assert(dim>=codim,
"Codim exceeds dimension");
185 static const unsigned int dimension = dim;
186 static const unsigned int codimension = codim;
187 static const unsigned int mydimension = dimension - codimension;
194 static const unsigned int maxMappingSize = Factory::maxMappingSize;
198 template<
class CoordVector >
200 construct (
const unsigned int topologyId,
const CoordVector &coords,
char *mappingStorage )
202 return Factory::construct( topologyId, coords, mappingStorage );
205 template<
class CoordVector >
208 char *mapping =
new char[ mappingSize( topologyId ) ];
209 return construct( topologyId, coords, mapping );
212 static std::size_t mappingSize (
const unsigned int topologyId )
214 return Factory::mappingSize( topologyId );
219 template<
class Topology,
class GeometryTraits,
unsigned int codim >
222 typedef MappingProvider< NonHybridMapping< Topology, GeometryTraits >, codim >
This;
225 static const unsigned int dimension = Topology::dimension;
226 static const unsigned int codimension = codim;
227 static const unsigned int mydimension = dimension - codimension;
238 struct NonHybridFactory
240 < typename SubTopology< Topology, codim, 0 >::type, GeometryTraits >
243 typedef typename SelectType< hybrid, HybridFactory<true>, NonHybridFactory<false> >::Type Factory;
247 static const unsigned int maxMappingSize = Factory::maxMappingSize;
251 template<
class CoordVector >
253 construct (
const unsigned int topologyId,
const CoordVector &coords,
char *mappingStorage )
255 return Factory::construct( topologyId, coords, mappingStorage );
258 template<
class CoordVector >
261 Mapping *mapping =
static_cast< Mapping *
>(
operator new( mappingSize( topologyId ) ) );
262 construct( topologyId, coords, mapping );
266 static std::size_t mappingSize (
const unsigned int topologyId )
268 return Factory::mappingSize( topologyId );
276 #endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_MAPPINGPROVIDER_HH