This file is indexed.

/usr/include/dune/geometry/genericgeometry/hybridmapping.hh is in libdune-geometry-dev 2.2.1-2ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=8 sw=2 sts=2:
#ifndef DUNE_GEOMETRY_GENERICGEOMETRY_HYBRIDMAPPING_HH
#define DUNE_GEOMETRY_GENERICGEOMETRY_HYBRIDMAPPING_HH

#include <cstddef>

#include <dune/common/typetraits.hh>

#include <dune/geometry/genericgeometry/cachedmapping.hh>
#include <dune/geometry/genericgeometry/geometrytraits.hh>
#include <dune/geometry/genericgeometry/traceprovider.hh>

namespace Dune
{

  namespace GenericGeometry
  {

    // Internal Forward Declarations
    // -----------------------------

    template< unsigned int dim, class GeometryTraits >
    class HybridMapping;

    template< class Topology, class GeometryTraits >
    class VirtualMapping;



    // HybridMappingBase
    // -----------------

    /** \cond */
    template< unsigned int dim, class GeometryTraits, unsigned int codim = dim >
    class HybridMappingBase;

    template< unsigned int dim, class GeometryTraits, unsigned int codim >
    class HybridMappingBase
      : public virtual HybridMappingBase< dim, GeometryTraits, static_cast<unsigned int>(codim-1) >
    {
      typedef HybridMapping< dim, GeometryTraits > Mapping;

    public:
      virtual ~HybridMappingBase() {}

    protected:
      using HybridMappingBase< dim, GeometryTraits, static_cast<unsigned int>(codim-1) >::trace;

      virtual HybridMapping< dim - codim, GeometryTraits > *
      trace ( integral_constant< int, codim >, unsigned int i, char *mappingStorage ) const = 0;
    };

    template< unsigned int dim, class GeometryTraits >
    class HybridMappingBase< dim, GeometryTraits, 0 >
    {
      typedef HybridMapping< dim, GeometryTraits > Mapping;

    public:
      virtual ~HybridMappingBase() {}

    protected:
      virtual HybridMapping< dim, GeometryTraits > *
      trace ( integral_constant< int, 0 >, unsigned int i, char *mappingStorage ) const = 0;
    };

    template< unsigned int dim, class GeometryTraits >
    class HybridMappingBase< dim, GeometryTraits, static_cast<unsigned int>(-1) >
    {
      typedef HybridMapping< dim, GeometryTraits > Mapping;

    public:
      virtual ~HybridMappingBase() {}

    protected:
      virtual HybridMapping< dim, GeometryTraits > *
      trace ( integral_constant< int, 0 >, unsigned int i, char *mappingStorage ) const = 0;
    };
    /** \endcond */



    // HybridMapping
    // -------------

