3 #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_MAPPINGPROVIDER_HH
4 #define DUNE_GEOMETRY_GENERICGEOMETRY_MAPPINGPROVIDER_HH
6 #include <dune/common/typetraits.hh>
7 #include <dune/common/visibility.hh>
16 namespace GenericGeometry
22 template<
class Topology,
class GeometryTraits >
32 template<
class CoordVector >
34 construct (
const unsigned int topologyId,
const CoordVector &coords,
char *mappingStorage )
36 assert( (topologyId >> 1) == (Topology::id >> 1) );
37 return new( mappingStorage )
Mapping( coords );
40 static std::size_t
mappingSize (
const unsigned int topologyId )
42 DUNE_UNUSED_PARAMETER(topologyId);
52 template<
unsigned int dim,
class GeometryTraits >
57 static const unsigned int numTopologies = (1 << dim);
59 template<
int topologyId >
71 template<
class CoordVector >
72 class ConstructorTable;
74 struct MappingSizeCache;
81 template<
class CoordVector >
83 construct (
const unsigned int topologyId,
const CoordVector &coords,
char *mappingStorage )
85 static ConstructorTable< CoordVector >
construct;
86 return construct[ topologyId ]( coords, mappingStorage );
89 DUNE_EXPORT
static std::size_t
mappingSize (
const unsigned int topologyId )
92 return mappingSize[ topologyId ];
100 template<
unsigned int dim,
class GeometryTraits >
101 template<
class CoordVector >
102 class VirtualMappingFactory< dim, GeometryTraits >::ConstructorTable
104 typedef Mapping* (*Construct)(
const CoordVector &coords,
char *mappingStorage );
112 ForLoop< Builder, 0, numTopologies-1 >::apply( construct_ );
115 Construct operator[] (
const unsigned int topologyId )
118 return construct_[ topologyId ];
122 template<
class Topology >
124 construct (
const CoordVector &coords,
char *mappingStorage )
126 typedef VirtualMapping< Topology, GeometryTraits > VMapping;
127 return new( mappingStorage ) VMapping( coords );
137 template<
unsigned int dim,
class GeometryTraits >
138 template<
class CoordVector >
139 template<
int topologyId >
145 construct[ topologyId ] = ConstructorTable< CoordVector >::template construct< Topology >;
154 template<
unsigned int dim,
class GeometryTraits >
159 ForLoop< MappingSize, 0, numTopologies-1 >::apply( size_ );
162 std::size_t operator[] (
const unsigned int topologyId )
164 assert( topologyId < numTopologies );
165 return size_[ topologyId ];
169 std::size_t size_[ numTopologies ];
177 template<
class ElementMapping,
unsigned int codim >
181 template<
unsigned int dim,
class GeometryTraits,
unsigned int codim >
186 dune_static_assert(dim>=codim,
"Codim exceeds dimension");
188 static const unsigned int dimension = dim;
189 static const unsigned int codimension = codim;
190 static const unsigned int mydimension = dimension - codimension;
197 static const unsigned int maxMappingSize = Factory::maxMappingSize;
201 template<
class CoordVector >
203 construct (
const unsigned int topologyId,
const CoordVector &coords,
char *mappingStorage )
205 return Factory::construct( topologyId, coords, mappingStorage );
208 template<
class CoordVector >
209 static Mapping *
create (
const unsigned int topologyId,
const CoordVector &coords )
211 char *mapping =
new char[ mappingSize( topologyId ) ];
212 return construct( topologyId, coords, mapping );
217 return Factory::mappingSize( topologyId );
222 template<
class Topology,
class GeometryTraits,
unsigned int codim >
228 static const unsigned int dimension = Topology::dimension;
229 static const unsigned int codimension = codim;
230 static const unsigned int mydimension = dimension - codimension;
241 struct NonHybridFactory
243 < typename SubTopology< Topology, codim, 0 >::type, GeometryTraits >
246 typedef typename conditional< hybrid, HybridFactory<true>, NonHybridFactory<false> >::type Factory;
250 static const unsigned int maxMappingSize = Factory::maxMappingSize;
254 template<
class CoordVector >
256 construct (
const unsigned int topologyId,
const CoordVector &coords,
char *mappingStorage )
258 return Factory::construct( topologyId, coords, mappingStorage );
261 template<
class CoordVector >
262 static Mapping *
create (
const unsigned int topologyId,
const CoordVector &coords )
264 Mapping *mapping =
static_cast< Mapping *
>(
operator new( mappingSize( topologyId ) ) );
265 construct( topologyId, coords, mapping );
271 return Factory::mappingSize( topologyId );
279 #endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_MAPPINGPROVIDER_HH
Definition: mappingprovider.hh:155
static const unsigned int maxMappingSize
Definition: mappingprovider.hh:79
Definition: mappingprovider.hh:182
static std::size_t mappingSize(const unsigned int topologyId)
Definition: mappingprovider.hh:269
static Mapping * create(const unsigned int topologyId, const CoordVector &coords)
Definition: mappingprovider.hh:262
Definition: hybridmapping.hh:27
static std::size_t mappingSize(const unsigned int topologyId)
Definition: mappingprovider.hh:215
MappingSizeCache()
Definition: mappingprovider.hh:157
Factory::Mapping Mapping
Definition: mappingprovider.hh:252
Definition: mappingprovider.hh:223
Definition: mappingprovider.hh:178
conditional< isPrism, Prism< true >, Pyramid< false > >::type::type type
Definition: topologytypes.hh:295
static Mapping * create(const unsigned int topologyId, const CoordVector &coords)
Definition: mappingprovider.hh:209
unsigned int numTopologies(int dim)
obtain the number of topologies of a given dimension
Definition: topologytypes.hh:135
static Mapping * construct(const unsigned int topologyId, const CoordVector &coords, char *mappingStorage)
Definition: mappingprovider.hh:256
abstract base class for generic mapping
Definition: hybridmapping.hh:24
static DUNE_EXPORT Mapping * construct(const unsigned int topologyId, const CoordVector &coords, char *mappingStorage)
Definition: mappingprovider.hh:83
Factory::Mapping Mapping
Definition: mappingprovider.hh:199
Definition: mappingprovider.hh:23
static void apply(Construct(&construct)[numTopologies])
Definition: mappingprovider.hh:142
static Mapping * construct(const unsigned int topologyId, const CoordVector &coords, char *mappingStorage)
Definition: mappingprovider.hh:203
static std::size_t mappingSize(const unsigned int topologyId)
Definition: mappingprovider.hh:40
HybridMapping< dim, GeometryTraits > Mapping
Definition: mappingprovider.hh:74
non-virtual geometric mapping
Definition: hybridmapping.hh:351
Definition: mappingprovider.hh:53
Definition: maximum.hh:29
static const unsigned int maxMappingSize
Definition: mappingprovider.hh:30
static Mapping * construct(const unsigned int topologyId, const CoordVector &coords, char *mappingStorage)
Definition: mappingprovider.hh:34
NonHybridMapping< Topology, GeometryTraits > Mapping
Definition: mappingprovider.hh:28
Definition: topologytypes.hh:103
Definition: topologytypes.hh:271
static DUNE_EXPORT std::size_t mappingSize(const unsigned int topologyId)
Definition: mappingprovider.hh:89