3 #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_CORNERMAPPING_HH
4 #define DUNE_GEOMETRY_GENERICGEOMETRY_CORNERMAPPING_HH
9 #include <dune/common/unused.hh>
14 namespace GenericGeometry
20 template<
class CT,
unsigned int dim,
unsigned int dimW >
28 template<
class Topology,
class Traits,
bool affine,
unsigned int offset = 0 >
29 class GenericCornerMapping;
31 template<
class Traits,
bool affine,
unsigned int offset >
32 class GenericCornerMapping <
Point, Traits, affine, offset >
37 static const unsigned int dim = Topology::dimension;
38 static const unsigned int dimW = Traits::dimWorld;
45 static const bool alwaysAffine =
true;
47 template<
class CoordStorage >
51 return coords[ offset ];
54 template<
class CoordStorage >
60 DUNE_UNUSED_PARAMETER(x);
62 for(
unsigned int i = 0; i < dimW; ++i )
63 p[ i ] = factor * y[ i ];
66 template<
class CoordStorage >
73 for(
unsigned int i = 0; i < dimW; ++i )
74 p[ i ] += factor * y[ i ];
77 template<
class CoordStorage >
83 DUNE_UNUSED_PARAMETER(coords);
84 DUNE_UNUSED_PARAMETER(x);
85 DUNE_UNUSED_PARAMETER(factor);
86 DUNE_UNUSED_PARAMETER(J);
90 template<
class CoordStorage >
96 DUNE_UNUSED_PARAMETER(coords);
97 DUNE_UNUSED_PARAMETER(x);
98 DUNE_UNUSED_PARAMETER(factor);
99 DUNE_UNUSED_PARAMETER(J);
105 template<
class BaseTopology,
class Traits,
bool affine,
unsigned int offset >
106 class GenericCornerMapping<
Prism< BaseTopology >, Traits, affine, offset >
110 typedef GenericCornerMapping< BaseTopology, Traits, affine, offset >
112 typedef GenericCornerMapping
113 < BaseTopology, Traits, affine, offset + BaseTopology::numCorners >
117 static const unsigned int dim = Topology::dimension;
118 static const unsigned int dimW = Traits::dimWorld;
125 static const bool alwaysAffine = ((dim < 2) || affine);
127 template<
class CoordStorage >
130 return BottomMapping::origin( coords );
133 template<
class CoordStorage >
141 BottomMapping::phi_set( coords, x, factor * cxn, p );
142 TopMapping::phi_add( coords, x, factor * xn, p );
145 template<
class CoordStorage >
153 BottomMapping::phi_add( coords, x, factor * cxn, p );
154 TopMapping::phi_add( coords, x, factor * xn, p );
157 template<
class CoordStorage >
164 bool isAffine =
true;
168 BottomMapping::Dphi_set( coords, x, factor * cxn, J );
169 TopMapping::Dphi_add( coords, x, factor * xn, J );
174 isAffine &= BottomMapping::Dphi_set( coords, x, factor, J );
175 isAffine &= TopMapping::Dphi_set( coords, x, factor, Jtop );
178 for(
unsigned int i = 0; i < dim-1; ++i )
181 norm += Jtop[ i ].two_norm2();
182 J[ i ].axpy( xn, Jtop[ i ] );
184 isAffine &= (norm < 1e-12);
186 BottomMapping::phi_set( coords, x, -factor, J[ dim-1 ] );
187 TopMapping::phi_add( coords, x, factor, J[ dim-1 ] );
191 template<
class CoordStorage >
198 bool isAffine =
true;
202 BottomMapping::Dphi_add( coords, x, factor * cxn, J );
203 TopMapping::Dphi_add( coords, x, factor * xn, J );
208 isAffine &= BottomMapping::Dphi_set( coords, x,
FieldType( 1 ), Jbottom );
209 isAffine &= TopMapping::Dphi_set( coords, x,
FieldType( 1 ), Jtop );
212 for(
unsigned int i = 0; i < dim-1; ++i )
214 Jtop[ i ] -= Jbottom[ i ];
215 norm += Jtop[ i ].two_norm2();
216 J[ i ].axpy( factor, Jbottom[ i ] );
217 J[ i ].axpy( factor*xn, Jtop[ i ] );
219 isAffine &= (norm < 1e-12);
221 BottomMapping::phi_add( coords, x, -factor, J[ dim-1 ] );
222 TopMapping::phi_add( coords, x, factor, J[ dim-1 ] );
228 template<
class BaseTopology,
class Traits,
bool affine,
unsigned int offset >
229 class GenericCornerMapping <
Pyramid< BaseTopology >, Traits, affine, offset >
233 typedef GenericCornerMapping< BaseTopology, Traits, affine, offset >
235 typedef GenericCornerMapping
236 <
Point, Traits, affine, offset + BaseTopology::numCorners >
240 static const unsigned int dim = Topology::dimension;
241 static const unsigned int dimW = Traits::dimWorld;
248 static const bool alwaysAffine = (BottomMapping::alwaysAffine || affine);
250 template<
class CoordStorage >
253 return BottomMapping::origin( coords );
256 template<
class CoordStorage >
268 BottomMapping::phi_set( coords, x, factor, p );
269 for(
unsigned int i = 0; i < dimW; ++i )
270 p[ i ] += (factor * xn) * (top[ i ] - bottom[ i ]);
274 TopMapping::phi_set( coords, x, factor * xn, p );
280 for(
unsigned int i = 0; i < dim-1; ++i )
281 xb[ i ] = icxn * x[ i ];
283 BottomMapping::phi_add( coords, xb, factor * cxn, p );
288 template<
class CoordStorage >
300 BottomMapping::phi_add( coords, x, factor, p );
301 for(
unsigned int i = 0; i < dimW; ++i )
302 p[ i ] += (factor * xn) * (top[ i ] - bottom[ i ]);
306 TopMapping::phi_add( coords, x, factor * xn, p );
312 for(
unsigned int i = 0; i < dim-1; ++i )
313 xb[ i ] = icxn * x[ i ];
315 BottomMapping::phi_add( coords, xb, factor * cxn, p );
320 template<
class CoordStorage >
333 isAffine = BottomMapping::Dphi_set( coords, x, factor, J );
334 for(
unsigned int i = 0; i < dimW; ++i )
335 q[ i ] = factor * (top[ i ] - bottom[ i ]);
343 for(
unsigned int i = 0; i < dim-1; ++i )
344 xb[ i ] = icxn * x[ i ];
345 isAffine = BottomMapping::Dphi_set( coords, xb, factor, J );
347 TopMapping::phi_set( coords, x, factor, q );
348 BottomMapping::phi_add( coords, xb, -factor, q );
350 for(
unsigned int j = 0; j < dim-1; ++j )
352 for(
unsigned int i = 0; i < dimW; ++i )
353 q[ i ] += J[ j ][ i ] * xb[ j ];
359 template<
class CoordStorage >
372 isAffine = BottomMapping::Dphi_add( coords, x, factor, J );
373 for(
unsigned int i = 0; i < dimW; ++i )
374 q[ i ] += factor * (top[ i ] - bottom[ i ]);
382 for(
unsigned int i = 0; i < dim-1; ++i )
383 xb[ i ] = icxn * x[ i ];
384 isAffine = BottomMapping::Dphi_add( coords, xb, factor, J );
386 TopMapping::phi_add( coords, x, factor, q );
387 BottomMapping::phi_add( coords, xb, -factor, q );
389 for(
unsigned int j = 0; j < dim-1; ++j )
391 for(
unsigned int i = 0; i < dimW; ++i )
392 q[ i ] += J[ j ][ i ] * xb[ j ];
404 template<
class Mapping,
unsigned int codim >
413 const unsigned int i_;
417 : mapping_( mapping ), i_( i )
423 = ReferenceElement::template subNumbering< codim, dimension - codim >( i_, j );
424 return mapping_.
corner( k );
437 template<
class CoordTraits,
class Topology,
unsigned int dimW >
443 static const unsigned int size = Topology::numCorners;
449 template<
class SubTopology >
455 template<
class CoordVector >
458 for(
unsigned int i = 0; i <
size; ++i )
459 coords_[ i ] = coords[ i ];
480 template<
class CoordTraits,
class Topology,
unsigned int dimW >
486 static const unsigned int size = Topology::numCorners;
492 template<
class SubTopology >
498 template<
class CoordVector >
501 for(
unsigned int i = 0; i <
size; ++i )
502 coords_[ i ] = &(coords[ i ]);
507 return *(coords_[ i ]);
524 template<
class CoordTraits,
class Topo,
unsigned int dimW,
525 class CStorage = CoordStorage< CoordTraits, Topo, dimW >,
526 bool affine =
false >
547 template<
unsigned int codim,
unsigned int i >
551 typedef typename CStorage::template SubStorage< Topology >::type
CornerStorage;
556 typedef GenericGeometry::GenericCornerMapping< Topology, Traits, affine > GenericMapping;
561 template<
class CoordVector >
582 template<
unsigned int codim,
unsigned int i >
587 return Trace( CoordVector( *
this, i ) );
598 #endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_CORNERMAPPING_HH