    /** \class   HybridMapping
     *  \ingroup GenericGeometry
     *  \brief   abstract base class for generic mapping
     *
     *  This is the user-visible class of the generic geometries if the
     *  topology type for each codimension is not unique.
     */
    template< unsigned int dim, class GeometryTraits >
    class HybridMapping
    /** \cond */
    : public virtual HybridMappingBase< dim, GeometryTraits >
    /** \endcond */
    {
      typedef HybridMapping< dim, GeometryTraits > This;

    protected:
      typedef MappingTraits< typename GeometryTraits::CoordTraits, dim, GeometryTraits::dimWorld > Traits;

    public:
      static const unsigned int dimension = Traits::dimension;
      static const unsigned int dimWorld = Traits::dimWorld;
      
      typedef typename Traits::FieldType FieldType;
      typedef typename Traits::LocalCoordinate LocalCoordinate;
      typedef typename Traits::GlobalCoordinate GlobalCoordinate;

      typedef CachedJacobianTransposed< dimension, GeometryTraits > JacobianTransposed;
      typedef CachedJacobianInverseTransposed< dimension, GeometryTraits > JacobianInverseTransposed;

      template< int codim >
      struct Codim
      {
        typedef HybridMapping< dimension - codim, GeometryTraits > Trace;
      };

      typedef typename GeometryTraits::Caching Caching;
      typedef typename GeometryTraits::UserData UserData;

      virtual ~HybridMapping ()
      {}

      /** \brief is this mapping affine? */
      virtual bool affine () const = 0;
      /** \brief obtain the name of the reference element */
      virtual Dune::GeometryType type () const = 0;
      unsigned int topologyId () const DUNE_DEPRECATED { return type().id(); }

      /** \brief obtain number of corners of the corresponding reference element */
      virtual int numCorners () const = 0;
      /** \brief obtain coordinates of the i-th corner */
      virtual GlobalCoordinate corner ( int i ) const = 0;
      /** \brief obtain the centroid of the mapping's image */
      virtual GlobalCoordinate center () const = 0;

      /** \brief evaluate the mapping
       *
       *  \param[in]  x  local coordinate to map
       *
       *  \returns corresponding global coordinate
       */
      virtual GlobalCoordinate global ( const LocalCoordinate &x ) const = 0;
      /** \brief evaluate the inverse mapping
       *
       *  \param[in]  y  global coordinate to map
       *
       *  \return corresponding local coordinate
       *
       *  \note The returned local coordinate y minimizes
       *  \code
       *  (global( x ) - y).two_norm()
       *  \endcode
       */
      virtual LocalCoordinate local ( const GlobalCoordinate &y ) const = 0;

      /** \brief check whether a point lies within the reference element
       *
       *  \param[in]  x  local coordinate of point to check
       *
       *  \note Historically, this method was part of the geometry interface.
       *        It is still required for the GenericReferenceElement.
       */
      virtual bool checkInside ( const LocalCoordinate &x ) const = 0;

      /** \brief obtain the integration element
       *
       *  If the Jacobian of the mapping is denoted by $J(x)$, the integration
       *  integration element \f$\mu(x)\f$ is given by
       *  \f[ \mu(x) = \sqrt{|\det (J^T(x) J(x))|}.\f]
       *
       *  \param[in]  x  local coordinate to evaluate the integration element in
       *
       *  \returns the integration element \f$\mu(x)\f$.
       *
       *  \note For affine mappings, it is more efficient to call
       *        jacobianInverseTransposed before integrationElement, if both
       *        are required.
       */
      virtual FieldType integrationElement ( const LocalCoordinate &x ) const = 0;
      /** \brief obtain the volume of the mapping's image
       *
       *  \note The current implementation just returns
       *  \code
       *  integrationElement( baryCenter() ) * ReferenceElement::volume()
       *  \endcode
       *  which is wrong for n-linear surface maps and other nonlinear maps.
       */
      virtual FieldType volume () const = 0;

      /** \brief obtain the transposed of the Jacobian
       *
       *  \param[in]  x  local coordinate to evaluate Jacobian in
       *
       *  \returns a reference to the transposed of the Jacobian
       *
       *  \note The returned reference is reused on the next call to
       *        JacobianTransposed, destroying the previous value.
       */
      virtual const JacobianTransposed &jacobianTransposed ( const LocalCoordinate &x ) const = 0;
      /** \brief obtain the transposed of the Jacobian's inverse
       *
       *  The Jacobian's inverse is defined as a pseudo-inverse. If we denote
       *  the Jacobian by \f$J(x)\f$, the following condition holds:
       *  \f[J^{-1}(x) J(x) = I.\f]
       */
      virtual const JacobianInverseTransposed &jacobianInverseTransposed ( const LocalCoordinate &x ) const = 0;

    protected:
      using HybridMappingBase< dim, GeometryTraits >::trace;

    public:
      virtual This *clone () const = 0;
      virtual This *clone ( char *mappingStorage ) const = 0;

      template< int codim >
      typename Codim< codim >::Trace *trace ( unsigned int i, char *mappingStorage ) const
      {
        integral_constant< int, codim > codimVariable;
        return trace( codimVariable, i, mappingStorage );
      }

      const UserData &userData () const { return userData_; }
      UserData &userData () { return userData_; }

    private:
      UserData userData_;
    };



    // VirtualMappingBase
    // ------------------

    /** \cond */
    template< class Topology, class GeometryTraits, unsigned int codim = Topology::dimension >
    class VirtualMappingBase;

    template< class Topology, class GeometryTraits, unsigned int codim >
    class VirtualMappingBase
    : public VirtualMappingBase< Topology, GeometryTraits, codim-1 >,
      public virtual HybridMappingBase< Topology::dimension, GeometryTraits, codim >
    {
      typedef GenericGeometry::VirtualMapping< Topology, GeometryTraits >
        VirtualMapping;

    protected:
      using VirtualMappingBase< Topology, GeometryTraits, codim-1 >::trace;

      virtual HybridMapping< Topology::dimension - codim, GeometryTraits > *
      trace ( integral_constant< int, codim >, unsigned int i, char *mappingStorage ) const
      {
        return static_cast< const VirtualMapping & >( *this ).template trace< codim >( i, mappingStorage );
      }
    };

    template< class Topology, class GeometryTraits >
    class VirtualMappingBase< Topology, GeometryTraits, 0 >
    : public virtual HybridMappingBase< Topology::dimension, GeometryTraits, 0 >
    {
      typedef GenericGeometry::VirtualMapping< Topology, GeometryTraits >
        VirtualMapping;

    protected:
      virtual HybridMapping< Topology::dimension, GeometryTraits > *
      trace ( integral_constant< int, 0 >, unsigned int i, char *mappingStorage ) const
      {
        return static_cast< const VirtualMapping & >( *this ).template trace< 0 >( i, mappingStorage );
      }
    };
    /** \endcond */



