This file is indexed.

/usr/include/dune/localfunctions/lagrange/pyramidp2/pyramidp2localbasis.hh is in libdune-localfunctions-dev 2.3.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
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
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_PYRAMID_P2_LOCALBASIS_HH
#define DUNE_PYRAMID_P2_LOCALBASIS_HH

#include <dune/common/fmatrix.hh>

#include <dune/localfunctions/common/localbasis.hh>

namespace Dune
{
  /**@ingroup LocalBasisImplementation
     \brief Quadratic Lagrange shape functions on the pyramid.

     Defines the quadratic shape functions on pyramid.
     Taken from
     Liping Liu, Kevin B. Davies, Michal Krizek, and Li Guan:
     On Higher Order Pyramidal Finite Elements
     Adv. Appl. Math. Mech., Vol. 3, No. 2, pp. 131-140, 2011

     \tparam D Type to represent the field in the domain.
     \tparam R Type to represent the field in the range.

     \nosubgrouping
   */
  template<class D, class R>
  class PyramidP2LocalBasis
  {
  public:
    //! \brief export type traits for function signature
    typedef LocalBasisTraits<D,3,Dune::FieldVector<D,3>,R,1,Dune::FieldVector<R,1>,
        Dune::FieldMatrix<R,1,3> > Traits;

    //! \brief number of shape functions
    unsigned int size () const
    {
      return 14;
    }

    //! \brief Evaluate all shape functions
    inline void evaluateFunction (const typename Traits::DomainType& in,
                                  std::vector<typename Traits::RangeType>& out) const
    {
      out.resize(14);

      // transform to reference element with base [-1,1]^2
      const R x = 2.0*in[0] + in[2] - 1.0;
      const R y = 2.0*in[1] + in[2] - 1.0;
      const R z = in[2];

      if (x > y)
      {
        // vertices
        out[0] = 0.25*(x + z)*(x + z - 1)*(y - z - 1)*(y - z);
        out[1] = -0.25*(x + z)*(y - z)*((x + z + 1)*(-y + z + 1) - 4*z) - z*(x - y);
        out[2] = 0.25*(x + z)*(y - z)*(y - z + 1)*(x + z - 1);
        out[3] = 0.25*(y - z)*(x + z)*(y - z + 1)*(x + z + 1);
        out[4] = z*(2*z - 1);

        // lower edges
        out[5] = -0.5*(y - z + 1)*(x + z - 1)*((y - 1)*(x + 1) + z*(x - y + z + 1));
        out[6] = -0.5*(y - z + 1)*(((x + z + 1)*(y - 1)*x - z) + z*(2*y + 1));
        out[7] = -0.5*(x + z - 1)*(((y - z - 1)*(x + 1)*y - z) + z*(2*x + 1));
        out[8] = -0.5*(y - z + 1)*(x + z - 1)*(x + 1)*y;

        // upper edges
        out[9] = z*(x + z - 1)*(y - z - 1);
        out[10] = -z*((x + z + 1)*(y - z - 1) + 4*z);
        out[11] = -z*(y - z + 1)*(x + z - 1);
        out[12] = z*(y - z + 1)*(x + z + 1);

        // base face
        out[13] = (y - z + 1)*(x + z - 1)*((y - 1)*(x + 1) + z*(x - y + z + 1));
      }
      else
      {
        // vertices
        out[0] = 0.25*(y + z)*(y + z - 1)*(x - z - 1)*(x - z);
        out[1] = -0.25*(x - z)*(y + z)*(x - z + 1)*(-y - z + 1);
        out[2] = 0.25*(x - z)*(y + z)*((x - z - 1)*(y + z + 1) + 4*z) + z*(x - y);
        out[3] = 0.25*(y + z)*(x - z)*(x - z + 1)*(y + z + 1);
        out[4] = z*(2*z - 1);

        // lower edges
        out[5] = -0.5*(y + z - 1)*(((x - z - 1)*(y + 1)*x - z) + z*(2*y + 1));
        out[6] = -0.5*(x - z + 1)*(y + z - 1)*(y + 1)*x;
        out[7] = -0.5*(x - z + 1)*(y + z - 1)*(x - 1)*y;
        out[8] = -0.5*(x - z + 1)*(((y + z + 1)*(x - 1)*y - z) + z*(2*x + 1));

        // upper edges
        out[9] = z*(y + z - 1)*(x - z - 1);
        out[10] = -z*(x - z + 1)*(y + z - 1);
        out[11] = -z*((y + z + 1)*(x - z - 1) + 4*z);
        out[12] = z*(x - z + 1)*(y + z + 1);

        // base face
        out[13] = (x - z + 1)*(y + z - 1)*((y + 1)*(x - 1) - z*(x - y - z - 1));
      }
    }

