This file is indexed.

/usr/include/dune/localfunctions/utility/l2interpolation.hh is in libdune-localfunctions-dev 2.5.1-1.

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
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_L2INTERPOLATION_HH
#define DUNE_L2INTERPOLATION_HH

#include <dune/geometry/topologyfactory.hh>
#include <dune/geometry/quadraturerules.hh>

#include <dune/localfunctions/utility/lfematrix.hh>

namespace Dune
{
  /**
   * @brief A local L2 interpolation taking a test basis and a quadrature
   *        rule.
   *
   * This class computes a local interpolation where the coefficients
   * are of the form:
   *     c = M^{-1}b
   * - M is the mass matrix with respect to the given basis and
   * - b = int f phi (where phi are the basis functions).
   * Thus the resulting local function u=c.varphi is defined through
   * the l2 interpolation int u phi = in f phi for all phi in the
   * base function set.
   * The third template argument can be used to specify that the
   * mass matrix is the unit matrix (onb=true).
   **/
  template< class B, class Q, bool onb >
  struct LocalL2Interpolation;

  template< class B, class Q >
  class LocalL2InterpolationBase
  {
    typedef LocalL2InterpolationBase< B, Q > This;

  public:
    typedef B Basis;
    typedef Q Quadrature;

    static const unsigned int dimension = Basis::dimension;

    template< class Function, class DofField >
    void interpolate ( const Function &function, std::vector< DofField > &coefficients ) const
    {
      typedef typename Quadrature::iterator Iterator;
      typedef FieldVector< DofField, Basis::dimRange > RangeVector;

      const unsigned int size = basis().size();
      static std::vector< RangeVector > basisValues( size );

      coefficients.resize( size );
      basisValues.resize( size );
      for( unsigned int i = 0; i < size; ++i )
        coefficients[ i ] = Zero< DofField >();

      const Iterator end = quadrature().end();
      for( Iterator it = quadrature().begin(); it != end; ++it )
      {
        basis().evaluate( it->position(), basisValues );
        typename Function::RangeType val;
        function.evaluate( field_cast<typename Function::DomainType::field_type>(it->position()), val );
        RangeVector factor = field_cast< DofField >( val );
        factor *= field_cast< DofField >( it->weight() );
        for( unsigned int i = 0; i < size; ++i )
          coefficients[ i ] += factor * basisValues[ i ];
      }
    }

    const Basis &basis () const
    {
      return basis_;
    }

    const Quadrature &quadrature () const
    {
      return quadrature_;
    }

  protected:
    LocalL2InterpolationBase ( const Basis &basis, const Quadrature &quadrature )
      : basis_( basis ),
        quadrature_( quadrature )
    {}

    const Basis &basis_;
    const Quadrature &quadrature_;
  };

  template< class B, class Q >
  struct LocalL2Interpolation<B,Q,true>
    : public LocalL2InterpolationBase<B,Q>
  {
    typedef LocalL2InterpolationBase<B,Q> Base;
    template< class BasisFactory, bool onb >
    friend class LocalL2InterpolationFactory;
    using typename Base::Basis;
    using typename Base::Quadrature;
  private:
    LocalL2Interpolation ( const typename Base::Basis &basis, const typename Base::Quadrature &quadrature )
      : Base(basis,quadrature)
    {}
  };
  template< class B, class Q >
  struct LocalL2Interpolation<B,Q,false>
    : public LocalL2InterpolationBase<B,Q>
  {
    typedef LocalL2InterpolationBase<B,Q> Base;
    template< class BasisFactory, bool onb >
    friend class LocalL2InterpolationFactory;
    using typename Base::Basis;
    using typename Base::Quadrature;
    template< class Function, class DofField >
    void interpolate ( const Function &function, std::vector< DofField > &coefficients ) const
    {
      const unsigned size = Base::basis().size();
      Base::interpolate(function,val_);
      coefficients.resize( size );
      for (unsigned int i=0; i<size; ++i)
      {
        coefficients[i] = 0;
        for (unsigned int j=0; j<size; ++j)
        {
          coefficients[i] += field_cast<DofField>(massMatrix_(i,j)*val_[j]);
        }
      }
    }
  private:
    LocalL2Interpolation ( const typename Base::Basis &basis, const typename Base::Quadrature &quadrature )
      : Base(basis,quadrature),
        val_(basis.size()),
        massMatrix_()
    {
      typedef FieldVector< Field, Base::Basis::dimRange > RangeVector;
      typedef typename Base::Quadrature::iterator Iterator;
      const unsigned size = basis.size();
      std::vector< RangeVector > basisValues( size );

      massMatrix_.resize( size,size );
      for (unsigned int i=0; i<size; ++i)
        for (unsigned int j=0; j<size; ++j)
          massMatrix_(i,j) = 0;
      const Iterator end = Base::quadrature().end();
      for( Iterator it = Base::quadrature().begin(); it != end; ++it )
      {
        Base::basis().evaluate( it->position(), basisValues );
        for (unsigned int i=0; i<size; ++i)
          for (unsigned int j=0; j<size; ++j)
            massMatrix_(i,j) += (basisValues[i]*basisValues[j])*it->weight();
      }
      if ( !massMatrix_.invert() )
      {
        DUNE_THROW(MathError, "Mass matrix singular in LocalL2Interpolation");
      }

    }
    typedef typename Base::Basis::StorageField Field;
    typedef FieldVector< Field, Base::Basis::dimRange > RangeVector;
    typedef LFEMatrix<Field> MassMatrix;
    mutable std::vector<Field> val_;
    MassMatrix massMatrix_;
  };

  /**
   * @brief A factory class for the local l2 interpolations
   *        taking a basis factory.
   **/
  template< class BasisFactory, bool onb >
  struct LocalL2InterpolationFactory;
  template< class BasisFactory, bool onb >
  struct LocalL2InterpolationFactoryTraits
  {
    static const unsigned int dimension = BasisFactory::dimension;
    // typedef typename BasisFactory::StorageField Field;
    typedef double Field;
    typedef QuadratureRule<Field,dimension> Quadrature;
    typedef QuadratureRules<Field,dimension> QuadratureProvider;

    typedef typename BasisFactory::Key Key;
    typedef typename BasisFactory::Object Basis;
    typedef LocalL2Interpolation< Basis, Quadrature, onb > LocalInterpolation;
    typedef const LocalInterpolation Object;
    typedef LocalL2InterpolationFactory<BasisFactory,onb> Factory;
  };

  template< class BasisFactory, bool onb >
  struct LocalL2InterpolationFactory :
    public TopologyFactory< LocalL2InterpolationFactoryTraits<BasisFactory,onb> >
  {
    typedef LocalL2InterpolationFactoryTraits<BasisFactory,onb> Traits;
    static const unsigned int dimension = Traits::dimension;
    typedef typename Traits::Key Key;
    typedef typename Traits::Basis Basis;
    typedef typename Traits::Object Object;
    typedef typename Traits::Field Field;
    typedef typename Traits::Quadrature Quadrature;

    template< class Topology >
    static Object *createObject ( const Key &key )
    {
      Dune::GeometryType gt(Topology::id, Topology::dimension);
      const Basis *basis = BasisFactory::template create< Topology >( key );
      const Quadrature & quadrature = Traits::QuadratureProvider::rule(gt, 2*basis->order()+1);
      return new Object( *basis, quadrature );
    }
    static void release ( Object *object )
    {
      const Basis &basis = object->basis();
      BasisFactory::release( &basis );
      delete object;
    }
  };

}

#endif // #ifndef DUNE_L2INTERPOLATION_HH