    template< class Topology, class GeometryTraits >
    class VirtualMapping
    : public HybridMapping< Topology::dimension, GeometryTraits >,
    /** \cond */
      public VirtualMappingBase< Topology, GeometryTraits >
    /**\endcond*/
    {
      typedef HybridMapping< Topology::dimension, GeometryTraits > Base;
      typedef VirtualMapping< Topology, GeometryTraits > This;

      typedef typename Base::Traits Traits;
      
      typedef CachedMapping< Topology, GeometryTraits > Mapping;

    public:
      static const unsigned int dimension = Traits::dimension;
      static const unsigned int dimWorld = Traits::dimWorld;
      
      typedef typename Traits::FieldType FieldType;
      typedef typename Traits::LocalCoordinate LocalCoordinate;
      typedef typename Traits::GlobalCoordinate GlobalCoordinate;

      typedef typename Base::JacobianTransposed JacobianTransposed;
      typedef typename Base::JacobianInverseTransposed JacobianInverseTransposed;

      typedef typename Mapping::ReferenceElement ReferenceElement;
      
      template< unsigned int codim >
      struct Codim
      {
        typedef typename TraceProvider< Topology, GeometryTraits, codim, true >::Trace Trace;
      };

      typedef typename GeometryTraits::Caching Caching;

      template< class CoordVector >
      explicit VirtualMapping ( const CoordVector &coordVector )
      : mapping_( coordVector )
      {}

      virtual bool affine () const { return mapping_.affine(); }
      virtual Dune::GeometryType type () const { return mapping_.type(); }

      virtual int numCorners () const { return mapping_.numCorners(); }
      virtual GlobalCoordinate corner ( int i ) const { return mapping_.corner( i ); }
      virtual GlobalCoordinate center () const { return mapping_.center(); }

      virtual GlobalCoordinate global ( const LocalCoordinate &local ) const { return mapping_.global( local ); }
      virtual LocalCoordinate local ( const GlobalCoordinate &global ) const { return mapping_.local( global ); }

      virtual bool checkInside ( const LocalCoordinate &local ) const { return mapping_.checkInside( local ); }

      virtual FieldType integrationElement ( const LocalCoordinate &local ) const { return mapping_.integrationElement( local ); }
      virtual FieldType volume () const { return mapping_.volume(); }

      virtual const JacobianTransposed &jacobianTransposed ( const LocalCoordinate &local ) const { return mapping_.jacobianTransposed( local ); }
      virtual const JacobianInverseTransposed &jacobianInverseTransposed ( const LocalCoordinate &local ) const { return mapping_.jacobianInverseTransposed( local ); }

      virtual Base *clone () const { return new This( *this ); }
      virtual Base* clone ( char *mappingStorage ) const { return new( mappingStorage ) This( *this ); }

      template< int codim >
      typename Codim< codim >::Trace *trace ( unsigned int i, char *mappingStorage ) const
      {
        return TraceProvider< Topology, GeometryTraits, codim, true >::construct( mapping_.mapping(), i, mappingStorage );
      }

    protected:
      using VirtualMappingBase< Topology, GeometryTraits >::trace;

    private:
      Mapping mapping_;
    };



    // NonHybridMapping
    // ----------------

    /** \class   NonHybridMapping
     *  \ingroup GenericGeometry
     *  \brief   non-virtual geometric mapping
     *
     *  This is the user-visible class of the generic geometries if the
     *  topology type for each codimension is unique.
     */
    template< class Topology, class GeometryTraits >
    class NonHybridMapping
    {
      typedef NonHybridMapping< Topology, GeometryTraits > This;

    protected:
      typedef MappingTraits< typename GeometryTraits::CoordTraits, Topology::dimension, GeometryTraits::dimWorld > Traits;
      
      typedef CachedMapping< Topology, GeometryTraits > Mapping;

    public:
      static const unsigned int dimension = Traits::dimension;
      static const unsigned int dimWorld = Traits::dimWorld;
      
      typedef typename Traits::FieldType FieldType;
      typedef typename Traits::LocalCoordinate LocalCoordinate;
      typedef typename Traits::GlobalCoordinate GlobalCoordinate;

      typedef CachedJacobianTransposed< dimension, GeometryTraits > JacobianTransposed;
      typedef CachedJacobianInverseTransposed< dimension, GeometryTraits > JacobianInverseTransposed;