    //! \brief Evaluate Jacobian of all shape functions
    inline void
    evaluateJacobian (const typename Traits::DomainType& in,         // position
                      std::vector<typename Traits::JacobianType>& out) const      // return value
    {
      out.resize(14);

      // transform to reference element with base [-1,1]^2
      const R x = 2.0*in[0] + in[2] - 1.0;
      const R y = 2.0*in[1] + in[2] - 1.0;
      const R z = in[2];

      // transformation of the gradient leads to a multiplication
      // with the Jacobian [2 0 0; 0 2 0; 1 1 1]
      if (x > y)
      {
        // vertices
        out[0][0][0] = 0.5*(y - z - 1)*(y - z)*(2*x + 2*z - 1);
        out[0][0][1] = 0.5*(x + z)*(x + z - 1)*(2*y - 2*z - 1);
        out[0][0][2] = 0.5*(out[0][0][0] + out[0][0][1])
                       + 0.25*((2*x + 2*z - 1)*(y - z - 1)*(y - z)
                               + (x + z)*(x + z - 1)*(-2*y + 2*z + 1));

        out[1][0][0] = 2*(-0.25*((y - z)*((x + z + 1)*(-y + z + 1) - 4*z)
                                 + (x + z)*(y - z)*(-y + z + 1)) - z);
        out[1][0][1] = 2*(-0.25*((x + z)*((x + z + 1)*(-y + z + 1) - 4*z)
                                 + (x + z)*(y - z)*(-(x + z + 1))) + z);
        out[1][0][2] = 0.5*(out[1][0][0] + out[1][0][1])
                       - 0.25*((y - z)*((x + z + 1)*(-y + z + 1) - 4*z)
                               - (x + z)*((x + z + 1)*(-y + z + 1) - 4*z)
                               + (x + z)*(y - z)*(x - y + 2*z - 2))
                       - (x - y);

        out[2][0][0] = 0.5*(y - z)*(y - z + 1)*(2*x + 2*z - 1);
        out[2][0][1] = 0.5*(x + z)*(2*y - 2*z + 1)*(x + z - 1);
        out[2][0][2] = 0.5*(out[2][0][0] + out[2][0][1])
                       + 0.25*((y - x - 2*z)*(y - z + 1)*(x + z - 1)
                               + (x + z)*(y - z)*(y - x - 2*z + 2));

        out[3][0][0] = 0.5*(y - z)*(2*x + 2*z + 1)*(y - z + 1);
        out[3][0][1] = 0.5*(2*y - 2*z + 1)*(x + z)*(x + z + 1);
        out[3][0][2] = 0.5*(out[3][0][0] + out[3][0][1])
                       + 0.25*((y - x - 2*z)*(y - z + 1)*(x + z + 1)
                               + (y - z)*(x + z)*(y - x - 2*z));

        out[4][0][0] = 0;
        out[4][0][1] = 0;
        out[4][0][2] = 4*z - 1;

        // lower edges
        out[5][0][0] = -((y - z + 1)*((y - 1)*(x + 1) + z*(x - y + z + 1))
                         + (y - z + 1)*(x + z - 1)*((y - 1) + z));
        out[5][0][1] = -((x + z - 1)*((y - 1)*(x + 1) + z*(x - y + z + 1))
                         + (y - z + 1)*(x + z - 1)*((x + 1) - z));
        out[5][0][2] = 0.5*(out[5][0][0] + out[5][0][1])
                       - 0.5*((-x + y - 2*z + 2)*((y - 1)*(x + 1) + z*(x - y + z + 1))
                              + (y - z + 1)*(x + z - 1)*(x - y + 2*z + 1));

        out[6][0][0] = -(y - z + 1)*(2*x + z + 1)*(y - 1);
        out[6][0][1] = -(((x + z + 1)*(y - 1)*x - z) + z*(2*y + 1)
                         + (y - z + 1)*((x + z + 1)*x + 2*z));
        out[6][0][2] = 0.5*(out[6][0][0] + out[6][0][1])
                       - 0.5*(-(((x + z + 1)*(y - 1)*x - z) + z*(2*y + 1))
                              + (y - z + 1)*(((y - 1)*x - 1) + 2*y + 1));

        out[7][0][0] = -(((y - z - 1)*(x + 1)*y - z) + z*(2*x + 1)
                         + (x + z - 1)*((y - z - 1)*y + 2*z));
        out[7][0][1] = -(x + z - 1)*(2*y - z - 1)*(x + 1);
        out[7][0][2] = 0.5*(out[7][0][0] + out[7][0][1])
                       - 0.5*(((y - z - 1)*(x + 1)*y - z) + z*(2*x + 1)
                              + (x + z - 1)*((-(x + 1)*y - 1) + 2*x + 1));

        out[8][0][0] = -(y - z + 1)*(2*x + z)*y;
        out[8][0][1] = -(2*y - z + 1)*(x + z - 1)*(x + 1);
        out[8][0][2] = 0.5*(out[8][0][0] + out[8][0][1])
                       - 0.5*(-x + y - 2*z + 2)*(x + 1)*y;

        // upper edges
        out[9][0][0] = 2*z*(y - z - 1);
        out[9][0][1] = 2*z*(x + z - 1);
        out[9][0][2] = 0.5*(out[9][0][0] + out[9][0][1])
                       + (x + z - 1)*(y - z - 1) + z*(-x + y - 2*z);

        out[10][0][0] = -2*z*(y - z - 1);
        out[10][0][1] = -2*z*(x + z + 1);
        out[10][0][2] = 0.5*(out[10][0][0] + out[10][0][1])
                        - ((x + z + 1)*(y - z - 1) + 4*z)
                        - z*(-x + y - 2*z + 2);

        out[11][0][0] = -2*z*(y - z + 1);
        out[11][0][1] = -2*z*(x + z - 1);
        out[11][0][2] = 0.5*(out[11][0][0] + out[11][0][1])
                        - (y - z + 1)*(x + z - 1) - z*(-x + y - 2*z + 2);

        out[12][0][0] = 2*z*(y - z + 1);
        out[12][0][1] = 2*z*(x + z + 1);
        out[12][0][2] = 0.5*(out[12][0][0] + out[12][0][1])
                        + (y - z + 1)*(x + z + 1) + z*(-x + y - 2*z);

        // base face
        out[13][0][0] = 2*((y - z + 1)*((y - 1)*(x + 1) + z*(x - y + z + 1))
                           + (y - z + 1)*(x + z - 1)*(y - 1 + z));
        out[13][0][1] = 2*((x + z - 1)*((y - 1)*(x + 1) + z*(x - y + z + 1))
                           + (y - z + 1)*(x + z - 1)*(x + 1 - z));
        out[13][0][2] = 0.5*(out[13][0][0] + out[13][0][1])
                        + ((-x + y - 2*z + 2)*((y - 1)*(x + 1) + z*(x - y + z + 1))
                           + (y - z + 1)*(x + z - 1)*(x - y + 2*z + 1));
      }
      else
      {
        // vertices
        out[0][0][0] = 0.5*(y + z)*(y + z - 1)*(2*x - 2*z - 1);
        out[0][0][1] = 0.5*(2*y + 2*z - 1)*(x - z - 1)*(x - z);
        out[0][0][2] = 0.5*(out[0][0][0] + out[0][0][1])
                       + 0.25*((2*y + 2*z - 1)*(x - z - 1)*(x - z)
                               + (y + z)*(y + z - 1)*(-2*x + 2*z + 1));

        out[1][0][0] = -0.5*(y + z)*(2*x - 2*z + 1)*(-y - z + 1);
        out[1][0][1] = -0.5*(x - z)*(x - z + 1)*(-2*y - 2*z + 1);
        out[1][0][2] = 0.5*(out[1][0][0] + out[1][0][1])
                       - 0.25*((x - y - 2*z)*(x - z + 1)*(-y - z + 1)
                               + (x - z)*(y + z)*(-x + y + 2*z - 2));

        out[2][0][0] = 0.5*((y + z)*((x - z - 1)*(y + z + 1) + 4*z)
                            + (x - z)*(y + z)*(y + z + 1) + 4*z);
        out[2][0][1] = 0.5*((x - z)*((x - z - 1)*(y + z + 1) + 4*z)
                            + (x - z)*(y + z)*(x - z - 1) - 4*z);
        out[2][0][2] = 0.5*(out[2][0][0] + out[2][0][1])
                       + 0.25*((x - y - 2*z)*((x - z - 1)*(y + z + 1) + 4*z)
                               + (x - z)*(y + z)*(x - y - 2*z + 2) + 4*(x - y));

        out[3][0][0] = 0.5*(y + z)*(2*x - 2*z + 1)*(y + z + 1);
        out[3][0][1] = 0.5*(x - z)*(x - z + 1)*(2*y + 2*z + 1);
        out[3][0][2] = 0.5*(out[3][0][0] + out[3][0][1])
                       + 0.25*((x - y - 2*z)*(x - z + 1)*(y + z + 1)
                               + (y + z)*(x - z)*(x - y - 2*z));

        out[4][0][0] = 0;
        out[4][0][1] = 0;
        out[4][0][2] = 4*z - 1;

        // lower edges
        out[5][0][0] = -(y + z - 1)*(2*x - z - 1)*(y + 1);
        out[5][0][1] = -(((x - z - 1)*(y + 1)*x - z) + z*(2*y + 1)
                         + (y + z - 1)*((x - z - 1)*x + 2*z));
        out[5][0][2] = 0.5*(out[5][0][0] + out[5][0][1])
                       - 0.5*((((x - z - 1)*(y + 1)*x - z) + z*(2*y + 1))
                              + (y + z - 1)*((-(y + 1)*x - 1) + 2*y + 1));

        out[6][0][0] = -(2*x - z + 1)*(y + z - 1)*(y + 1);
        out[6][0][1] = -(x - z + 1)*(2*y + z)*x;
        out[6][0][2] = 0.5*(out[6][0][0] + out[6][0][1])
                       - 0.5*(x - y - 2*z + 2)*(y + 1)*x;

        out[7][0][0] = -(2*x - z)*(y + z - 1)*y;
        out[7][0][1] = -(x - z + 1)*(2*y + z - 1)*(x - 1);
        out[7][0][2] = 0.5*(out[7][0][0] + out[7][0][1])
                       - 0.5*(x - y - 2*z + 2)*(x - 1)*y;

        out[8][0][0] = -(((y + z + 1)*(x - 1)*y - z) + z*(2*x + 1)
                         + (x - z + 1)*((y + z + 1)*y + 2*z));
        out[8][0][1] = -(x - z + 1)*(2*y + z + 1)*(x - 1);
        out[8][0][2] = 0.5*(out[8][0][0] + out[8][0][1])
                       - 0.5*(-(((y + z + 1)*(x - 1)*y - z) + z*(2*x + 1))
                              + (x - z + 1)*(((x - 1)*y - 1) + 2*x + 1));

        // upper edges
        out[9][0][0] = 2*z*(y + z - 1);
        out[9][0][1] = 2*z*(x - z - 1);
        out[9][0][2] = 0.5*(out[9][0][0] + out[9][0][1])
                       + (y + z - 1)*(x - z - 1) + z*(x - y - 2*z);

        out[10][0][0] = -2*z*(y + z - 1);
        out[10][0][1] = -2*z*(x - z + 1);
        out[10][0][2] = 0.5*(out[10][0][0] + out[10][0][1])
                        - (x - z + 1)*(y + z - 1) - z*(x - y - 2*z + 2);

        out[11][0][0] = -2*z*(y + z + 1);
        out[11][0][1] = -2*z*(x - z - 1);
        out[11][0][2] = 0.5*(out[11][0][0] + out[11][0][1])
                        - ((y + z + 1)*(x - z - 1) + 4*z) - z*(x - y - 2*z + 2);

        out[12][0][0] = 2*z*(y + z + 1);
        out[12][0][1] = 2*z*(x - z + 1);
        out[12][0][2] = 0.5*(out[12][0][0] + out[12][0][1])
                        + (x - z + 1)*(y + z + 1) + z*(x - y - 2*z);

        // base face
        out[13][0][0] = 2*((y + z - 1)*((y + 1)*(x - 1) - z*(x - y - z - 1))
                           + (x - z + 1)*(y + z - 1)*(y + 1 - z));
        out[13][0][1] = 2*((x - z + 1)*((y + 1)*(x - 1) - z*(x - y - z - 1))
                           + (x - z + 1)*(y + z - 1)*(x - 1 + z));
        out[13][0][2] = 0.5*(out[13][0][0] + out[13][0][1])
                        + (x - y - 2*z + 2)*((y + 1)*(x - 1) - z*(x - y - z - 1))
                        + (x - z + 1)*(y + z - 1)*(-(x - y - 2*z - 1));
      }
    }

    //! \brief Polynomial order of the shape functions
    unsigned int order () const
    {
      return 2;
    }
  };
}
#endif