Dune Core Modules (2.3.1)

traceprovider.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GEOMETRY_GENERICGEOMETRY_TRACEPROVIDER_HH
4#define DUNE_GEOMETRY_GENERICGEOMETRY_TRACEPROVIDER_HH
5
9
10#include "mapping.hh"
11#include "subtopologies.hh"
12
13namespace Dune
14{
15
16 namespace GenericGeometry
17 {
18
19 // External Forward Declarations
20 // -----------------------------
21
22 template< class Topology, class GeometryTraits >
23 class NonHybridMapping;
24
25 template< unsigned int dim, class GeometryTraits >
26 class HybridMapping;
27
28 template< class Topology, class GeometryTraits >
29 class VirtualMapping;
30
31
32
33 // TraceProvider
34 // -------------
35
36 template< class Topology, class GeometryTraits, unsigned int codim, bool forceHybrid >
37 class TraceProvider
38 {
39 typedef TraceProvider< Topology, GeometryTraits, codim, forceHybrid > This;
40
41 typedef typename GeometryTraits::template Mapping< Topology >::type MappingImpl;
42
43 public:
44 static const unsigned int dimension = Topology::dimension;
45 static const unsigned int codimension = codim;
46 static const unsigned int mydimension = dimension - codimension;
47
48 static const bool hybrid = (forceHybrid || ((mydimension != dimension) && IsHybrid< Topology >::value));
49
50 typedef GenericGeometry::Mapping< typename GeometryTraits::CoordTraits, Topology, GeometryTraits::dimWorld, MappingImpl > Mapping;
51
52 private:
53 static const unsigned int numSubTopologies = Mapping::ReferenceElement::template Codim< codimension >::size;
54
55 template< bool > class HybridFactory;
56 template< bool > class NonHybridFactory;
57
58 typedef typename conditional< hybrid, HybridFactory< true >, NonHybridFactory< false > >::type Factory;
59
60 template< int i > struct Builder;
61
62 public:
63 typedef typename Factory::Trace Trace;
64
65 static Trace *construct ( const Mapping &mapping, unsigned int i, char *traceStorage )
66 {
67 return (*instance().construct_[ i ])( mapping, traceStorage );
68 }
69
70 private:
71 typedef Trace *(*Construct)( const Mapping &mapping, char *traceStorage );
72
73 TraceProvider ()
74 {
75 ForLoop< Builder, 0, numSubTopologies-1 >::apply( construct_ );
76 }
77
78 DUNE_EXPORT static const This &instance ()
79 {
80 static This theInstance;
81 return theInstance;
82 }
83
84 Construct construct_[ numSubTopologies ];
85 };
86
87
88
89 // TraceProvider::HybridFactory
90 // ----------------------------
91
92 template< class Topology, class GeometryTraits, unsigned int codim, bool forceHybrid >
93 template< bool >
94 class TraceProvider< Topology, GeometryTraits, codim, forceHybrid >::HybridFactory
95 {
96 template< unsigned int i >
97 struct VirtualTrace
98 {
99 typedef typename GenericGeometry::SubTopology< Topology, codim, i >::type SubTopology;
100 typedef VirtualMapping< SubTopology, GeometryTraits > type;
101 };
102
103 public:
104 typedef HybridMapping< mydimension, GeometryTraits > Trace;
105
106 template< int i >
107 static Trace *construct ( const Mapping &mapping, char *traceStorage )
108 {
109 typedef typename VirtualTrace< i >::type TraceImpl;
110 return new( traceStorage ) TraceImpl( mapping.template trace< codim, i >() );
111 }
112 };
113
114
115
116 // TraceProvider::NonHybridFactory
117 // -------------------------------
118
119 template< class Topology, class GeometryTraits, unsigned int codim, bool forceHybrid >
120 template< bool >
121 class TraceProvider< Topology, GeometryTraits, codim, forceHybrid >::NonHybridFactory
122 {
123 typedef typename GenericGeometry::SubTopology< Topology, codim, 0 >::type SubTopology;
124
125 public:
126 typedef NonHybridMapping< SubTopology, GeometryTraits > Trace;
127
128 template< int i >
129 static Trace *construct ( const Mapping &mapping, char *traceStorage )
130 {
131 return new( traceStorage ) Trace( mapping.template trace< codim, i >() );
132 }
133 };
134
135
136
137 // TraceProvider::Builder
138 // ----------------------
139
140 template< class Topology, class GeometryTraits, unsigned int codim, bool forceHybrid >
141 template< int i >
142 struct TraceProvider< Topology, GeometryTraits, codim, forceHybrid >::Builder
143 {
144 static void apply ( Construct (&construct)[ numSubTopologies ] )
145 {
146 construct[ i ] = &(Factory::template construct< i >);
147 }
148 };
149
150 } // namespace GenericGeometry
151
152} // namespace Dune
153
154#endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_TRACEPROVIDER_HH
A static for loop for template meta-programming.
Dune namespace.
Definition: alignment.hh:14
Traits for type conversions and type information.
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:18
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)