      typedef typename Mapping::ReferenceElement ReferenceElement;
      
      template< unsigned int codim >
      struct Codim
      {
        typedef typename TraceProvider< Topology, GeometryTraits, codim, false >::Trace Trace;
      };

      typedef typename GeometryTraits::Caching Caching;
      typedef typename GeometryTraits::UserData UserData;

      template< class CoordVector >
      explicit NonHybridMapping ( const CoordVector &coordVector )
      : mapping_( coordVector )
      {}

      /** \brief is this mapping affine? */
      bool affine () const { return mapping_.affine(); }
      /** \brief obtain the name of the reference element */
      Dune::GeometryType type () const { return mapping_.type(); }
      unsigned int topologyId () const DUNE_DEPRECATED { return type().id(); }

      /** \brief obtain number of corners of the corresponding reference element */
      int numCorners () const { return mapping_.numCorners(); }
      /** \brief obtain coordinates of the i-th corner */
      GlobalCoordinate corner ( int i ) const { return mapping_.corner( i ); }
      /** \brief obtain the centroid of the mapping's image */
      GlobalCoordinate center () const { return mapping_.center(); }

      /** \brief evaluate the mapping
       *
       *  \param[in]  local  local coordinate to map
       *
       *  \returns corresponding global coordinate
       */
      GlobalCoordinate global ( const LocalCoordinate &local ) const { return mapping_.global( local ); }
      /** \brief evaluate the inverse mapping
       *
       *  \param[in]  global  global coorindate to map
       *
       *  \return corresponding local coordinate
       *
       *  \note The returned local coordinate y minimizes
       *  \code
       *  (global( x ) - y).two_norm()
       *  \endcode
       */
      LocalCoordinate local ( const GlobalCoordinate &global ) const { return mapping_.local( global ); }

      /** \brief check whether a point lies within the reference element
       *
       *  \param[in]  local  local coordinate of point to check
       *
       *  \note Historically, this method was part of the geometry interface.
       *        It is still required for the GenericReferenceElement.
       */
      bool checkInside ( const LocalCoordinate &local ) const { return mapping_.checkInside( local ); }

      /** \brief obtain the integration element
       *
       *  If the Jacobian of the mapping is denoted by $J(x)$, the integration
       *  integration element \f$\mu(x)\f$ is given by
       *  \f[ \mu(x) = \sqrt{|\det (J^T(x) J(x))|}.\f]
       *
       *  \param[in]  local  local coordinate to evaluate the integration element in
       *
       *  \returns the integration element \f$\mu(x)\f$.
       *
       *  \note For affine mappings, it is more efficient to call
       *        jacobianInverseTransposed before integrationElement, if both
       *        are required.
       */
      FieldType integrationElement ( const LocalCoordinate &local ) const { return mapping_.integrationElement( local ); }
      /** \brief obtain the volume of the mapping's image
       *
       *  \note The current implementation just returns
       *  \code
       *  integrationElement( baryCenter() ) * ReferenceElement::volume()
       *  \endcode
       *  which is wrong for n-linear surface maps and other nonlinear maps.
       */
      FieldType volume () const { return mapping_.volume(); }

      /** \brief obtain the transposed of the Jacobian
       *
       *  \param[in]  local  local coordinate to evaluate Jacobian in
       *
       *  \returns a reference to the transposed of the Jacobian
       *
       *  \note The returned reference is reused on the next call to
       *        JacobianTransposed, destroying the previous value.
       */
      const JacobianTransposed &jacobianTransposed ( const LocalCoordinate &local ) const { return mapping_.jacobianTransposed( local ); }
      /** \brief obtain the transposed of the Jacobian's inverse
       *
       *  The Jacobian's inverse is defined as a pseudo-inverse. If we denote
       *  the Jacobian by \f$J(x)\f$, the following condition holds:
       *  \f[J^{-1}(x) J(x) = I.\f]
       */
      const JacobianInverseTransposed &jacobianInverseTransposed ( const LocalCoordinate &local ) const { return mapping_.jacobianInverseTransposed( local ); }

      This *clone () const { return new This( *this ); }
      This *clone ( char *mappingStorage ) const { return new( mappingStorage ) This( *this ); }

      template< int codim >
      typename Codim< codim >::Trace *trace ( unsigned int i, char *mappingStorage ) const
      {
        return TraceProvider< Topology, GeometryTraits, codim, false >::construct( mapping_.mapping(), i, mappingStorage );
      }

      const UserData &userData () const { return userData_; }
      UserData &userData () { return userData_; }

    private:
      UserData userData_;
      Mapping mapping_;
    };

  } // namespace GenericGeometry
  
} // namespace Dune

#endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_HYBRIDMAPPING_HH