~ubuntu-branches/ubuntu/natty/ffc/natty

« back to all changes in this revision

Viewing changes to test/regression/references/VectorLaplaceGradCurl.h

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2010-02-03 20:22:35 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100203202235-fe8d0kajuvgy2sqn
Tags: 0.9.0-1
* New upstream release.
* debian/control: Bump Standards-Version (no changes needed).
* Update debian/copyright and debian/copyright_hints.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This code conforms with the UFC specification version 1.4
 
2
// and was automatically generated by FFC version 0.9.0.
 
3
 
 
4
#ifndef __VECTORLAPLACEGRADCURL_H
 
5
#define __VECTORLAPLACEGRADCURL_H
 
6
 
 
7
#include <cmath>
 
8
#include <stdexcept>
 
9
#include <fstream>
 
10
#include <ufc.h>
 
11
 
 
12
/// This class defines the interface for a finite element.
 
13
 
 
14
class vectorlaplacegradcurl_finite_element_0: public ufc::finite_element
 
15
{
 
16
public:
 
17
 
 
18
  /// Constructor
 
19
  vectorlaplacegradcurl_finite_element_0() : ufc::finite_element()
 
20
  {
 
21
    // Do nothing
 
22
  }
 
23
 
 
24
  /// Destructor
 
25
  virtual ~vectorlaplacegradcurl_finite_element_0()
 
26
  {
 
27
    // Do nothing
 
28
  }
 
29
 
 
30
  /// Return a string identifying the finite element
 
31
  virtual const char* signature() const
 
32
  {
 
33
    return "FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2)";
 
34
  }
 
35
 
 
36
  /// Return the cell shape
 
37
  virtual ufc::shape cell_shape() const
 
38
  {
 
39
    return ufc::tetrahedron;
 
40
  }
 
41
 
 
42
  /// Return the dimension of the finite element function space
 
43
  virtual unsigned int space_dimension() const
 
44
  {
 
45
    return 10;
 
46
  }
 
47
 
 
48
  /// Return the rank of the value space
 
49
  virtual unsigned int value_rank() const
 
50
  {
 
51
    return 0;
 
52
  }
 
53
 
 
54
  /// Return the dimension of the value space for axis i
 
55
  virtual unsigned int value_dimension(unsigned int i) const
 
56
  {
 
57
    return 1;
 
58
  }
 
59
 
 
60
  /// Evaluate basis function i at given point in cell
 
61
  virtual void evaluate_basis(unsigned int i,
 
62
                              double* values,
 
63
                              const double* coordinates,
 
64
                              const ufc::cell& c) const
 
65
  {
 
66
    // Extract vertex coordinates
 
67
    const double * const * x = c.coordinates;
 
68
    
 
69
    // Compute Jacobian of affine map from reference cell
 
70
    const double J_00 = x[1][0] - x[0][0];
 
71
    const double J_01 = x[2][0] - x[0][0];
 
72
    const double J_02 = x[3][0] - x[0][0];
 
73
    const double J_10 = x[1][1] - x[0][1];
 
74
    const double J_11 = x[2][1] - x[0][1];
 
75
    const double J_12 = x[3][1] - x[0][1];
 
76
    const double J_20 = x[1][2] - x[0][2];
 
77
    const double J_21 = x[2][2] - x[0][2];
 
78
    const double J_22 = x[3][2] - x[0][2];
 
79
    
 
80
    // Compute sub determinants
 
81
    const double d_00 = J_11*J_22 - J_12*J_21;
 
82
    const double d_01 = J_12*J_20 - J_10*J_22;
 
83
    const double d_02 = J_10*J_21 - J_11*J_20;
 
84
    const double d_10 = J_02*J_21 - J_01*J_22;
 
85
    const double d_11 = J_00*J_22 - J_02*J_20;
 
86
    const double d_12 = J_01*J_20 - J_00*J_21;
 
87
    const double d_20 = J_01*J_12 - J_02*J_11;
 
88
    const double d_21 = J_02*J_10 - J_00*J_12;
 
89
    const double d_22 = J_00*J_11 - J_01*J_10;
 
90
    
 
91
    // Compute determinant of Jacobian
 
92
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
93
    
 
94
    // Compute inverse of Jacobian
 
95
    
 
96
    // Compute constants
 
97
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
98
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
99
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
100
    
 
101
    // Get coordinates and map to the reference (FIAT) element
 
102
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
103
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
104
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
105
    
 
106
    
 
107
    // Reset values
 
108
    *values = 0.00000000;
 
109
    
 
110
    // Map degree of freedom to element degree of freedom
 
111
    const unsigned int dof = i;
 
112
    
 
113
    // Array of basisvalues
 
114
    double basisvalues[10] = {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
115
    
 
116
    // Declare helper variables
 
117
    unsigned int rr = 0;
 
118
    unsigned int ss = 0;
 
119
    unsigned int tt = 0;
 
120
    double tmp5 = 0.00000000;
 
121
    double tmp6 = 0.00000000;
 
122
    double tmp7 = 0.00000000;
 
123
    double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
124
    double tmp1 = 0.25000000*(Y + Z)*(Y + Z);
 
125
    double tmp2 = 0.50000000*(1.00000000 + Z + 2.00000000*Y);
 
126
    double tmp3 = 0.50000000*(1.00000000 - Z);
 
127
    double tmp4 = tmp3*tmp3;
 
128
    
 
129
    // Compute basisvalues
 
130
    basisvalues[0] = 1.00000000;
 
131
    basisvalues[1] = tmp0;
 
132
    for (unsigned int r = 1; r < 2; r++)
 
133
    {
 
134
      rr = (r + 1)*((r + 1) + 1)*((r + 1) + 2)/6;
 
135
      ss = r*(r + 1)*(r + 2)/6;
 
136
      tt = (r - 1)*((r - 1) + 1)*((r - 1) + 2)/6;
 
137
      basisvalues[rr] = (basisvalues[ss]*tmp0*(1.00000000 + 2.00000000*r)/(1.00000000 + r) - basisvalues[tt]*tmp1*r/(1.00000000 + r));
 
138
    }// end loop over 'r'
 
139
    for (unsigned int r = 0; r < 2; r++)
 
140
    {
 
141
      rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
142
      ss = r*(r + 1)*(r + 2)/6;
 
143
      basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
144
    }// end loop over 'r'
 
145
    for (unsigned int r = 0; r < 1; r++)
 
146
    {
 
147
      for (unsigned int s = 1; s < 2 - r; s++)
 
148
      {
 
149
        rr = (r + (s + 1))*(r + (s + 1) + 1)*(r + (s + 1) + 2)/6 + (s + 1)*((s + 1) + 1)/2;
 
150
        ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
151
        tt = (r + (s - 1))*(r + (s - 1) + 1)*(r + (s - 1) + 2)/6 + (s - 1)*((s - 1) + 1)/2;
 
152
        tmp5 = (2.00000000 + 2.00000000*r + 2.00000000*s)*(3.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
153
        tmp6 = (1.00000000 + 4.00000000*r*r + 4.00000000*r)*(2.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
154
        tmp7 = (1.00000000 + s + 2.00000000*r)*(3.00000000 + 2.00000000*r + 2.00000000*s)*s/((1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
155
        basisvalues[rr] = (basisvalues[ss]*(tmp2*tmp5 + tmp3*tmp6) - basisvalues[tt]*tmp4*tmp7);
 
156
      }// end loop over 's'
 
157
    }// end loop over 'r'
 
158
    for (unsigned int r = 0; r < 2; r++)
 
159
    {
 
160
      for (unsigned int s = 0; s < 2 - r; s++)
 
161
      {
 
162
        rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
163
        ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
164
        basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
165
      }// end loop over 's'
 
166
    }// end loop over 'r'
 
167
    for (unsigned int r = 0; r < 1; r++)
 
168
    {
 
169
      for (unsigned int s = 0; s < 1 - r; s++)
 
170
      {
 
171
        for (unsigned int t = 1; t < 2 - r - s; t++)
 
172
        {
 
173
          rr = (r + s + t + 1)*(r + s + t + 1 + 1)*(r + s + t + 1 + 2)/6 + (s + t + 1)*(s + t + 1 + 1)/2 + t + 1;
 
174
          ss = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
175
          tt = (r + s + t - 1)*(r + s + t - 1 + 1)*(r + s + t - 1 + 2)/6 + (s + t - 1)*(s + t - 1 + 1)/2 + t - 1;
 
176
          tmp5 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)/(2.00000000*(1.00000000 + t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
177
          tmp6 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 4.00000000*r*r + 4.00000000*s*s + 8.00000000*r*s + 8.00000000*r + 8.00000000*s)/(2.00000000*(1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
178
          tmp7 = (2.00000000 + t + 2.00000000*r + 2.00000000*s)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*t/((1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
179
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Z*tmp5) - basisvalues[tt]*tmp7);
 
180
        }// end loop over 't'
 
181
      }// end loop over 's'
 
182
    }// end loop over 'r'
 
183
    for (unsigned int r = 0; r < 3; r++)
 
184
    {
 
185
      for (unsigned int s = 0; s < 3 - r; s++)
 
186
      {
 
187
        for (unsigned int t = 0; t < 3 - r - s; t++)
 
188
        {
 
189
          rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
190
          basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
191
        }// end loop over 't'
 
192
      }// end loop over 's'
 
193
    }// end loop over 'r'
 
194
    
 
195
    // Table(s) of coefficients
 
196
    static const double coefficients0[10][10] = \
 
197
    {{-0.05773503, -0.06085806, -0.03513642, -0.02484520, 0.06506000, 0.05039526, 0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
198
    {-0.05773503, 0.06085806, -0.03513642, -0.02484520, 0.06506000, -0.05039526, -0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
199
    {-0.05773503, 0.00000000, 0.07027284, -0.02484520, 0.00000000, 0.00000000, 0.00000000, 0.08728716, -0.04751311, 0.01679842},
 
200
    {-0.05773503, 0.00000000, 0.00000000, 0.07453560, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.10079053},
 
201
    {0.23094011, 0.00000000, 0.14054567, 0.09938080, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.11878277, -0.06719368},
 
202
    {0.23094011, 0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, 0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
203
    {0.23094011, 0.12171612, 0.07027284, -0.09938080, 0.00000000, 0.10079053, -0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
204
    {0.23094011, -0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, -0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
205
    {0.23094011, -0.12171612, 0.07027284, -0.09938080, 0.00000000, -0.10079053, 0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
206
    {0.23094011, 0.00000000, -0.14054567, -0.09938080, -0.13012001, 0.00000000, 0.00000000, 0.02909572, 0.02375655, 0.01679842}};
 
207
    
 
208
    // Compute value(s).
 
209
    for (unsigned int r = 0; r < 10; r++)
 
210
    {
 
211
      *values += coefficients0[dof][r]*basisvalues[r];
 
212
    }// end loop over 'r'
 
213
  }
 
214
 
 
215
  /// Evaluate all basis functions at given point in cell
 
216
  virtual void evaluate_basis_all(double* values,
 
217
                                  const double* coordinates,
 
218
                                  const ufc::cell& c) const
 
219
  {
 
220
    // Helper variable to hold values of a single dof.
 
221
    double dof_values = 0.00000000;
 
222
    
 
223
    // Loop dofs and call evaluate_basis.
 
224
    for (unsigned int r = 0; r < 10; r++)
 
225
    {
 
226
      evaluate_basis(r, &dof_values, coordinates, c);
 
227
      values[r] = dof_values;
 
228
    }// end loop over 'r'
 
229
  }
 
230
 
 
231
  /// Evaluate order n derivatives of basis function i at given point in cell
 
232
  virtual void evaluate_basis_derivatives(unsigned int i,
 
233
                                          unsigned int n,
 
234
                                          double* values,
 
235
                                          const double* coordinates,
 
236
                                          const ufc::cell& c) const
 
237
  {
 
238
    // Extract vertex coordinates
 
239
    const double * const * x = c.coordinates;
 
240
    
 
241
    // Compute Jacobian of affine map from reference cell
 
242
    const double J_00 = x[1][0] - x[0][0];
 
243
    const double J_01 = x[2][0] - x[0][0];
 
244
    const double J_02 = x[3][0] - x[0][0];
 
245
    const double J_10 = x[1][1] - x[0][1];
 
246
    const double J_11 = x[2][1] - x[0][1];
 
247
    const double J_12 = x[3][1] - x[0][1];
 
248
    const double J_20 = x[1][2] - x[0][2];
 
249
    const double J_21 = x[2][2] - x[0][2];
 
250
    const double J_22 = x[3][2] - x[0][2];
 
251
    
 
252
    // Compute sub determinants
 
253
    const double d_00 = J_11*J_22 - J_12*J_21;
 
254
    const double d_01 = J_12*J_20 - J_10*J_22;
 
255
    const double d_02 = J_10*J_21 - J_11*J_20;
 
256
    const double d_10 = J_02*J_21 - J_01*J_22;
 
257
    const double d_11 = J_00*J_22 - J_02*J_20;
 
258
    const double d_12 = J_01*J_20 - J_00*J_21;
 
259
    const double d_20 = J_01*J_12 - J_02*J_11;
 
260
    const double d_21 = J_02*J_10 - J_00*J_12;
 
261
    const double d_22 = J_00*J_11 - J_01*J_10;
 
262
    
 
263
    // Compute determinant of Jacobian
 
264
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
265
    
 
266
    // Compute inverse of Jacobian
 
267
    const double K_00 = d_00 / detJ;
 
268
    const double K_01 = d_10 / detJ;
 
269
    const double K_02 = d_20 / detJ;
 
270
    const double K_10 = d_01 / detJ;
 
271
    const double K_11 = d_11 / detJ;
 
272
    const double K_12 = d_21 / detJ;
 
273
    const double K_20 = d_02 / detJ;
 
274
    const double K_21 = d_12 / detJ;
 
275
    const double K_22 = d_22 / detJ;
 
276
    
 
277
    // Compute constants
 
278
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
279
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
280
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
281
    
 
282
    // Get coordinates and map to the reference (FIAT) element
 
283
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
284
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
285
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
286
    
 
287
    
 
288
    // Compute number of derivatives.
 
289
    unsigned int  num_derivatives = 1;
 
290
    
 
291
    for (unsigned int r = 0; r < n; r++)
 
292
    {
 
293
      num_derivatives *= 3;
 
294
    }// end loop over 'r'
 
295
    
 
296
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
297
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
298
    for (unsigned int row = 0; row < num_derivatives; row++)
 
299
    {
 
300
      combinations[row] = new unsigned int [n];
 
301
      for (unsigned int col = 0; col < n; col++)
 
302
        combinations[row][col] = 0;
 
303
    }
 
304
    
 
305
    // Generate combinations of derivatives
 
306
    for (unsigned int row = 1; row < num_derivatives; row++)
 
307
    {
 
308
      for (unsigned int num = 0; num < row; num++)
 
309
      {
 
310
        for (unsigned int col = n-1; col+1 > 0; col--)
 
311
        {
 
312
          if (combinations[row][col] + 1 > 2)
 
313
            combinations[row][col] = 0;
 
314
          else
 
315
          {
 
316
            combinations[row][col] += 1;
 
317
            break;
 
318
          }
 
319
        }
 
320
      }
 
321
    }
 
322
    
 
323
    // Compute inverse of Jacobian
 
324
    const double Jinv[3][3] = {{K_00, K_01, K_02}, {K_10, K_11, K_12}, {K_20, K_21, K_22}};
 
325
    
 
326
    // Declare transformation matrix
 
327
    // Declare pointer to two dimensional array and initialise
 
328
    double **transform = new double *[num_derivatives];
 
329
    
 
330
    for (unsigned int j = 0; j < num_derivatives; j++)
 
331
    {
 
332
      transform[j] = new double [num_derivatives];
 
333
      for (unsigned int k = 0; k < num_derivatives; k++)
 
334
        transform[j][k] = 1;
 
335
    }
 
336
    
 
337
    // Construct transformation matrix
 
338
    for (unsigned int row = 0; row < num_derivatives; row++)
 
339
    {
 
340
      for (unsigned int col = 0; col < num_derivatives; col++)
 
341
      {
 
342
        for (unsigned int k = 0; k < n; k++)
 
343
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
344
      }
 
345
    }
 
346
    
 
347
    // Reset values. Assuming that values is always an array.
 
348
    for (unsigned int r = 0; r < num_derivatives; r++)
 
349
    {
 
350
      values[r] = 0.00000000;
 
351
    }// end loop over 'r'
 
352
    
 
353
    // Map degree of freedom to element degree of freedom
 
354
    const unsigned int dof = i;
 
355
    
 
356
    // Array of basisvalues
 
357
    double basisvalues[10] = {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
358
    
 
359
    // Declare helper variables
 
360
    unsigned int rr = 0;
 
361
    unsigned int ss = 0;
 
362
    unsigned int tt = 0;
 
363
    double tmp5 = 0.00000000;
 
364
    double tmp6 = 0.00000000;
 
365
    double tmp7 = 0.00000000;
 
366
    double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
367
    double tmp1 = 0.25000000*(Y + Z)*(Y + Z);
 
368
    double tmp2 = 0.50000000*(1.00000000 + Z + 2.00000000*Y);
 
369
    double tmp3 = 0.50000000*(1.00000000 - Z);
 
370
    double tmp4 = tmp3*tmp3;
 
371
    
 
372
    // Compute basisvalues
 
373
    basisvalues[0] = 1.00000000;
 
374
    basisvalues[1] = tmp0;
 
375
    for (unsigned int r = 1; r < 2; r++)
 
376
    {
 
377
      rr = (r + 1)*((r + 1) + 1)*((r + 1) + 2)/6;
 
378
      ss = r*(r + 1)*(r + 2)/6;
 
379
      tt = (r - 1)*((r - 1) + 1)*((r - 1) + 2)/6;
 
380
      basisvalues[rr] = (basisvalues[ss]*tmp0*(1.00000000 + 2.00000000*r)/(1.00000000 + r) - basisvalues[tt]*tmp1*r/(1.00000000 + r));
 
381
    }// end loop over 'r'
 
382
    for (unsigned int r = 0; r < 2; r++)
 
383
    {
 
384
      rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
385
      ss = r*(r + 1)*(r + 2)/6;
 
386
      basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
387
    }// end loop over 'r'
 
388
    for (unsigned int r = 0; r < 1; r++)
 
389
    {
 
390
      for (unsigned int s = 1; s < 2 - r; s++)
 
391
      {
 
392
        rr = (r + (s + 1))*(r + (s + 1) + 1)*(r + (s + 1) + 2)/6 + (s + 1)*((s + 1) + 1)/2;
 
393
        ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
394
        tt = (r + (s - 1))*(r + (s - 1) + 1)*(r + (s - 1) + 2)/6 + (s - 1)*((s - 1) + 1)/2;
 
395
        tmp5 = (2.00000000 + 2.00000000*r + 2.00000000*s)*(3.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
396
        tmp6 = (1.00000000 + 4.00000000*r*r + 4.00000000*r)*(2.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
397
        tmp7 = (1.00000000 + s + 2.00000000*r)*(3.00000000 + 2.00000000*r + 2.00000000*s)*s/((1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
398
        basisvalues[rr] = (basisvalues[ss]*(tmp2*tmp5 + tmp3*tmp6) - basisvalues[tt]*tmp4*tmp7);
 
399
      }// end loop over 's'
 
400
    }// end loop over 'r'
 
401
    for (unsigned int r = 0; r < 2; r++)
 
402
    {
 
403
      for (unsigned int s = 0; s < 2 - r; s++)
 
404
      {
 
405
        rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
406
        ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
407
        basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
408
      }// end loop over 's'
 
409
    }// end loop over 'r'
 
410
    for (unsigned int r = 0; r < 1; r++)
 
411
    {
 
412
      for (unsigned int s = 0; s < 1 - r; s++)
 
413
      {
 
414
        for (unsigned int t = 1; t < 2 - r - s; t++)
 
415
        {
 
416
          rr = (r + s + t + 1)*(r + s + t + 1 + 1)*(r + s + t + 1 + 2)/6 + (s + t + 1)*(s + t + 1 + 1)/2 + t + 1;
 
417
          ss = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
418
          tt = (r + s + t - 1)*(r + s + t - 1 + 1)*(r + s + t - 1 + 2)/6 + (s + t - 1)*(s + t - 1 + 1)/2 + t - 1;
 
419
          tmp5 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)/(2.00000000*(1.00000000 + t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
420
          tmp6 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 4.00000000*r*r + 4.00000000*s*s + 8.00000000*r*s + 8.00000000*r + 8.00000000*s)/(2.00000000*(1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
421
          tmp7 = (2.00000000 + t + 2.00000000*r + 2.00000000*s)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*t/((1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
422
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Z*tmp5) - basisvalues[tt]*tmp7);
 
423
        }// end loop over 't'
 
424
      }// end loop over 's'
 
425
    }// end loop over 'r'
 
426
    for (unsigned int r = 0; r < 3; r++)
 
427
    {
 
428
      for (unsigned int s = 0; s < 3 - r; s++)
 
429
      {
 
430
        for (unsigned int t = 0; t < 3 - r - s; t++)
 
431
        {
 
432
          rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
433
          basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
434
        }// end loop over 't'
 
435
      }// end loop over 's'
 
436
    }// end loop over 'r'
 
437
    
 
438
    // Table(s) of coefficients
 
439
    static const double coefficients0[10][10] = \
 
440
    {{-0.05773503, -0.06085806, -0.03513642, -0.02484520, 0.06506000, 0.05039526, 0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
441
    {-0.05773503, 0.06085806, -0.03513642, -0.02484520, 0.06506000, -0.05039526, -0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
442
    {-0.05773503, 0.00000000, 0.07027284, -0.02484520, 0.00000000, 0.00000000, 0.00000000, 0.08728716, -0.04751311, 0.01679842},
 
443
    {-0.05773503, 0.00000000, 0.00000000, 0.07453560, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.10079053},
 
444
    {0.23094011, 0.00000000, 0.14054567, 0.09938080, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.11878277, -0.06719368},
 
445
    {0.23094011, 0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, 0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
446
    {0.23094011, 0.12171612, 0.07027284, -0.09938080, 0.00000000, 0.10079053, -0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
447
    {0.23094011, -0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, -0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
448
    {0.23094011, -0.12171612, 0.07027284, -0.09938080, 0.00000000, -0.10079053, 0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
449
    {0.23094011, 0.00000000, -0.14054567, -0.09938080, -0.13012001, 0.00000000, 0.00000000, 0.02909572, 0.02375655, 0.01679842}};
 
450
    
 
451
    // Tables of derivatives of the polynomial base (transpose).
 
452
    static const double dmats0[10][10] = \
 
453
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
454
    {6.32455532, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
455
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
456
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
457
    {0.00000000, 11.22497216, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
458
    {4.58257569, 0.00000000, 8.36660027, -1.18321596, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
459
    {3.74165739, 0.00000000, 0.00000000, 8.69482605, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
460
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
461
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
462
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
463
    
 
464
    static const double dmats1[10][10] = \
 
465
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
466
    {3.16227766, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
467
    {5.47722558, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
468
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
469
    {2.95803989, 5.61248608, -1.08012345, -0.76376262, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
470
    {2.29128785, 7.24568837, 4.18330013, -0.59160798, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
471
    {1.87082869, 0.00000000, 0.00000000, 4.34741302, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
472
    {-2.64575131, 0.00000000, 9.66091783, 0.68313005, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
473
    {3.24037035, 0.00000000, 0.00000000, 7.52994024, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
474
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
475
    
 
476
    static const double dmats2[10][10] = \
 
477
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
478
    {3.16227766, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
479
    {1.82574186, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
480
    {5.16397779, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
481
    {2.95803989, 5.61248608, -1.08012345, -0.76376262, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
482
    {2.29128785, 1.44913767, 4.18330013, -0.59160798, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
483
    {1.87082869, 7.09929574, 0.00000000, 4.34741302, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
484
    {1.32287566, 0.00000000, 3.86436713, -0.34156503, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
485
    {1.08012345, 0.00000000, 7.09929574, 2.50998008, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
486
    {-3.81881308, 0.00000000, 0.00000000, 8.87411967, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
487
    
 
488
    // Compute reference derivatives
 
489
    // Declare pointer to array of derivatives on FIAT element
 
490
    double *derivatives = new double [num_derivatives];
 
491
    for (unsigned int r = 0; r < num_derivatives; r++)
 
492
    {
 
493
      derivatives[r] = 0.00000000;
 
494
    }// end loop over 'r'
 
495
    
 
496
    // Declare derivative matrix (of polynomial basis).
 
497
    double dmats[10][10] = \
 
498
    {{1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
499
    {0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
500
    {0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
501
    {0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
502
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
503
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
504
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
505
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
506
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
507
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
508
    
 
509
    // Declare (auxiliary) derivative matrix (of polynomial basis).
 
510
    double dmats_old[10][10] = \
 
511
    {{1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
512
    {0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
513
    {0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
514
    {0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
515
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
516
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
517
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
518
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
519
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
520
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
521
    
 
522
    // Loop possible derivatives.
 
523
    for (unsigned int r = 0; r < num_derivatives; r++)
 
524
    {
 
525
      // Resetting dmats values to compute next derivative.
 
526
      for (unsigned int t = 0; t < 10; t++)
 
527
      {
 
528
        for (unsigned int u = 0; u < 10; u++)
 
529
        {
 
530
          dmats[t][u] = 0.00000000;
 
531
          if (t == u)
 
532
          {
 
533
          dmats[t][u] = 1.00000000;
 
534
          }
 
535
          
 
536
        }// end loop over 'u'
 
537
      }// end loop over 't'
 
538
      
 
539
      // Looping derivative order to generate dmats.
 
540
      for (unsigned int s = 0; s < n; s++)
 
541
      {
 
542
        // Updating dmats_old with new values and resetting dmats.
 
543
        for (unsigned int t = 0; t < 10; t++)
 
544
        {
 
545
          for (unsigned int u = 0; u < 10; u++)
 
546
          {
 
547
            dmats_old[t][u] = dmats[t][u];
 
548
            dmats[t][u] = 0.00000000;
 
549
          }// end loop over 'u'
 
550
        }// end loop over 't'
 
551
        
 
552
        // Update dmats using an inner product.
 
553
        if (combinations[r][s] == 0)
 
554
        {
 
555
        for (unsigned int t = 0; t < 10; t++)
 
556
        {
 
557
          for (unsigned int u = 0; u < 10; u++)
 
558
          {
 
559
            for (unsigned int tu = 0; tu < 10; tu++)
 
560
            {
 
561
              dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
562
            }// end loop over 'tu'
 
563
          }// end loop over 'u'
 
564
        }// end loop over 't'
 
565
        }
 
566
        
 
567
        if (combinations[r][s] == 1)
 
568
        {
 
569
        for (unsigned int t = 0; t < 10; t++)
 
570
        {
 
571
          for (unsigned int u = 0; u < 10; u++)
 
572
          {
 
573
            for (unsigned int tu = 0; tu < 10; tu++)
 
574
            {
 
575
              dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
576
            }// end loop over 'tu'
 
577
          }// end loop over 'u'
 
578
        }// end loop over 't'
 
579
        }
 
580
        
 
581
        if (combinations[r][s] == 2)
 
582
        {
 
583
        for (unsigned int t = 0; t < 10; t++)
 
584
        {
 
585
          for (unsigned int u = 0; u < 10; u++)
 
586
          {
 
587
            for (unsigned int tu = 0; tu < 10; tu++)
 
588
            {
 
589
              dmats[t][u] += dmats2[t][tu]*dmats_old[tu][u];
 
590
            }// end loop over 'tu'
 
591
          }// end loop over 'u'
 
592
        }// end loop over 't'
 
593
        }
 
594
        
 
595
      }// end loop over 's'
 
596
      for (unsigned int s = 0; s < 10; s++)
 
597
      {
 
598
        for (unsigned int t = 0; t < 10; t++)
 
599
        {
 
600
          derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
 
601
        }// end loop over 't'
 
602
      }// end loop over 's'
 
603
    }// end loop over 'r'
 
604
    
 
605
    // Transform derivatives back to physical element
 
606
    for (unsigned int row = 0; row < num_derivatives; row++)
 
607
    {
 
608
      for (unsigned int col = 0; col < num_derivatives; col++)
 
609
      {
 
610
        values[row] += transform[row][col]*derivatives[col];
 
611
      }
 
612
    }
 
613
    
 
614
    // Delete pointer to array of derivatives on FIAT element
 
615
    delete [] derivatives;
 
616
    
 
617
    // Delete pointer to array of combinations of derivatives and transform
 
618
    for (unsigned int r = 0; r < num_derivatives; r++)
 
619
    {
 
620
      delete [] combinations[r];
 
621
      delete [] transform[r];
 
622
    }// end loop over 'r'
 
623
    delete [] combinations;
 
624
    delete [] transform;
 
625
  }
 
626
 
 
627
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
628
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
629
                                              double* values,
 
630
                                              const double* coordinates,
 
631
                                              const ufc::cell& c) const
 
632
  {
 
633
    // Compute number of derivatives.
 
634
    unsigned int  num_derivatives = 1;
 
635
    
 
636
    for (unsigned int r = 0; r < n; r++)
 
637
    {
 
638
      num_derivatives *= 3;
 
639
    }// end loop over 'r'
 
640
    
 
641
    // Helper variable to hold values of a single dof.
 
642
    double *dof_values = new double [num_derivatives];
 
643
    for (unsigned int r = 0; r < num_derivatives; r++)
 
644
    {
 
645
      dof_values[r] = 0.00000000;
 
646
    }// end loop over 'r'
 
647
    
 
648
    // Loop dofs and call evaluate_basis_derivatives.
 
649
    for (unsigned int r = 0; r < 10; r++)
 
650
    {
 
651
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
652
      for (unsigned int s = 0; s < num_derivatives; s++)
 
653
      {
 
654
        values[r*num_derivatives + s] = dof_values[s];
 
655
      }// end loop over 's'
 
656
    }// end loop over 'r'
 
657
    
 
658
    // Delete pointer.
 
659
    delete [] dof_values;
 
660
  }
 
661
 
 
662
  /// Evaluate linear functional for dof i on the function f
 
663
  virtual double evaluate_dof(unsigned int i,
 
664
                              const ufc::function& f,
 
665
                              const ufc::cell& c) const
 
666
  {
 
667
    // Declare variables for result of evaluation
 
668
    double vals[1];
 
669
    
 
670
    // Declare variable for physical coordinates
 
671
    double y[3];
 
672
    
 
673
    const double * const * x = c.coordinates;
 
674
    switch (i)
 
675
    {
 
676
    case 0:
 
677
      {
 
678
        y[0] = x[0][0];
 
679
      y[1] = x[0][1];
 
680
      y[2] = x[0][2];
 
681
      f.evaluate(vals, y, c);
 
682
      return vals[0];
 
683
        break;
 
684
      }
 
685
    case 1:
 
686
      {
 
687
        y[0] = x[1][0];
 
688
      y[1] = x[1][1];
 
689
      y[2] = x[1][2];
 
690
      f.evaluate(vals, y, c);
 
691
      return vals[0];
 
692
        break;
 
693
      }
 
694
    case 2:
 
695
      {
 
696
        y[0] = x[2][0];
 
697
      y[1] = x[2][1];
 
698
      y[2] = x[2][2];
 
699
      f.evaluate(vals, y, c);
 
700
      return vals[0];
 
701
        break;
 
702
      }
 
703
    case 3:
 
704
      {
 
705
        y[0] = x[3][0];
 
706
      y[1] = x[3][1];
 
707
      y[2] = x[3][2];
 
708
      f.evaluate(vals, y, c);
 
709
      return vals[0];
 
710
        break;
 
711
      }
 
712
    case 4:
 
713
      {
 
714
        y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
715
      y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
716
      y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
717
      f.evaluate(vals, y, c);
 
718
      return vals[0];
 
719
        break;
 
720
      }
 
721
    case 5:
 
722
      {
 
723
        y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
724
      y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
725
      y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
726
      f.evaluate(vals, y, c);
 
727
      return vals[0];
 
728
        break;
 
729
      }
 
730
    case 6:
 
731
      {
 
732
        y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
733
      y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
734
      y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
735
      f.evaluate(vals, y, c);
 
736
      return vals[0];
 
737
        break;
 
738
      }
 
739
    case 7:
 
740
      {
 
741
        y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
742
      y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
743
      y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
744
      f.evaluate(vals, y, c);
 
745
      return vals[0];
 
746
        break;
 
747
      }
 
748
    case 8:
 
749
      {
 
750
        y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
751
      y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
752
      y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
753
      f.evaluate(vals, y, c);
 
754
      return vals[0];
 
755
        break;
 
756
      }
 
757
    case 9:
 
758
      {
 
759
        y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
760
      y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
761
      y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
762
      f.evaluate(vals, y, c);
 
763
      return vals[0];
 
764
        break;
 
765
      }
 
766
    }
 
767
    
 
768
    return 0.0;
 
769
  }
 
770
 
 
771
  /// Evaluate linear functionals for all dofs on the function f
 
772
  virtual void evaluate_dofs(double* values,
 
773
                             const ufc::function& f,
 
774
                             const ufc::cell& c) const
 
775
  {
 
776
    // Declare variables for result of evaluation
 
777
    double vals[1];
 
778
    
 
779
    // Declare variable for physical coordinates
 
780
    double y[3];
 
781
    
 
782
    const double * const * x = c.coordinates;
 
783
    y[0] = x[0][0];
 
784
    y[1] = x[0][1];
 
785
    y[2] = x[0][2];
 
786
    f.evaluate(vals, y, c);
 
787
    values[0] = vals[0];
 
788
    y[0] = x[1][0];
 
789
    y[1] = x[1][1];
 
790
    y[2] = x[1][2];
 
791
    f.evaluate(vals, y, c);
 
792
    values[1] = vals[0];
 
793
    y[0] = x[2][0];
 
794
    y[1] = x[2][1];
 
795
    y[2] = x[2][2];
 
796
    f.evaluate(vals, y, c);
 
797
    values[2] = vals[0];
 
798
    y[0] = x[3][0];
 
799
    y[1] = x[3][1];
 
800
    y[2] = x[3][2];
 
801
    f.evaluate(vals, y, c);
 
802
    values[3] = vals[0];
 
803
    y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
804
    y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
805
    y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
806
    f.evaluate(vals, y, c);
 
807
    values[4] = vals[0];
 
808
    y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
809
    y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
810
    y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
811
    f.evaluate(vals, y, c);
 
812
    values[5] = vals[0];
 
813
    y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
814
    y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
815
    y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
816
    f.evaluate(vals, y, c);
 
817
    values[6] = vals[0];
 
818
    y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
819
    y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
820
    y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
821
    f.evaluate(vals, y, c);
 
822
    values[7] = vals[0];
 
823
    y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
824
    y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
825
    y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
826
    f.evaluate(vals, y, c);
 
827
    values[8] = vals[0];
 
828
    y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
829
    y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
830
    y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
831
    f.evaluate(vals, y, c);
 
832
    values[9] = vals[0];
 
833
  }
 
834
 
 
835
  /// Interpolate vertex values from dof values
 
836
  virtual void interpolate_vertex_values(double* vertex_values,
 
837
                                         const double* dof_values,
 
838
                                         const ufc::cell& c) const
 
839
  {
 
840
    // Evaluate function and change variables
 
841
    vertex_values[0] = dof_values[0];
 
842
    vertex_values[1] = dof_values[1];
 
843
    vertex_values[2] = dof_values[2];
 
844
    vertex_values[3] = dof_values[3];
 
845
  }
 
846
 
 
847
  /// Return the number of sub elements (for a mixed element)
 
848
  virtual unsigned int num_sub_elements() const
 
849
  {
 
850
    return 0;
 
851
  }
 
852
 
 
853
  /// Create a new finite element for sub element i (for a mixed element)
 
854
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
855
  {
 
856
    return 0;
 
857
  }
 
858
 
 
859
};
 
860
 
 
861
/// This class defines the interface for a finite element.
 
862
 
 
863
class vectorlaplacegradcurl_finite_element_1: public ufc::finite_element
 
864
{
 
865
public:
 
866
 
 
867
  /// Constructor
 
868
  vectorlaplacegradcurl_finite_element_1() : ufc::finite_element()
 
869
  {
 
870
    // Do nothing
 
871
  }
 
872
 
 
873
  /// Destructor
 
874
  virtual ~vectorlaplacegradcurl_finite_element_1()
 
875
  {
 
876
    // Do nothing
 
877
  }
 
878
 
 
879
  /// Return a string identifying the finite element
 
880
  virtual const char* signature() const
 
881
  {
 
882
    return "VectorElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2, 3)";
 
883
  }
 
884
 
 
885
  /// Return the cell shape
 
886
  virtual ufc::shape cell_shape() const
 
887
  {
 
888
    return ufc::tetrahedron;
 
889
  }
 
890
 
 
891
  /// Return the dimension of the finite element function space
 
892
  virtual unsigned int space_dimension() const
 
893
  {
 
894
    return 30;
 
895
  }
 
896
 
 
897
  /// Return the rank of the value space
 
898
  virtual unsigned int value_rank() const
 
899
  {
 
900
    return 1;
 
901
  }
 
902
 
 
903
  /// Return the dimension of the value space for axis i
 
904
  virtual unsigned int value_dimension(unsigned int i) const
 
905
  {
 
906
    switch (i)
 
907
    {
 
908
    case 0:
 
909
      {
 
910
        return 3;
 
911
        break;
 
912
      }
 
913
    }
 
914
    
 
915
    return 0;
 
916
  }
 
917
 
 
918
  /// Evaluate basis function i at given point in cell
 
919
  virtual void evaluate_basis(unsigned int i,
 
920
                              double* values,
 
921
                              const double* coordinates,
 
922
                              const ufc::cell& c) const
 
923
  {
 
924
    // Extract vertex coordinates
 
925
    const double * const * x = c.coordinates;
 
926
    
 
927
    // Compute Jacobian of affine map from reference cell
 
928
    const double J_00 = x[1][0] - x[0][0];
 
929
    const double J_01 = x[2][0] - x[0][0];
 
930
    const double J_02 = x[3][0] - x[0][0];
 
931
    const double J_10 = x[1][1] - x[0][1];
 
932
    const double J_11 = x[2][1] - x[0][1];
 
933
    const double J_12 = x[3][1] - x[0][1];
 
934
    const double J_20 = x[1][2] - x[0][2];
 
935
    const double J_21 = x[2][2] - x[0][2];
 
936
    const double J_22 = x[3][2] - x[0][2];
 
937
    
 
938
    // Compute sub determinants
 
939
    const double d_00 = J_11*J_22 - J_12*J_21;
 
940
    const double d_01 = J_12*J_20 - J_10*J_22;
 
941
    const double d_02 = J_10*J_21 - J_11*J_20;
 
942
    const double d_10 = J_02*J_21 - J_01*J_22;
 
943
    const double d_11 = J_00*J_22 - J_02*J_20;
 
944
    const double d_12 = J_01*J_20 - J_00*J_21;
 
945
    const double d_20 = J_01*J_12 - J_02*J_11;
 
946
    const double d_21 = J_02*J_10 - J_00*J_12;
 
947
    const double d_22 = J_00*J_11 - J_01*J_10;
 
948
    
 
949
    // Compute determinant of Jacobian
 
950
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
951
    
 
952
    // Compute inverse of Jacobian
 
953
    
 
954
    // Compute constants
 
955
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
956
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
957
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
958
    
 
959
    // Get coordinates and map to the reference (FIAT) element
 
960
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
961
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
962
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
963
    
 
964
    
 
965
    // Reset values
 
966
    values[0] = 0.00000000;
 
967
    values[1] = 0.00000000;
 
968
    values[2] = 0.00000000;
 
969
    if (0 <= i && i <= 9)
 
970
    {
 
971
      // Map degree of freedom to element degree of freedom
 
972
      const unsigned int dof = i;
 
973
      
 
974
      // Array of basisvalues
 
975
      double basisvalues[10] = {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
976
      
 
977
      // Declare helper variables
 
978
      unsigned int rr = 0;
 
979
      unsigned int ss = 0;
 
980
      unsigned int tt = 0;
 
981
      double tmp5 = 0.00000000;
 
982
      double tmp6 = 0.00000000;
 
983
      double tmp7 = 0.00000000;
 
984
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
985
      double tmp1 = 0.25000000*(Y + Z)*(Y + Z);
 
986
      double tmp2 = 0.50000000*(1.00000000 + Z + 2.00000000*Y);
 
987
      double tmp3 = 0.50000000*(1.00000000 - Z);
 
988
      double tmp4 = tmp3*tmp3;
 
989
      
 
990
      // Compute basisvalues
 
991
      basisvalues[0] = 1.00000000;
 
992
      basisvalues[1] = tmp0;
 
993
      for (unsigned int r = 1; r < 2; r++)
 
994
      {
 
995
        rr = (r + 1)*((r + 1) + 1)*((r + 1) + 2)/6;
 
996
        ss = r*(r + 1)*(r + 2)/6;
 
997
        tt = (r - 1)*((r - 1) + 1)*((r - 1) + 2)/6;
 
998
        basisvalues[rr] = (basisvalues[ss]*tmp0*(1.00000000 + 2.00000000*r)/(1.00000000 + r) - basisvalues[tt]*tmp1*r/(1.00000000 + r));
 
999
      }// end loop over 'r'
 
1000
      for (unsigned int r = 0; r < 2; r++)
 
1001
      {
 
1002
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
1003
        ss = r*(r + 1)*(r + 2)/6;
 
1004
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
1005
      }// end loop over 'r'
 
1006
      for (unsigned int r = 0; r < 1; r++)
 
1007
      {
 
1008
        for (unsigned int s = 1; s < 2 - r; s++)
 
1009
        {
 
1010
          rr = (r + (s + 1))*(r + (s + 1) + 1)*(r + (s + 1) + 2)/6 + (s + 1)*((s + 1) + 1)/2;
 
1011
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1012
          tt = (r + (s - 1))*(r + (s - 1) + 1)*(r + (s - 1) + 2)/6 + (s - 1)*((s - 1) + 1)/2;
 
1013
          tmp5 = (2.00000000 + 2.00000000*r + 2.00000000*s)*(3.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1014
          tmp6 = (1.00000000 + 4.00000000*r*r + 4.00000000*r)*(2.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1015
          tmp7 = (1.00000000 + s + 2.00000000*r)*(3.00000000 + 2.00000000*r + 2.00000000*s)*s/((1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1016
          basisvalues[rr] = (basisvalues[ss]*(tmp2*tmp5 + tmp3*tmp6) - basisvalues[tt]*tmp4*tmp7);
 
1017
        }// end loop over 's'
 
1018
      }// end loop over 'r'
 
1019
      for (unsigned int r = 0; r < 2; r++)
 
1020
      {
 
1021
        for (unsigned int s = 0; s < 2 - r; s++)
 
1022
        {
 
1023
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
1024
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1025
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
1026
        }// end loop over 's'
 
1027
      }// end loop over 'r'
 
1028
      for (unsigned int r = 0; r < 1; r++)
 
1029
      {
 
1030
        for (unsigned int s = 0; s < 1 - r; s++)
 
1031
        {
 
1032
          for (unsigned int t = 1; t < 2 - r - s; t++)
 
1033
          {
 
1034
            rr = (r + s + t + 1)*(r + s + t + 1 + 1)*(r + s + t + 1 + 2)/6 + (s + t + 1)*(s + t + 1 + 1)/2 + t + 1;
 
1035
            ss = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1036
            tt = (r + s + t - 1)*(r + s + t - 1 + 1)*(r + s + t - 1 + 2)/6 + (s + t - 1)*(s + t - 1 + 1)/2 + t - 1;
 
1037
            tmp5 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)/(2.00000000*(1.00000000 + t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1038
            tmp6 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 4.00000000*r*r + 4.00000000*s*s + 8.00000000*r*s + 8.00000000*r + 8.00000000*s)/(2.00000000*(1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1039
            tmp7 = (2.00000000 + t + 2.00000000*r + 2.00000000*s)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*t/((1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1040
            basisvalues[rr] = (basisvalues[ss]*(tmp6 + Z*tmp5) - basisvalues[tt]*tmp7);
 
1041
          }// end loop over 't'
 
1042
        }// end loop over 's'
 
1043
      }// end loop over 'r'
 
1044
      for (unsigned int r = 0; r < 3; r++)
 
1045
      {
 
1046
        for (unsigned int s = 0; s < 3 - r; s++)
 
1047
        {
 
1048
          for (unsigned int t = 0; t < 3 - r - s; t++)
 
1049
          {
 
1050
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1051
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
1052
          }// end loop over 't'
 
1053
        }// end loop over 's'
 
1054
      }// end loop over 'r'
 
1055
      
 
1056
      // Table(s) of coefficients
 
1057
      static const double coefficients0[10][10] = \
 
1058
      {{-0.05773503, -0.06085806, -0.03513642, -0.02484520, 0.06506000, 0.05039526, 0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1059
      {-0.05773503, 0.06085806, -0.03513642, -0.02484520, 0.06506000, -0.05039526, -0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1060
      {-0.05773503, 0.00000000, 0.07027284, -0.02484520, 0.00000000, 0.00000000, 0.00000000, 0.08728716, -0.04751311, 0.01679842},
 
1061
      {-0.05773503, 0.00000000, 0.00000000, 0.07453560, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.10079053},
 
1062
      {0.23094011, 0.00000000, 0.14054567, 0.09938080, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.11878277, -0.06719368},
 
1063
      {0.23094011, 0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, 0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1064
      {0.23094011, 0.12171612, 0.07027284, -0.09938080, 0.00000000, 0.10079053, -0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1065
      {0.23094011, -0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, -0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1066
      {0.23094011, -0.12171612, 0.07027284, -0.09938080, 0.00000000, -0.10079053, 0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1067
      {0.23094011, 0.00000000, -0.14054567, -0.09938080, -0.13012001, 0.00000000, 0.00000000, 0.02909572, 0.02375655, 0.01679842}};
 
1068
      
 
1069
      // Compute value(s).
 
1070
      for (unsigned int r = 0; r < 10; r++)
 
1071
      {
 
1072
        values[0] += coefficients0[dof][r]*basisvalues[r];
 
1073
      }// end loop over 'r'
 
1074
    }
 
1075
    
 
1076
    if (10 <= i && i <= 19)
 
1077
    {
 
1078
      // Map degree of freedom to element degree of freedom
 
1079
      const unsigned int dof = i - 10;
 
1080
      
 
1081
      // Array of basisvalues
 
1082
      double basisvalues[10] = {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
1083
      
 
1084
      // Declare helper variables
 
1085
      unsigned int rr = 0;
 
1086
      unsigned int ss = 0;
 
1087
      unsigned int tt = 0;
 
1088
      double tmp5 = 0.00000000;
 
1089
      double tmp6 = 0.00000000;
 
1090
      double tmp7 = 0.00000000;
 
1091
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
1092
      double tmp1 = 0.25000000*(Y + Z)*(Y + Z);
 
1093
      double tmp2 = 0.50000000*(1.00000000 + Z + 2.00000000*Y);
 
1094
      double tmp3 = 0.50000000*(1.00000000 - Z);
 
1095
      double tmp4 = tmp3*tmp3;
 
1096
      
 
1097
      // Compute basisvalues
 
1098
      basisvalues[0] = 1.00000000;
 
1099
      basisvalues[1] = tmp0;
 
1100
      for (unsigned int r = 1; r < 2; r++)
 
1101
      {
 
1102
        rr = (r + 1)*((r + 1) + 1)*((r + 1) + 2)/6;
 
1103
        ss = r*(r + 1)*(r + 2)/6;
 
1104
        tt = (r - 1)*((r - 1) + 1)*((r - 1) + 2)/6;
 
1105
        basisvalues[rr] = (basisvalues[ss]*tmp0*(1.00000000 + 2.00000000*r)/(1.00000000 + r) - basisvalues[tt]*tmp1*r/(1.00000000 + r));
 
1106
      }// end loop over 'r'
 
1107
      for (unsigned int r = 0; r < 2; r++)
 
1108
      {
 
1109
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
1110
        ss = r*(r + 1)*(r + 2)/6;
 
1111
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
1112
      }// end loop over 'r'
 
1113
      for (unsigned int r = 0; r < 1; r++)
 
1114
      {
 
1115
        for (unsigned int s = 1; s < 2 - r; s++)
 
1116
        {
 
1117
          rr = (r + (s + 1))*(r + (s + 1) + 1)*(r + (s + 1) + 2)/6 + (s + 1)*((s + 1) + 1)/2;
 
1118
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1119
          tt = (r + (s - 1))*(r + (s - 1) + 1)*(r + (s - 1) + 2)/6 + (s - 1)*((s - 1) + 1)/2;
 
1120
          tmp5 = (2.00000000 + 2.00000000*r + 2.00000000*s)*(3.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1121
          tmp6 = (1.00000000 + 4.00000000*r*r + 4.00000000*r)*(2.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1122
          tmp7 = (1.00000000 + s + 2.00000000*r)*(3.00000000 + 2.00000000*r + 2.00000000*s)*s/((1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1123
          basisvalues[rr] = (basisvalues[ss]*(tmp2*tmp5 + tmp3*tmp6) - basisvalues[tt]*tmp4*tmp7);
 
1124
        }// end loop over 's'
 
1125
      }// end loop over 'r'
 
1126
      for (unsigned int r = 0; r < 2; r++)
 
1127
      {
 
1128
        for (unsigned int s = 0; s < 2 - r; s++)
 
1129
        {
 
1130
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
1131
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1132
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
1133
        }// end loop over 's'
 
1134
      }// end loop over 'r'
 
1135
      for (unsigned int r = 0; r < 1; r++)
 
1136
      {
 
1137
        for (unsigned int s = 0; s < 1 - r; s++)
 
1138
        {
 
1139
          for (unsigned int t = 1; t < 2 - r - s; t++)
 
1140
          {
 
1141
            rr = (r + s + t + 1)*(r + s + t + 1 + 1)*(r + s + t + 1 + 2)/6 + (s + t + 1)*(s + t + 1 + 1)/2 + t + 1;
 
1142
            ss = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1143
            tt = (r + s + t - 1)*(r + s + t - 1 + 1)*(r + s + t - 1 + 2)/6 + (s + t - 1)*(s + t - 1 + 1)/2 + t - 1;
 
1144
            tmp5 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)/(2.00000000*(1.00000000 + t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1145
            tmp6 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 4.00000000*r*r + 4.00000000*s*s + 8.00000000*r*s + 8.00000000*r + 8.00000000*s)/(2.00000000*(1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1146
            tmp7 = (2.00000000 + t + 2.00000000*r + 2.00000000*s)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*t/((1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1147
            basisvalues[rr] = (basisvalues[ss]*(tmp6 + Z*tmp5) - basisvalues[tt]*tmp7);
 
1148
          }// end loop over 't'
 
1149
        }// end loop over 's'
 
1150
      }// end loop over 'r'
 
1151
      for (unsigned int r = 0; r < 3; r++)
 
1152
      {
 
1153
        for (unsigned int s = 0; s < 3 - r; s++)
 
1154
        {
 
1155
          for (unsigned int t = 0; t < 3 - r - s; t++)
 
1156
          {
 
1157
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1158
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
1159
          }// end loop over 't'
 
1160
        }// end loop over 's'
 
1161
      }// end loop over 'r'
 
1162
      
 
1163
      // Table(s) of coefficients
 
1164
      static const double coefficients0[10][10] = \
 
1165
      {{-0.05773503, -0.06085806, -0.03513642, -0.02484520, 0.06506000, 0.05039526, 0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1166
      {-0.05773503, 0.06085806, -0.03513642, -0.02484520, 0.06506000, -0.05039526, -0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1167
      {-0.05773503, 0.00000000, 0.07027284, -0.02484520, 0.00000000, 0.00000000, 0.00000000, 0.08728716, -0.04751311, 0.01679842},
 
1168
      {-0.05773503, 0.00000000, 0.00000000, 0.07453560, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.10079053},
 
1169
      {0.23094011, 0.00000000, 0.14054567, 0.09938080, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.11878277, -0.06719368},
 
1170
      {0.23094011, 0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, 0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1171
      {0.23094011, 0.12171612, 0.07027284, -0.09938080, 0.00000000, 0.10079053, -0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1172
      {0.23094011, -0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, -0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1173
      {0.23094011, -0.12171612, 0.07027284, -0.09938080, 0.00000000, -0.10079053, 0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1174
      {0.23094011, 0.00000000, -0.14054567, -0.09938080, -0.13012001, 0.00000000, 0.00000000, 0.02909572, 0.02375655, 0.01679842}};
 
1175
      
 
1176
      // Compute value(s).
 
1177
      for (unsigned int r = 0; r < 10; r++)
 
1178
      {
 
1179
        values[1] += coefficients0[dof][r]*basisvalues[r];
 
1180
      }// end loop over 'r'
 
1181
    }
 
1182
    
 
1183
    if (20 <= i && i <= 29)
 
1184
    {
 
1185
      // Map degree of freedom to element degree of freedom
 
1186
      const unsigned int dof = i - 20;
 
1187
      
 
1188
      // Array of basisvalues
 
1189
      double basisvalues[10] = {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
1190
      
 
1191
      // Declare helper variables
 
1192
      unsigned int rr = 0;
 
1193
      unsigned int ss = 0;
 
1194
      unsigned int tt = 0;
 
1195
      double tmp5 = 0.00000000;
 
1196
      double tmp6 = 0.00000000;
 
1197
      double tmp7 = 0.00000000;
 
1198
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
1199
      double tmp1 = 0.25000000*(Y + Z)*(Y + Z);
 
1200
      double tmp2 = 0.50000000*(1.00000000 + Z + 2.00000000*Y);
 
1201
      double tmp3 = 0.50000000*(1.00000000 - Z);
 
1202
      double tmp4 = tmp3*tmp3;
 
1203
      
 
1204
      // Compute basisvalues
 
1205
      basisvalues[0] = 1.00000000;
 
1206
      basisvalues[1] = tmp0;
 
1207
      for (unsigned int r = 1; r < 2; r++)
 
1208
      {
 
1209
        rr = (r + 1)*((r + 1) + 1)*((r + 1) + 2)/6;
 
1210
        ss = r*(r + 1)*(r + 2)/6;
 
1211
        tt = (r - 1)*((r - 1) + 1)*((r - 1) + 2)/6;
 
1212
        basisvalues[rr] = (basisvalues[ss]*tmp0*(1.00000000 + 2.00000000*r)/(1.00000000 + r) - basisvalues[tt]*tmp1*r/(1.00000000 + r));
 
1213
      }// end loop over 'r'
 
1214
      for (unsigned int r = 0; r < 2; r++)
 
1215
      {
 
1216
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
1217
        ss = r*(r + 1)*(r + 2)/6;
 
1218
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
1219
      }// end loop over 'r'
 
1220
      for (unsigned int r = 0; r < 1; r++)
 
1221
      {
 
1222
        for (unsigned int s = 1; s < 2 - r; s++)
 
1223
        {
 
1224
          rr = (r + (s + 1))*(r + (s + 1) + 1)*(r + (s + 1) + 2)/6 + (s + 1)*((s + 1) + 1)/2;
 
1225
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1226
          tt = (r + (s - 1))*(r + (s - 1) + 1)*(r + (s - 1) + 2)/6 + (s - 1)*((s - 1) + 1)/2;
 
1227
          tmp5 = (2.00000000 + 2.00000000*r + 2.00000000*s)*(3.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1228
          tmp6 = (1.00000000 + 4.00000000*r*r + 4.00000000*r)*(2.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1229
          tmp7 = (1.00000000 + s + 2.00000000*r)*(3.00000000 + 2.00000000*r + 2.00000000*s)*s/((1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1230
          basisvalues[rr] = (basisvalues[ss]*(tmp2*tmp5 + tmp3*tmp6) - basisvalues[tt]*tmp4*tmp7);
 
1231
        }// end loop over 's'
 
1232
      }// end loop over 'r'
 
1233
      for (unsigned int r = 0; r < 2; r++)
 
1234
      {
 
1235
        for (unsigned int s = 0; s < 2 - r; s++)
 
1236
        {
 
1237
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
1238
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1239
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
1240
        }// end loop over 's'
 
1241
      }// end loop over 'r'
 
1242
      for (unsigned int r = 0; r < 1; r++)
 
1243
      {
 
1244
        for (unsigned int s = 0; s < 1 - r; s++)
 
1245
        {
 
1246
          for (unsigned int t = 1; t < 2 - r - s; t++)
 
1247
          {
 
1248
            rr = (r + s + t + 1)*(r + s + t + 1 + 1)*(r + s + t + 1 + 2)/6 + (s + t + 1)*(s + t + 1 + 1)/2 + t + 1;
 
1249
            ss = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1250
            tt = (r + s + t - 1)*(r + s + t - 1 + 1)*(r + s + t - 1 + 2)/6 + (s + t - 1)*(s + t - 1 + 1)/2 + t - 1;
 
1251
            tmp5 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)/(2.00000000*(1.00000000 + t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1252
            tmp6 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 4.00000000*r*r + 4.00000000*s*s + 8.00000000*r*s + 8.00000000*r + 8.00000000*s)/(2.00000000*(1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1253
            tmp7 = (2.00000000 + t + 2.00000000*r + 2.00000000*s)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*t/((1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1254
            basisvalues[rr] = (basisvalues[ss]*(tmp6 + Z*tmp5) - basisvalues[tt]*tmp7);
 
1255
          }// end loop over 't'
 
1256
        }// end loop over 's'
 
1257
      }// end loop over 'r'
 
1258
      for (unsigned int r = 0; r < 3; r++)
 
1259
      {
 
1260
        for (unsigned int s = 0; s < 3 - r; s++)
 
1261
        {
 
1262
          for (unsigned int t = 0; t < 3 - r - s; t++)
 
1263
          {
 
1264
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1265
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
1266
          }// end loop over 't'
 
1267
        }// end loop over 's'
 
1268
      }// end loop over 'r'
 
1269
      
 
1270
      // Table(s) of coefficients
 
1271
      static const double coefficients0[10][10] = \
 
1272
      {{-0.05773503, -0.06085806, -0.03513642, -0.02484520, 0.06506000, 0.05039526, 0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1273
      {-0.05773503, 0.06085806, -0.03513642, -0.02484520, 0.06506000, -0.05039526, -0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1274
      {-0.05773503, 0.00000000, 0.07027284, -0.02484520, 0.00000000, 0.00000000, 0.00000000, 0.08728716, -0.04751311, 0.01679842},
 
1275
      {-0.05773503, 0.00000000, 0.00000000, 0.07453560, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.10079053},
 
1276
      {0.23094011, 0.00000000, 0.14054567, 0.09938080, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.11878277, -0.06719368},
 
1277
      {0.23094011, 0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, 0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1278
      {0.23094011, 0.12171612, 0.07027284, -0.09938080, 0.00000000, 0.10079053, -0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1279
      {0.23094011, -0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, -0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1280
      {0.23094011, -0.12171612, 0.07027284, -0.09938080, 0.00000000, -0.10079053, 0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1281
      {0.23094011, 0.00000000, -0.14054567, -0.09938080, -0.13012001, 0.00000000, 0.00000000, 0.02909572, 0.02375655, 0.01679842}};
 
1282
      
 
1283
      // Compute value(s).
 
1284
      for (unsigned int r = 0; r < 10; r++)
 
1285
      {
 
1286
        values[2] += coefficients0[dof][r]*basisvalues[r];
 
1287
      }// end loop over 'r'
 
1288
    }
 
1289
    
 
1290
  }
 
1291
 
 
1292
  /// Evaluate all basis functions at given point in cell
 
1293
  virtual void evaluate_basis_all(double* values,
 
1294
                                  const double* coordinates,
 
1295
                                  const ufc::cell& c) const
 
1296
  {
 
1297
    // Helper variable to hold values of a single dof.
 
1298
    double dof_values[3] = {0.00000000, 0.00000000, 0.00000000};
 
1299
    
 
1300
    // Loop dofs and call evaluate_basis.
 
1301
    for (unsigned int r = 0; r < 30; r++)
 
1302
    {
 
1303
      evaluate_basis(r, dof_values, coordinates, c);
 
1304
      for (unsigned int s = 0; s < 3; s++)
 
1305
      {
 
1306
        values[r*3 + s] = dof_values[s];
 
1307
      }// end loop over 's'
 
1308
    }// end loop over 'r'
 
1309
  }
 
1310
 
 
1311
  /// Evaluate order n derivatives of basis function i at given point in cell
 
1312
  virtual void evaluate_basis_derivatives(unsigned int i,
 
1313
                                          unsigned int n,
 
1314
                                          double* values,
 
1315
                                          const double* coordinates,
 
1316
                                          const ufc::cell& c) const
 
1317
  {
 
1318
    // Extract vertex coordinates
 
1319
    const double * const * x = c.coordinates;
 
1320
    
 
1321
    // Compute Jacobian of affine map from reference cell
 
1322
    const double J_00 = x[1][0] - x[0][0];
 
1323
    const double J_01 = x[2][0] - x[0][0];
 
1324
    const double J_02 = x[3][0] - x[0][0];
 
1325
    const double J_10 = x[1][1] - x[0][1];
 
1326
    const double J_11 = x[2][1] - x[0][1];
 
1327
    const double J_12 = x[3][1] - x[0][1];
 
1328
    const double J_20 = x[1][2] - x[0][2];
 
1329
    const double J_21 = x[2][2] - x[0][2];
 
1330
    const double J_22 = x[3][2] - x[0][2];
 
1331
    
 
1332
    // Compute sub determinants
 
1333
    const double d_00 = J_11*J_22 - J_12*J_21;
 
1334
    const double d_01 = J_12*J_20 - J_10*J_22;
 
1335
    const double d_02 = J_10*J_21 - J_11*J_20;
 
1336
    const double d_10 = J_02*J_21 - J_01*J_22;
 
1337
    const double d_11 = J_00*J_22 - J_02*J_20;
 
1338
    const double d_12 = J_01*J_20 - J_00*J_21;
 
1339
    const double d_20 = J_01*J_12 - J_02*J_11;
 
1340
    const double d_21 = J_02*J_10 - J_00*J_12;
 
1341
    const double d_22 = J_00*J_11 - J_01*J_10;
 
1342
    
 
1343
    // Compute determinant of Jacobian
 
1344
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
1345
    
 
1346
    // Compute inverse of Jacobian
 
1347
    const double K_00 = d_00 / detJ;
 
1348
    const double K_01 = d_10 / detJ;
 
1349
    const double K_02 = d_20 / detJ;
 
1350
    const double K_10 = d_01 / detJ;
 
1351
    const double K_11 = d_11 / detJ;
 
1352
    const double K_12 = d_21 / detJ;
 
1353
    const double K_20 = d_02 / detJ;
 
1354
    const double K_21 = d_12 / detJ;
 
1355
    const double K_22 = d_22 / detJ;
 
1356
    
 
1357
    // Compute constants
 
1358
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
1359
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
1360
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
1361
    
 
1362
    // Get coordinates and map to the reference (FIAT) element
 
1363
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
1364
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
1365
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
1366
    
 
1367
    
 
1368
    // Compute number of derivatives.
 
1369
    unsigned int  num_derivatives = 1;
 
1370
    
 
1371
    for (unsigned int r = 0; r < n; r++)
 
1372
    {
 
1373
      num_derivatives *= 3;
 
1374
    }// end loop over 'r'
 
1375
    
 
1376
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
1377
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
1378
    for (unsigned int row = 0; row < num_derivatives; row++)
 
1379
    {
 
1380
      combinations[row] = new unsigned int [n];
 
1381
      for (unsigned int col = 0; col < n; col++)
 
1382
        combinations[row][col] = 0;
 
1383
    }
 
1384
    
 
1385
    // Generate combinations of derivatives
 
1386
    for (unsigned int row = 1; row < num_derivatives; row++)
 
1387
    {
 
1388
      for (unsigned int num = 0; num < row; num++)
 
1389
      {
 
1390
        for (unsigned int col = n-1; col+1 > 0; col--)
 
1391
        {
 
1392
          if (combinations[row][col] + 1 > 2)
 
1393
            combinations[row][col] = 0;
 
1394
          else
 
1395
          {
 
1396
            combinations[row][col] += 1;
 
1397
            break;
 
1398
          }
 
1399
        }
 
1400
      }
 
1401
    }
 
1402
    
 
1403
    // Compute inverse of Jacobian
 
1404
    const double Jinv[3][3] = {{K_00, K_01, K_02}, {K_10, K_11, K_12}, {K_20, K_21, K_22}};
 
1405
    
 
1406
    // Declare transformation matrix
 
1407
    // Declare pointer to two dimensional array and initialise
 
1408
    double **transform = new double *[num_derivatives];
 
1409
    
 
1410
    for (unsigned int j = 0; j < num_derivatives; j++)
 
1411
    {
 
1412
      transform[j] = new double [num_derivatives];
 
1413
      for (unsigned int k = 0; k < num_derivatives; k++)
 
1414
        transform[j][k] = 1;
 
1415
    }
 
1416
    
 
1417
    // Construct transformation matrix
 
1418
    for (unsigned int row = 0; row < num_derivatives; row++)
 
1419
    {
 
1420
      for (unsigned int col = 0; col < num_derivatives; col++)
 
1421
      {
 
1422
        for (unsigned int k = 0; k < n; k++)
 
1423
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
1424
      }
 
1425
    }
 
1426
    
 
1427
    // Reset values. Assuming that values is always an array.
 
1428
    for (unsigned int r = 0; r < 3*num_derivatives; r++)
 
1429
    {
 
1430
      values[r] = 0.00000000;
 
1431
    }// end loop over 'r'
 
1432
    
 
1433
    if (0 <= i && i <= 9)
 
1434
    {
 
1435
      // Map degree of freedom to element degree of freedom
 
1436
      const unsigned int dof = i;
 
1437
      
 
1438
      // Array of basisvalues
 
1439
      double basisvalues[10] = {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
1440
      
 
1441
      // Declare helper variables
 
1442
      unsigned int rr = 0;
 
1443
      unsigned int ss = 0;
 
1444
      unsigned int tt = 0;
 
1445
      double tmp5 = 0.00000000;
 
1446
      double tmp6 = 0.00000000;
 
1447
      double tmp7 = 0.00000000;
 
1448
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
1449
      double tmp1 = 0.25000000*(Y + Z)*(Y + Z);
 
1450
      double tmp2 = 0.50000000*(1.00000000 + Z + 2.00000000*Y);
 
1451
      double tmp3 = 0.50000000*(1.00000000 - Z);
 
1452
      double tmp4 = tmp3*tmp3;
 
1453
      
 
1454
      // Compute basisvalues
 
1455
      basisvalues[0] = 1.00000000;
 
1456
      basisvalues[1] = tmp0;
 
1457
      for (unsigned int r = 1; r < 2; r++)
 
1458
      {
 
1459
        rr = (r + 1)*((r + 1) + 1)*((r + 1) + 2)/6;
 
1460
        ss = r*(r + 1)*(r + 2)/6;
 
1461
        tt = (r - 1)*((r - 1) + 1)*((r - 1) + 2)/6;
 
1462
        basisvalues[rr] = (basisvalues[ss]*tmp0*(1.00000000 + 2.00000000*r)/(1.00000000 + r) - basisvalues[tt]*tmp1*r/(1.00000000 + r));
 
1463
      }// end loop over 'r'
 
1464
      for (unsigned int r = 0; r < 2; r++)
 
1465
      {
 
1466
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
1467
        ss = r*(r + 1)*(r + 2)/6;
 
1468
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
1469
      }// end loop over 'r'
 
1470
      for (unsigned int r = 0; r < 1; r++)
 
1471
      {
 
1472
        for (unsigned int s = 1; s < 2 - r; s++)
 
1473
        {
 
1474
          rr = (r + (s + 1))*(r + (s + 1) + 1)*(r + (s + 1) + 2)/6 + (s + 1)*((s + 1) + 1)/2;
 
1475
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1476
          tt = (r + (s - 1))*(r + (s - 1) + 1)*(r + (s - 1) + 2)/6 + (s - 1)*((s - 1) + 1)/2;
 
1477
          tmp5 = (2.00000000 + 2.00000000*r + 2.00000000*s)*(3.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1478
          tmp6 = (1.00000000 + 4.00000000*r*r + 4.00000000*r)*(2.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1479
          tmp7 = (1.00000000 + s + 2.00000000*r)*(3.00000000 + 2.00000000*r + 2.00000000*s)*s/((1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1480
          basisvalues[rr] = (basisvalues[ss]*(tmp2*tmp5 + tmp3*tmp6) - basisvalues[tt]*tmp4*tmp7);
 
1481
        }// end loop over 's'
 
1482
      }// end loop over 'r'
 
1483
      for (unsigned int r = 0; r < 2; r++)
 
1484
      {
 
1485
        for (unsigned int s = 0; s < 2 - r; s++)
 
1486
        {
 
1487
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
1488
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1489
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
1490
        }// end loop over 's'
 
1491
      }// end loop over 'r'
 
1492
      for (unsigned int r = 0; r < 1; r++)
 
1493
      {
 
1494
        for (unsigned int s = 0; s < 1 - r; s++)
 
1495
        {
 
1496
          for (unsigned int t = 1; t < 2 - r - s; t++)
 
1497
          {
 
1498
            rr = (r + s + t + 1)*(r + s + t + 1 + 1)*(r + s + t + 1 + 2)/6 + (s + t + 1)*(s + t + 1 + 1)/2 + t + 1;
 
1499
            ss = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1500
            tt = (r + s + t - 1)*(r + s + t - 1 + 1)*(r + s + t - 1 + 2)/6 + (s + t - 1)*(s + t - 1 + 1)/2 + t - 1;
 
1501
            tmp5 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)/(2.00000000*(1.00000000 + t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1502
            tmp6 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 4.00000000*r*r + 4.00000000*s*s + 8.00000000*r*s + 8.00000000*r + 8.00000000*s)/(2.00000000*(1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1503
            tmp7 = (2.00000000 + t + 2.00000000*r + 2.00000000*s)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*t/((1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1504
            basisvalues[rr] = (basisvalues[ss]*(tmp6 + Z*tmp5) - basisvalues[tt]*tmp7);
 
1505
          }// end loop over 't'
 
1506
        }// end loop over 's'
 
1507
      }// end loop over 'r'
 
1508
      for (unsigned int r = 0; r < 3; r++)
 
1509
      {
 
1510
        for (unsigned int s = 0; s < 3 - r; s++)
 
1511
        {
 
1512
          for (unsigned int t = 0; t < 3 - r - s; t++)
 
1513
          {
 
1514
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1515
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
1516
          }// end loop over 't'
 
1517
        }// end loop over 's'
 
1518
      }// end loop over 'r'
 
1519
      
 
1520
      // Table(s) of coefficients
 
1521
      static const double coefficients0[10][10] = \
 
1522
      {{-0.05773503, -0.06085806, -0.03513642, -0.02484520, 0.06506000, 0.05039526, 0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1523
      {-0.05773503, 0.06085806, -0.03513642, -0.02484520, 0.06506000, -0.05039526, -0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1524
      {-0.05773503, 0.00000000, 0.07027284, -0.02484520, 0.00000000, 0.00000000, 0.00000000, 0.08728716, -0.04751311, 0.01679842},
 
1525
      {-0.05773503, 0.00000000, 0.00000000, 0.07453560, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.10079053},
 
1526
      {0.23094011, 0.00000000, 0.14054567, 0.09938080, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.11878277, -0.06719368},
 
1527
      {0.23094011, 0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, 0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1528
      {0.23094011, 0.12171612, 0.07027284, -0.09938080, 0.00000000, 0.10079053, -0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1529
      {0.23094011, -0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, -0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1530
      {0.23094011, -0.12171612, 0.07027284, -0.09938080, 0.00000000, -0.10079053, 0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1531
      {0.23094011, 0.00000000, -0.14054567, -0.09938080, -0.13012001, 0.00000000, 0.00000000, 0.02909572, 0.02375655, 0.01679842}};
 
1532
      
 
1533
      // Tables of derivatives of the polynomial base (transpose).
 
1534
      static const double dmats0[10][10] = \
 
1535
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1536
      {6.32455532, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1537
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1538
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1539
      {0.00000000, 11.22497216, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1540
      {4.58257569, 0.00000000, 8.36660027, -1.18321596, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1541
      {3.74165739, 0.00000000, 0.00000000, 8.69482605, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1542
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1543
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1544
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
1545
      
 
1546
      static const double dmats1[10][10] = \
 
1547
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1548
      {3.16227766, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1549
      {5.47722558, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1550
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1551
      {2.95803989, 5.61248608, -1.08012345, -0.76376262, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1552
      {2.29128785, 7.24568837, 4.18330013, -0.59160798, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1553
      {1.87082869, 0.00000000, 0.00000000, 4.34741302, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1554
      {-2.64575131, 0.00000000, 9.66091783, 0.68313005, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1555
      {3.24037035, 0.00000000, 0.00000000, 7.52994024, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1556
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
1557
      
 
1558
      static const double dmats2[10][10] = \
 
1559
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1560
      {3.16227766, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1561
      {1.82574186, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1562
      {5.16397779, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1563
      {2.95803989, 5.61248608, -1.08012345, -0.76376262, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1564
      {2.29128785, 1.44913767, 4.18330013, -0.59160798, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1565
      {1.87082869, 7.09929574, 0.00000000, 4.34741302, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1566
      {1.32287566, 0.00000000, 3.86436713, -0.34156503, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1567
      {1.08012345, 0.00000000, 7.09929574, 2.50998008, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1568
      {-3.81881308, 0.00000000, 0.00000000, 8.87411967, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
1569
      
 
1570
      // Compute reference derivatives
 
1571
      // Declare pointer to array of derivatives on FIAT element
 
1572
      double *derivatives = new double [num_derivatives];
 
1573
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1574
      {
 
1575
        derivatives[r] = 0.00000000;
 
1576
      }// end loop over 'r'
 
1577
      
 
1578
      // Declare derivative matrix (of polynomial basis).
 
1579
      double dmats[10][10] = \
 
1580
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1581
      {0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1582
      {0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1583
      {0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1584
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1585
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1586
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1587
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
1588
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
1589
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
1590
      
 
1591
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
1592
      double dmats_old[10][10] = \
 
1593
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1594
      {0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1595
      {0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1596
      {0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1597
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1598
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1599
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1600
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
1601
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
1602
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
1603
      
 
1604
      // Loop possible derivatives.
 
1605
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1606
      {
 
1607
        // Resetting dmats values to compute next derivative.
 
1608
        for (unsigned int t = 0; t < 10; t++)
 
1609
        {
 
1610
          for (unsigned int u = 0; u < 10; u++)
 
1611
          {
 
1612
            dmats[t][u] = 0.00000000;
 
1613
            if (t == u)
 
1614
            {
 
1615
            dmats[t][u] = 1.00000000;
 
1616
            }
 
1617
            
 
1618
          }// end loop over 'u'
 
1619
        }// end loop over 't'
 
1620
        
 
1621
        // Looping derivative order to generate dmats.
 
1622
        for (unsigned int s = 0; s < n; s++)
 
1623
        {
 
1624
          // Updating dmats_old with new values and resetting dmats.
 
1625
          for (unsigned int t = 0; t < 10; t++)
 
1626
          {
 
1627
            for (unsigned int u = 0; u < 10; u++)
 
1628
            {
 
1629
              dmats_old[t][u] = dmats[t][u];
 
1630
              dmats[t][u] = 0.00000000;
 
1631
            }// end loop over 'u'
 
1632
          }// end loop over 't'
 
1633
          
 
1634
          // Update dmats using an inner product.
 
1635
          if (combinations[r][s] == 0)
 
1636
          {
 
1637
          for (unsigned int t = 0; t < 10; t++)
 
1638
          {
 
1639
            for (unsigned int u = 0; u < 10; u++)
 
1640
            {
 
1641
              for (unsigned int tu = 0; tu < 10; tu++)
 
1642
              {
 
1643
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
1644
              }// end loop over 'tu'
 
1645
            }// end loop over 'u'
 
1646
          }// end loop over 't'
 
1647
          }
 
1648
          
 
1649
          if (combinations[r][s] == 1)
 
1650
          {
 
1651
          for (unsigned int t = 0; t < 10; t++)
 
1652
          {
 
1653
            for (unsigned int u = 0; u < 10; u++)
 
1654
            {
 
1655
              for (unsigned int tu = 0; tu < 10; tu++)
 
1656
              {
 
1657
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
1658
              }// end loop over 'tu'
 
1659
            }// end loop over 'u'
 
1660
          }// end loop over 't'
 
1661
          }
 
1662
          
 
1663
          if (combinations[r][s] == 2)
 
1664
          {
 
1665
          for (unsigned int t = 0; t < 10; t++)
 
1666
          {
 
1667
            for (unsigned int u = 0; u < 10; u++)
 
1668
            {
 
1669
              for (unsigned int tu = 0; tu < 10; tu++)
 
1670
              {
 
1671
                dmats[t][u] += dmats2[t][tu]*dmats_old[tu][u];
 
1672
              }// end loop over 'tu'
 
1673
            }// end loop over 'u'
 
1674
          }// end loop over 't'
 
1675
          }
 
1676
          
 
1677
        }// end loop over 's'
 
1678
        for (unsigned int s = 0; s < 10; s++)
 
1679
        {
 
1680
          for (unsigned int t = 0; t < 10; t++)
 
1681
          {
 
1682
            derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
 
1683
          }// end loop over 't'
 
1684
        }// end loop over 's'
 
1685
      }// end loop over 'r'
 
1686
      
 
1687
      // Transform derivatives back to physical element
 
1688
      for (unsigned int row = 0; row < num_derivatives; row++)
 
1689
      {
 
1690
        for (unsigned int col = 0; col < num_derivatives; col++)
 
1691
        {
 
1692
          values[row] += transform[row][col]*derivatives[col];
 
1693
        }
 
1694
      }
 
1695
      
 
1696
      // Delete pointer to array of derivatives on FIAT element
 
1697
      delete [] derivatives;
 
1698
      
 
1699
      // Delete pointer to array of combinations of derivatives and transform
 
1700
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1701
      {
 
1702
        delete [] combinations[r];
 
1703
        delete [] transform[r];
 
1704
      }// end loop over 'r'
 
1705
      delete [] combinations;
 
1706
      delete [] transform;
 
1707
    }
 
1708
    
 
1709
    if (10 <= i && i <= 19)
 
1710
    {
 
1711
      // Map degree of freedom to element degree of freedom
 
1712
      const unsigned int dof = i - 10;
 
1713
      
 
1714
      // Array of basisvalues
 
1715
      double basisvalues[10] = {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
1716
      
 
1717
      // Declare helper variables
 
1718
      unsigned int rr = 0;
 
1719
      unsigned int ss = 0;
 
1720
      unsigned int tt = 0;
 
1721
      double tmp5 = 0.00000000;
 
1722
      double tmp6 = 0.00000000;
 
1723
      double tmp7 = 0.00000000;
 
1724
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
1725
      double tmp1 = 0.25000000*(Y + Z)*(Y + Z);
 
1726
      double tmp2 = 0.50000000*(1.00000000 + Z + 2.00000000*Y);
 
1727
      double tmp3 = 0.50000000*(1.00000000 - Z);
 
1728
      double tmp4 = tmp3*tmp3;
 
1729
      
 
1730
      // Compute basisvalues
 
1731
      basisvalues[0] = 1.00000000;
 
1732
      basisvalues[1] = tmp0;
 
1733
      for (unsigned int r = 1; r < 2; r++)
 
1734
      {
 
1735
        rr = (r + 1)*((r + 1) + 1)*((r + 1) + 2)/6;
 
1736
        ss = r*(r + 1)*(r + 2)/6;
 
1737
        tt = (r - 1)*((r - 1) + 1)*((r - 1) + 2)/6;
 
1738
        basisvalues[rr] = (basisvalues[ss]*tmp0*(1.00000000 + 2.00000000*r)/(1.00000000 + r) - basisvalues[tt]*tmp1*r/(1.00000000 + r));
 
1739
      }// end loop over 'r'
 
1740
      for (unsigned int r = 0; r < 2; r++)
 
1741
      {
 
1742
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
1743
        ss = r*(r + 1)*(r + 2)/6;
 
1744
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
1745
      }// end loop over 'r'
 
1746
      for (unsigned int r = 0; r < 1; r++)
 
1747
      {
 
1748
        for (unsigned int s = 1; s < 2 - r; s++)
 
1749
        {
 
1750
          rr = (r + (s + 1))*(r + (s + 1) + 1)*(r + (s + 1) + 2)/6 + (s + 1)*((s + 1) + 1)/2;
 
1751
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1752
          tt = (r + (s - 1))*(r + (s - 1) + 1)*(r + (s - 1) + 2)/6 + (s - 1)*((s - 1) + 1)/2;
 
1753
          tmp5 = (2.00000000 + 2.00000000*r + 2.00000000*s)*(3.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1754
          tmp6 = (1.00000000 + 4.00000000*r*r + 4.00000000*r)*(2.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1755
          tmp7 = (1.00000000 + s + 2.00000000*r)*(3.00000000 + 2.00000000*r + 2.00000000*s)*s/((1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
1756
          basisvalues[rr] = (basisvalues[ss]*(tmp2*tmp5 + tmp3*tmp6) - basisvalues[tt]*tmp4*tmp7);
 
1757
        }// end loop over 's'
 
1758
      }// end loop over 'r'
 
1759
      for (unsigned int r = 0; r < 2; r++)
 
1760
      {
 
1761
        for (unsigned int s = 0; s < 2 - r; s++)
 
1762
        {
 
1763
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
1764
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
1765
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
1766
        }// end loop over 's'
 
1767
      }// end loop over 'r'
 
1768
      for (unsigned int r = 0; r < 1; r++)
 
1769
      {
 
1770
        for (unsigned int s = 0; s < 1 - r; s++)
 
1771
        {
 
1772
          for (unsigned int t = 1; t < 2 - r - s; t++)
 
1773
          {
 
1774
            rr = (r + s + t + 1)*(r + s + t + 1 + 1)*(r + s + t + 1 + 2)/6 + (s + t + 1)*(s + t + 1 + 1)/2 + t + 1;
 
1775
            ss = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1776
            tt = (r + s + t - 1)*(r + s + t - 1 + 1)*(r + s + t - 1 + 2)/6 + (s + t - 1)*(s + t - 1 + 1)/2 + t - 1;
 
1777
            tmp5 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)/(2.00000000*(1.00000000 + t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1778
            tmp6 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 4.00000000*r*r + 4.00000000*s*s + 8.00000000*r*s + 8.00000000*r + 8.00000000*s)/(2.00000000*(1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1779
            tmp7 = (2.00000000 + t + 2.00000000*r + 2.00000000*s)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*t/((1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
1780
            basisvalues[rr] = (basisvalues[ss]*(tmp6 + Z*tmp5) - basisvalues[tt]*tmp7);
 
1781
          }// end loop over 't'
 
1782
        }// end loop over 's'
 
1783
      }// end loop over 'r'
 
1784
      for (unsigned int r = 0; r < 3; r++)
 
1785
      {
 
1786
        for (unsigned int s = 0; s < 3 - r; s++)
 
1787
        {
 
1788
          for (unsigned int t = 0; t < 3 - r - s; t++)
 
1789
          {
 
1790
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
1791
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
1792
          }// end loop over 't'
 
1793
        }// end loop over 's'
 
1794
      }// end loop over 'r'
 
1795
      
 
1796
      // Table(s) of coefficients
 
1797
      static const double coefficients0[10][10] = \
 
1798
      {{-0.05773503, -0.06085806, -0.03513642, -0.02484520, 0.06506000, 0.05039526, 0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1799
      {-0.05773503, 0.06085806, -0.03513642, -0.02484520, 0.06506000, -0.05039526, -0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
1800
      {-0.05773503, 0.00000000, 0.07027284, -0.02484520, 0.00000000, 0.00000000, 0.00000000, 0.08728716, -0.04751311, 0.01679842},
 
1801
      {-0.05773503, 0.00000000, 0.00000000, 0.07453560, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.10079053},
 
1802
      {0.23094011, 0.00000000, 0.14054567, 0.09938080, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.11878277, -0.06719368},
 
1803
      {0.23094011, 0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, 0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1804
      {0.23094011, 0.12171612, 0.07027284, -0.09938080, 0.00000000, 0.10079053, -0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1805
      {0.23094011, -0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, -0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
1806
      {0.23094011, -0.12171612, 0.07027284, -0.09938080, 0.00000000, -0.10079053, 0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
1807
      {0.23094011, 0.00000000, -0.14054567, -0.09938080, -0.13012001, 0.00000000, 0.00000000, 0.02909572, 0.02375655, 0.01679842}};
 
1808
      
 
1809
      // Tables of derivatives of the polynomial base (transpose).
 
1810
      static const double dmats0[10][10] = \
 
1811
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1812
      {6.32455532, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1813
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1814
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1815
      {0.00000000, 11.22497216, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1816
      {4.58257569, 0.00000000, 8.36660027, -1.18321596, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1817
      {3.74165739, 0.00000000, 0.00000000, 8.69482605, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1818
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1819
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1820
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
1821
      
 
1822
      static const double dmats1[10][10] = \
 
1823
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1824
      {3.16227766, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1825
      {5.47722558, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1826
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1827
      {2.95803989, 5.61248608, -1.08012345, -0.76376262, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1828
      {2.29128785, 7.24568837, 4.18330013, -0.59160798, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1829
      {1.87082869, 0.00000000, 0.00000000, 4.34741302, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1830
      {-2.64575131, 0.00000000, 9.66091783, 0.68313005, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1831
      {3.24037035, 0.00000000, 0.00000000, 7.52994024, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1832
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
1833
      
 
1834
      static const double dmats2[10][10] = \
 
1835
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1836
      {3.16227766, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1837
      {1.82574186, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1838
      {5.16397779, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1839
      {2.95803989, 5.61248608, -1.08012345, -0.76376262, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1840
      {2.29128785, 1.44913767, 4.18330013, -0.59160798, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1841
      {1.87082869, 7.09929574, 0.00000000, 4.34741302, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1842
      {1.32287566, 0.00000000, 3.86436713, -0.34156503, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1843
      {1.08012345, 0.00000000, 7.09929574, 2.50998008, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1844
      {-3.81881308, 0.00000000, 0.00000000, 8.87411967, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
1845
      
 
1846
      // Compute reference derivatives
 
1847
      // Declare pointer to array of derivatives on FIAT element
 
1848
      double *derivatives = new double [num_derivatives];
 
1849
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1850
      {
 
1851
        derivatives[r] = 0.00000000;
 
1852
      }// end loop over 'r'
 
1853
      
 
1854
      // Declare derivative matrix (of polynomial basis).
 
1855
      double dmats[10][10] = \
 
1856
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1857
      {0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1858
      {0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1859
      {0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1860
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1861
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1862
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1863
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
1864
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
1865
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
1866
      
 
1867
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
1868
      double dmats_old[10][10] = \
 
1869
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1870
      {0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1871
      {0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1872
      {0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1873
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1874
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1875
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
1876
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
1877
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
1878
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
1879
      
 
1880
      // Loop possible derivatives.
 
1881
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1882
      {
 
1883
        // Resetting dmats values to compute next derivative.
 
1884
        for (unsigned int t = 0; t < 10; t++)
 
1885
        {
 
1886
          for (unsigned int u = 0; u < 10; u++)
 
1887
          {
 
1888
            dmats[t][u] = 0.00000000;
 
1889
            if (t == u)
 
1890
            {
 
1891
            dmats[t][u] = 1.00000000;
 
1892
            }
 
1893
            
 
1894
          }// end loop over 'u'
 
1895
        }// end loop over 't'
 
1896
        
 
1897
        // Looping derivative order to generate dmats.
 
1898
        for (unsigned int s = 0; s < n; s++)
 
1899
        {
 
1900
          // Updating dmats_old with new values and resetting dmats.
 
1901
          for (unsigned int t = 0; t < 10; t++)
 
1902
          {
 
1903
            for (unsigned int u = 0; u < 10; u++)
 
1904
            {
 
1905
              dmats_old[t][u] = dmats[t][u];
 
1906
              dmats[t][u] = 0.00000000;
 
1907
            }// end loop over 'u'
 
1908
          }// end loop over 't'
 
1909
          
 
1910
          // Update dmats using an inner product.
 
1911
          if (combinations[r][s] == 0)
 
1912
          {
 
1913
          for (unsigned int t = 0; t < 10; t++)
 
1914
          {
 
1915
            for (unsigned int u = 0; u < 10; u++)
 
1916
            {
 
1917
              for (unsigned int tu = 0; tu < 10; tu++)
 
1918
              {
 
1919
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
1920
              }// end loop over 'tu'
 
1921
            }// end loop over 'u'
 
1922
          }// end loop over 't'
 
1923
          }
 
1924
          
 
1925
          if (combinations[r][s] == 1)
 
1926
          {
 
1927
          for (unsigned int t = 0; t < 10; t++)
 
1928
          {
 
1929
            for (unsigned int u = 0; u < 10; u++)
 
1930
            {
 
1931
              for (unsigned int tu = 0; tu < 10; tu++)
 
1932
              {
 
1933
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
1934
              }// end loop over 'tu'
 
1935
            }// end loop over 'u'
 
1936
          }// end loop over 't'
 
1937
          }
 
1938
          
 
1939
          if (combinations[r][s] == 2)
 
1940
          {
 
1941
          for (unsigned int t = 0; t < 10; t++)
 
1942
          {
 
1943
            for (unsigned int u = 0; u < 10; u++)
 
1944
            {
 
1945
              for (unsigned int tu = 0; tu < 10; tu++)
 
1946
              {
 
1947
                dmats[t][u] += dmats2[t][tu]*dmats_old[tu][u];
 
1948
              }// end loop over 'tu'
 
1949
            }// end loop over 'u'
 
1950
          }// end loop over 't'
 
1951
          }
 
1952
          
 
1953
        }// end loop over 's'
 
1954
        for (unsigned int s = 0; s < 10; s++)
 
1955
        {
 
1956
          for (unsigned int t = 0; t < 10; t++)
 
1957
          {
 
1958
            derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
 
1959
          }// end loop over 't'
 
1960
        }// end loop over 's'
 
1961
      }// end loop over 'r'
 
1962
      
 
1963
      // Transform derivatives back to physical element
 
1964
      for (unsigned int row = 0; row < num_derivatives; row++)
 
1965
      {
 
1966
        for (unsigned int col = 0; col < num_derivatives; col++)
 
1967
        {
 
1968
          values[num_derivatives + row] += transform[row][col]*derivatives[col];
 
1969
        }
 
1970
      }
 
1971
      
 
1972
      // Delete pointer to array of derivatives on FIAT element
 
1973
      delete [] derivatives;
 
1974
      
 
1975
      // Delete pointer to array of combinations of derivatives and transform
 
1976
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1977
      {
 
1978
        delete [] combinations[r];
 
1979
        delete [] transform[r];
 
1980
      }// end loop over 'r'
 
1981
      delete [] combinations;
 
1982
      delete [] transform;
 
1983
    }
 
1984
    
 
1985
    if (20 <= i && i <= 29)
 
1986
    {
 
1987
      // Map degree of freedom to element degree of freedom
 
1988
      const unsigned int dof = i - 20;
 
1989
      
 
1990
      // Array of basisvalues
 
1991
      double basisvalues[10] = {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
1992
      
 
1993
      // Declare helper variables
 
1994
      unsigned int rr = 0;
 
1995
      unsigned int ss = 0;
 
1996
      unsigned int tt = 0;
 
1997
      double tmp5 = 0.00000000;
 
1998
      double tmp6 = 0.00000000;
 
1999
      double tmp7 = 0.00000000;
 
2000
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
2001
      double tmp1 = 0.25000000*(Y + Z)*(Y + Z);
 
2002
      double tmp2 = 0.50000000*(1.00000000 + Z + 2.00000000*Y);
 
2003
      double tmp3 = 0.50000000*(1.00000000 - Z);
 
2004
      double tmp4 = tmp3*tmp3;
 
2005
      
 
2006
      // Compute basisvalues
 
2007
      basisvalues[0] = 1.00000000;
 
2008
      basisvalues[1] = tmp0;
 
2009
      for (unsigned int r = 1; r < 2; r++)
 
2010
      {
 
2011
        rr = (r + 1)*((r + 1) + 1)*((r + 1) + 2)/6;
 
2012
        ss = r*(r + 1)*(r + 2)/6;
 
2013
        tt = (r - 1)*((r - 1) + 1)*((r - 1) + 2)/6;
 
2014
        basisvalues[rr] = (basisvalues[ss]*tmp0*(1.00000000 + 2.00000000*r)/(1.00000000 + r) - basisvalues[tt]*tmp1*r/(1.00000000 + r));
 
2015
      }// end loop over 'r'
 
2016
      for (unsigned int r = 0; r < 2; r++)
 
2017
      {
 
2018
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
2019
        ss = r*(r + 1)*(r + 2)/6;
 
2020
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
2021
      }// end loop over 'r'
 
2022
      for (unsigned int r = 0; r < 1; r++)
 
2023
      {
 
2024
        for (unsigned int s = 1; s < 2 - r; s++)
 
2025
        {
 
2026
          rr = (r + (s + 1))*(r + (s + 1) + 1)*(r + (s + 1) + 2)/6 + (s + 1)*((s + 1) + 1)/2;
 
2027
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
2028
          tt = (r + (s - 1))*(r + (s - 1) + 1)*(r + (s - 1) + 2)/6 + (s - 1)*((s - 1) + 1)/2;
 
2029
          tmp5 = (2.00000000 + 2.00000000*r + 2.00000000*s)*(3.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
2030
          tmp6 = (1.00000000 + 4.00000000*r*r + 4.00000000*r)*(2.00000000 + 2.00000000*r + 2.00000000*s)/(2.00000000*(1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
2031
          tmp7 = (1.00000000 + s + 2.00000000*r)*(3.00000000 + 2.00000000*r + 2.00000000*s)*s/((1.00000000 + 2.00000000*r + 2.00000000*s)*(1.00000000 + s)*(2.00000000 + s + 2.00000000*r));
 
2032
          basisvalues[rr] = (basisvalues[ss]*(tmp2*tmp5 + tmp3*tmp6) - basisvalues[tt]*tmp4*tmp7);
 
2033
        }// end loop over 's'
 
2034
      }// end loop over 'r'
 
2035
      for (unsigned int r = 0; r < 2; r++)
 
2036
      {
 
2037
        for (unsigned int s = 0; s < 2 - r; s++)
 
2038
        {
 
2039
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
2040
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
2041
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
2042
        }// end loop over 's'
 
2043
      }// end loop over 'r'
 
2044
      for (unsigned int r = 0; r < 1; r++)
 
2045
      {
 
2046
        for (unsigned int s = 0; s < 1 - r; s++)
 
2047
        {
 
2048
          for (unsigned int t = 1; t < 2 - r - s; t++)
 
2049
          {
 
2050
            rr = (r + s + t + 1)*(r + s + t + 1 + 1)*(r + s + t + 1 + 2)/6 + (s + t + 1)*(s + t + 1 + 1)/2 + t + 1;
 
2051
            ss = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
2052
            tt = (r + s + t - 1)*(r + s + t - 1 + 1)*(r + s + t - 1 + 2)/6 + (s + t - 1)*(s + t - 1 + 1)/2 + t - 1;
 
2053
            tmp5 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)/(2.00000000*(1.00000000 + t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
2054
            tmp6 = (3.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(4.00000000 + 4.00000000*r*r + 4.00000000*s*s + 8.00000000*r*s + 8.00000000*r + 8.00000000*s)/(2.00000000*(1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
2055
            tmp7 = (2.00000000 + t + 2.00000000*r + 2.00000000*s)*(4.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*t/((1.00000000 + t)*(2.00000000 + 2.00000000*r + 2.00000000*s + 2.00000000*t)*(3.00000000 + t + 2.00000000*r + 2.00000000*s));
 
2056
            basisvalues[rr] = (basisvalues[ss]*(tmp6 + Z*tmp5) - basisvalues[tt]*tmp7);
 
2057
          }// end loop over 't'
 
2058
        }// end loop over 's'
 
2059
      }// end loop over 'r'
 
2060
      for (unsigned int r = 0; r < 3; r++)
 
2061
      {
 
2062
        for (unsigned int s = 0; s < 3 - r; s++)
 
2063
        {
 
2064
          for (unsigned int t = 0; t < 3 - r - s; t++)
 
2065
          {
 
2066
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
2067
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
2068
          }// end loop over 't'
 
2069
        }// end loop over 's'
 
2070
      }// end loop over 'r'
 
2071
      
 
2072
      // Table(s) of coefficients
 
2073
      static const double coefficients0[10][10] = \
 
2074
      {{-0.05773503, -0.06085806, -0.03513642, -0.02484520, 0.06506000, 0.05039526, 0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
2075
      {-0.05773503, 0.06085806, -0.03513642, -0.02484520, 0.06506000, -0.05039526, -0.04114756, 0.02909572, 0.02375655, 0.01679842},
 
2076
      {-0.05773503, 0.00000000, 0.07027284, -0.02484520, 0.00000000, 0.00000000, 0.00000000, 0.08728716, -0.04751311, 0.01679842},
 
2077
      {-0.05773503, 0.00000000, 0.00000000, 0.07453560, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.10079053},
 
2078
      {0.23094011, 0.00000000, 0.14054567, 0.09938080, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.11878277, -0.06719368},
 
2079
      {0.23094011, 0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, 0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
2080
      {0.23094011, 0.12171612, 0.07027284, -0.09938080, 0.00000000, 0.10079053, -0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
2081
      {0.23094011, -0.12171612, -0.07027284, 0.09938080, 0.00000000, 0.00000000, -0.10286890, 0.00000000, -0.05939139, -0.06719368},
 
2082
      {0.23094011, -0.12171612, 0.07027284, -0.09938080, 0.00000000, -0.10079053, 0.02057378, -0.08728716, -0.01187828, 0.01679842},
 
2083
      {0.23094011, 0.00000000, -0.14054567, -0.09938080, -0.13012001, 0.00000000, 0.00000000, 0.02909572, 0.02375655, 0.01679842}};
 
2084
      
 
2085
      // Tables of derivatives of the polynomial base (transpose).
 
2086
      static const double dmats0[10][10] = \
 
2087
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2088
      {6.32455532, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2089
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2090
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2091
      {0.00000000, 11.22497216, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2092
      {4.58257569, 0.00000000, 8.36660027, -1.18321596, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2093
      {3.74165739, 0.00000000, 0.00000000, 8.69482605, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2094
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2095
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2096
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
2097
      
 
2098
      static const double dmats1[10][10] = \
 
2099
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2100
      {3.16227766, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2101
      {5.47722558, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2102
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2103
      {2.95803989, 5.61248608, -1.08012345, -0.76376262, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2104
      {2.29128785, 7.24568837, 4.18330013, -0.59160798, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2105
      {1.87082869, 0.00000000, 0.00000000, 4.34741302, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2106
      {-2.64575131, 0.00000000, 9.66091783, 0.68313005, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2107
      {3.24037035, 0.00000000, 0.00000000, 7.52994024, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2108
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
2109
      
 
2110
      static const double dmats2[10][10] = \
 
2111
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2112
      {3.16227766, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2113
      {1.82574186, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2114
      {5.16397779, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2115
      {2.95803989, 5.61248608, -1.08012345, -0.76376262, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2116
      {2.29128785, 1.44913767, 4.18330013, -0.59160798, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2117
      {1.87082869, 7.09929574, 0.00000000, 4.34741302, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2118
      {1.32287566, 0.00000000, 3.86436713, -0.34156503, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2119
      {1.08012345, 0.00000000, 7.09929574, 2.50998008, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2120
      {-3.81881308, 0.00000000, 0.00000000, 8.87411967, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
2121
      
 
2122
      // Compute reference derivatives
 
2123
      // Declare pointer to array of derivatives on FIAT element
 
2124
      double *derivatives = new double [num_derivatives];
 
2125
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2126
      {
 
2127
        derivatives[r] = 0.00000000;
 
2128
      }// end loop over 'r'
 
2129
      
 
2130
      // Declare derivative matrix (of polynomial basis).
 
2131
      double dmats[10][10] = \
 
2132
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2133
      {0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2134
      {0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2135
      {0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2136
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2137
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2138
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2139
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
2140
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
2141
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
2142
      
 
2143
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
2144
      double dmats_old[10][10] = \
 
2145
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2146
      {0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2147
      {0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2148
      {0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2149
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2150
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2151
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
2152
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
2153
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
2154
      {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
2155
      
 
2156
      // Loop possible derivatives.
 
2157
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2158
      {
 
2159
        // Resetting dmats values to compute next derivative.
 
2160
        for (unsigned int t = 0; t < 10; t++)
 
2161
        {
 
2162
          for (unsigned int u = 0; u < 10; u++)
 
2163
          {
 
2164
            dmats[t][u] = 0.00000000;
 
2165
            if (t == u)
 
2166
            {
 
2167
            dmats[t][u] = 1.00000000;
 
2168
            }
 
2169
            
 
2170
          }// end loop over 'u'
 
2171
        }// end loop over 't'
 
2172
        
 
2173
        // Looping derivative order to generate dmats.
 
2174
        for (unsigned int s = 0; s < n; s++)
 
2175
        {
 
2176
          // Updating dmats_old with new values and resetting dmats.
 
2177
          for (unsigned int t = 0; t < 10; t++)
 
2178
          {
 
2179
            for (unsigned int u = 0; u < 10; u++)
 
2180
            {
 
2181
              dmats_old[t][u] = dmats[t][u];
 
2182
              dmats[t][u] = 0.00000000;
 
2183
            }// end loop over 'u'
 
2184
          }// end loop over 't'
 
2185
          
 
2186
          // Update dmats using an inner product.
 
2187
          if (combinations[r][s] == 0)
 
2188
          {
 
2189
          for (unsigned int t = 0; t < 10; t++)
 
2190
          {
 
2191
            for (unsigned int u = 0; u < 10; u++)
 
2192
            {
 
2193
              for (unsigned int tu = 0; tu < 10; tu++)
 
2194
              {
 
2195
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
2196
              }// end loop over 'tu'
 
2197
            }// end loop over 'u'
 
2198
          }// end loop over 't'
 
2199
          }
 
2200
          
 
2201
          if (combinations[r][s] == 1)
 
2202
          {
 
2203
          for (unsigned int t = 0; t < 10; t++)
 
2204
          {
 
2205
            for (unsigned int u = 0; u < 10; u++)
 
2206
            {
 
2207
              for (unsigned int tu = 0; tu < 10; tu++)
 
2208
              {
 
2209
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
2210
              }// end loop over 'tu'
 
2211
            }// end loop over 'u'
 
2212
          }// end loop over 't'
 
2213
          }
 
2214
          
 
2215
          if (combinations[r][s] == 2)
 
2216
          {
 
2217
          for (unsigned int t = 0; t < 10; t++)
 
2218
          {
 
2219
            for (unsigned int u = 0; u < 10; u++)
 
2220
            {
 
2221
              for (unsigned int tu = 0; tu < 10; tu++)
 
2222
              {
 
2223
                dmats[t][u] += dmats2[t][tu]*dmats_old[tu][u];
 
2224
              }// end loop over 'tu'
 
2225
            }// end loop over 'u'
 
2226
          }// end loop over 't'
 
2227
          }
 
2228
          
 
2229
        }// end loop over 's'
 
2230
        for (unsigned int s = 0; s < 10; s++)
 
2231
        {
 
2232
          for (unsigned int t = 0; t < 10; t++)
 
2233
          {
 
2234
            derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
 
2235
          }// end loop over 't'
 
2236
        }// end loop over 's'
 
2237
      }// end loop over 'r'
 
2238
      
 
2239
      // Transform derivatives back to physical element
 
2240
      for (unsigned int row = 0; row < num_derivatives; row++)
 
2241
      {
 
2242
        for (unsigned int col = 0; col < num_derivatives; col++)
 
2243
        {
 
2244
          values[2*num_derivatives + row] += transform[row][col]*derivatives[col];
 
2245
        }
 
2246
      }
 
2247
      
 
2248
      // Delete pointer to array of derivatives on FIAT element
 
2249
      delete [] derivatives;
 
2250
      
 
2251
      // Delete pointer to array of combinations of derivatives and transform
 
2252
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2253
      {
 
2254
        delete [] combinations[r];
 
2255
        delete [] transform[r];
 
2256
      }// end loop over 'r'
 
2257
      delete [] combinations;
 
2258
      delete [] transform;
 
2259
    }
 
2260
    
 
2261
  }
 
2262
 
 
2263
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
2264
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
2265
                                              double* values,
 
2266
                                              const double* coordinates,
 
2267
                                              const ufc::cell& c) const
 
2268
  {
 
2269
    // Compute number of derivatives.
 
2270
    unsigned int  num_derivatives = 1;
 
2271
    
 
2272
    for (unsigned int r = 0; r < n; r++)
 
2273
    {
 
2274
      num_derivatives *= 3;
 
2275
    }// end loop over 'r'
 
2276
    
 
2277
    // Helper variable to hold values of a single dof.
 
2278
    double *dof_values = new double [3*num_derivatives];
 
2279
    for (unsigned int r = 0; r < 3*num_derivatives; r++)
 
2280
    {
 
2281
      dof_values[r] = 0.00000000;
 
2282
    }// end loop over 'r'
 
2283
    
 
2284
    // Loop dofs and call evaluate_basis_derivatives.
 
2285
    for (unsigned int r = 0; r < 30; r++)
 
2286
    {
 
2287
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
2288
      for (unsigned int s = 0; s < 3*num_derivatives; s++)
 
2289
      {
 
2290
        values[r*3*num_derivatives + s] = dof_values[s];
 
2291
      }// end loop over 's'
 
2292
    }// end loop over 'r'
 
2293
    
 
2294
    // Delete pointer.
 
2295
    delete [] dof_values;
 
2296
  }
 
2297
 
 
2298
  /// Evaluate linear functional for dof i on the function f
 
2299
  virtual double evaluate_dof(unsigned int i,
 
2300
                              const ufc::function& f,
 
2301
                              const ufc::cell& c) const
 
2302
  {
 
2303
    // Declare variables for result of evaluation
 
2304
    double vals[3];
 
2305
    
 
2306
    // Declare variable for physical coordinates
 
2307
    double y[3];
 
2308
    
 
2309
    const double * const * x = c.coordinates;
 
2310
    switch (i)
 
2311
    {
 
2312
    case 0:
 
2313
      {
 
2314
        y[0] = x[0][0];
 
2315
      y[1] = x[0][1];
 
2316
      y[2] = x[0][2];
 
2317
      f.evaluate(vals, y, c);
 
2318
      return vals[0];
 
2319
        break;
 
2320
      }
 
2321
    case 1:
 
2322
      {
 
2323
        y[0] = x[1][0];
 
2324
      y[1] = x[1][1];
 
2325
      y[2] = x[1][2];
 
2326
      f.evaluate(vals, y, c);
 
2327
      return vals[0];
 
2328
        break;
 
2329
      }
 
2330
    case 2:
 
2331
      {
 
2332
        y[0] = x[2][0];
 
2333
      y[1] = x[2][1];
 
2334
      y[2] = x[2][2];
 
2335
      f.evaluate(vals, y, c);
 
2336
      return vals[0];
 
2337
        break;
 
2338
      }
 
2339
    case 3:
 
2340
      {
 
2341
        y[0] = x[3][0];
 
2342
      y[1] = x[3][1];
 
2343
      y[2] = x[3][2];
 
2344
      f.evaluate(vals, y, c);
 
2345
      return vals[0];
 
2346
        break;
 
2347
      }
 
2348
    case 4:
 
2349
      {
 
2350
        y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
2351
      y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
2352
      y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
2353
      f.evaluate(vals, y, c);
 
2354
      return vals[0];
 
2355
        break;
 
2356
      }
 
2357
    case 5:
 
2358
      {
 
2359
        y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
2360
      y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
2361
      y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
2362
      f.evaluate(vals, y, c);
 
2363
      return vals[0];
 
2364
        break;
 
2365
      }
 
2366
    case 6:
 
2367
      {
 
2368
        y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
2369
      y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
2370
      y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
2371
      f.evaluate(vals, y, c);
 
2372
      return vals[0];
 
2373
        break;
 
2374
      }
 
2375
    case 7:
 
2376
      {
 
2377
        y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
2378
      y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
2379
      y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
2380
      f.evaluate(vals, y, c);
 
2381
      return vals[0];
 
2382
        break;
 
2383
      }
 
2384
    case 8:
 
2385
      {
 
2386
        y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
2387
      y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
2388
      y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
2389
      f.evaluate(vals, y, c);
 
2390
      return vals[0];
 
2391
        break;
 
2392
      }
 
2393
    case 9:
 
2394
      {
 
2395
        y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
2396
      y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
2397
      y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
2398
      f.evaluate(vals, y, c);
 
2399
      return vals[0];
 
2400
        break;
 
2401
      }
 
2402
    case 10:
 
2403
      {
 
2404
        y[0] = x[0][0];
 
2405
      y[1] = x[0][1];
 
2406
      y[2] = x[0][2];
 
2407
      f.evaluate(vals, y, c);
 
2408
      return vals[1];
 
2409
        break;
 
2410
      }
 
2411
    case 11:
 
2412
      {
 
2413
        y[0] = x[1][0];
 
2414
      y[1] = x[1][1];
 
2415
      y[2] = x[1][2];
 
2416
      f.evaluate(vals, y, c);
 
2417
      return vals[1];
 
2418
        break;
 
2419
      }
 
2420
    case 12:
 
2421
      {
 
2422
        y[0] = x[2][0];
 
2423
      y[1] = x[2][1];
 
2424
      y[2] = x[2][2];
 
2425
      f.evaluate(vals, y, c);
 
2426
      return vals[1];
 
2427
        break;
 
2428
      }
 
2429
    case 13:
 
2430
      {
 
2431
        y[0] = x[3][0];
 
2432
      y[1] = x[3][1];
 
2433
      y[2] = x[3][2];
 
2434
      f.evaluate(vals, y, c);
 
2435
      return vals[1];
 
2436
        break;
 
2437
      }
 
2438
    case 14:
 
2439
      {
 
2440
        y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
2441
      y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
2442
      y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
2443
      f.evaluate(vals, y, c);
 
2444
      return vals[1];
 
2445
        break;
 
2446
      }
 
2447
    case 15:
 
2448
      {
 
2449
        y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
2450
      y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
2451
      y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
2452
      f.evaluate(vals, y, c);
 
2453
      return vals[1];
 
2454
        break;
 
2455
      }
 
2456
    case 16:
 
2457
      {
 
2458
        y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
2459
      y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
2460
      y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
2461
      f.evaluate(vals, y, c);
 
2462
      return vals[1];
 
2463
        break;
 
2464
      }
 
2465
    case 17:
 
2466
      {
 
2467
        y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
2468
      y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
2469
      y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
2470
      f.evaluate(vals, y, c);
 
2471
      return vals[1];
 
2472
        break;
 
2473
      }
 
2474
    case 18:
 
2475
      {
 
2476
        y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
2477
      y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
2478
      y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
2479
      f.evaluate(vals, y, c);
 
2480
      return vals[1];
 
2481
        break;
 
2482
      }
 
2483
    case 19:
 
2484
      {
 
2485
        y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
2486
      y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
2487
      y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
2488
      f.evaluate(vals, y, c);
 
2489
      return vals[1];
 
2490
        break;
 
2491
      }
 
2492
    case 20:
 
2493
      {
 
2494
        y[0] = x[0][0];
 
2495
      y[1] = x[0][1];
 
2496
      y[2] = x[0][2];
 
2497
      f.evaluate(vals, y, c);
 
2498
      return vals[2];
 
2499
        break;
 
2500
      }
 
2501
    case 21:
 
2502
      {
 
2503
        y[0] = x[1][0];
 
2504
      y[1] = x[1][1];
 
2505
      y[2] = x[1][2];
 
2506
      f.evaluate(vals, y, c);
 
2507
      return vals[2];
 
2508
        break;
 
2509
      }
 
2510
    case 22:
 
2511
      {
 
2512
        y[0] = x[2][0];
 
2513
      y[1] = x[2][1];
 
2514
      y[2] = x[2][2];
 
2515
      f.evaluate(vals, y, c);
 
2516
      return vals[2];
 
2517
        break;
 
2518
      }
 
2519
    case 23:
 
2520
      {
 
2521
        y[0] = x[3][0];
 
2522
      y[1] = x[3][1];
 
2523
      y[2] = x[3][2];
 
2524
      f.evaluate(vals, y, c);
 
2525
      return vals[2];
 
2526
        break;
 
2527
      }
 
2528
    case 24:
 
2529
      {
 
2530
        y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
2531
      y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
2532
      y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
2533
      f.evaluate(vals, y, c);
 
2534
      return vals[2];
 
2535
        break;
 
2536
      }
 
2537
    case 25:
 
2538
      {
 
2539
        y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
2540
      y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
2541
      y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
2542
      f.evaluate(vals, y, c);
 
2543
      return vals[2];
 
2544
        break;
 
2545
      }
 
2546
    case 26:
 
2547
      {
 
2548
        y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
2549
      y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
2550
      y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
2551
      f.evaluate(vals, y, c);
 
2552
      return vals[2];
 
2553
        break;
 
2554
      }
 
2555
    case 27:
 
2556
      {
 
2557
        y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
2558
      y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
2559
      y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
2560
      f.evaluate(vals, y, c);
 
2561
      return vals[2];
 
2562
        break;
 
2563
      }
 
2564
    case 28:
 
2565
      {
 
2566
        y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
2567
      y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
2568
      y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
2569
      f.evaluate(vals, y, c);
 
2570
      return vals[2];
 
2571
        break;
 
2572
      }
 
2573
    case 29:
 
2574
      {
 
2575
        y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
2576
      y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
2577
      y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
2578
      f.evaluate(vals, y, c);
 
2579
      return vals[2];
 
2580
        break;
 
2581
      }
 
2582
    }
 
2583
    
 
2584
    return 0.0;
 
2585
  }
 
2586
 
 
2587
  /// Evaluate linear functionals for all dofs on the function f
 
2588
  virtual void evaluate_dofs(double* values,
 
2589
                             const ufc::function& f,
 
2590
                             const ufc::cell& c) const
 
2591
  {
 
2592
    // Declare variables for result of evaluation
 
2593
    double vals[3];
 
2594
    
 
2595
    // Declare variable for physical coordinates
 
2596
    double y[3];
 
2597
    
 
2598
    const double * const * x = c.coordinates;
 
2599
    y[0] = x[0][0];
 
2600
    y[1] = x[0][1];
 
2601
    y[2] = x[0][2];
 
2602
    f.evaluate(vals, y, c);
 
2603
    values[0] = vals[0];
 
2604
    y[0] = x[1][0];
 
2605
    y[1] = x[1][1];
 
2606
    y[2] = x[1][2];
 
2607
    f.evaluate(vals, y, c);
 
2608
    values[1] = vals[0];
 
2609
    y[0] = x[2][0];
 
2610
    y[1] = x[2][1];
 
2611
    y[2] = x[2][2];
 
2612
    f.evaluate(vals, y, c);
 
2613
    values[2] = vals[0];
 
2614
    y[0] = x[3][0];
 
2615
    y[1] = x[3][1];
 
2616
    y[2] = x[3][2];
 
2617
    f.evaluate(vals, y, c);
 
2618
    values[3] = vals[0];
 
2619
    y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
2620
    y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
2621
    y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
2622
    f.evaluate(vals, y, c);
 
2623
    values[4] = vals[0];
 
2624
    y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
2625
    y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
2626
    y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
2627
    f.evaluate(vals, y, c);
 
2628
    values[5] = vals[0];
 
2629
    y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
2630
    y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
2631
    y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
2632
    f.evaluate(vals, y, c);
 
2633
    values[6] = vals[0];
 
2634
    y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
2635
    y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
2636
    y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
2637
    f.evaluate(vals, y, c);
 
2638
    values[7] = vals[0];
 
2639
    y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
2640
    y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
2641
    y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
2642
    f.evaluate(vals, y, c);
 
2643
    values[8] = vals[0];
 
2644
    y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
2645
    y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
2646
    y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
2647
    f.evaluate(vals, y, c);
 
2648
    values[9] = vals[0];
 
2649
    y[0] = x[0][0];
 
2650
    y[1] = x[0][1];
 
2651
    y[2] = x[0][2];
 
2652
    f.evaluate(vals, y, c);
 
2653
    values[10] = vals[1];
 
2654
    y[0] = x[1][0];
 
2655
    y[1] = x[1][1];
 
2656
    y[2] = x[1][2];
 
2657
    f.evaluate(vals, y, c);
 
2658
    values[11] = vals[1];
 
2659
    y[0] = x[2][0];
 
2660
    y[1] = x[2][1];
 
2661
    y[2] = x[2][2];
 
2662
    f.evaluate(vals, y, c);
 
2663
    values[12] = vals[1];
 
2664
    y[0] = x[3][0];
 
2665
    y[1] = x[3][1];
 
2666
    y[2] = x[3][2];
 
2667
    f.evaluate(vals, y, c);
 
2668
    values[13] = vals[1];
 
2669
    y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
2670
    y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
2671
    y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
2672
    f.evaluate(vals, y, c);
 
2673
    values[14] = vals[1];
 
2674
    y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
2675
    y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
2676
    y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
2677
    f.evaluate(vals, y, c);
 
2678
    values[15] = vals[1];
 
2679
    y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
2680
    y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
2681
    y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
2682
    f.evaluate(vals, y, c);
 
2683
    values[16] = vals[1];
 
2684
    y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
2685
    y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
2686
    y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
2687
    f.evaluate(vals, y, c);
 
2688
    values[17] = vals[1];
 
2689
    y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
2690
    y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
2691
    y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
2692
    f.evaluate(vals, y, c);
 
2693
    values[18] = vals[1];
 
2694
    y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
2695
    y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
2696
    y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
2697
    f.evaluate(vals, y, c);
 
2698
    values[19] = vals[1];
 
2699
    y[0] = x[0][0];
 
2700
    y[1] = x[0][1];
 
2701
    y[2] = x[0][2];
 
2702
    f.evaluate(vals, y, c);
 
2703
    values[20] = vals[2];
 
2704
    y[0] = x[1][0];
 
2705
    y[1] = x[1][1];
 
2706
    y[2] = x[1][2];
 
2707
    f.evaluate(vals, y, c);
 
2708
    values[21] = vals[2];
 
2709
    y[0] = x[2][0];
 
2710
    y[1] = x[2][1];
 
2711
    y[2] = x[2][2];
 
2712
    f.evaluate(vals, y, c);
 
2713
    values[22] = vals[2];
 
2714
    y[0] = x[3][0];
 
2715
    y[1] = x[3][1];
 
2716
    y[2] = x[3][2];
 
2717
    f.evaluate(vals, y, c);
 
2718
    values[23] = vals[2];
 
2719
    y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
2720
    y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
2721
    y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
2722
    f.evaluate(vals, y, c);
 
2723
    values[24] = vals[2];
 
2724
    y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
2725
    y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
2726
    y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
2727
    f.evaluate(vals, y, c);
 
2728
    values[25] = vals[2];
 
2729
    y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
2730
    y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
2731
    y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
2732
    f.evaluate(vals, y, c);
 
2733
    values[26] = vals[2];
 
2734
    y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
2735
    y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
2736
    y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
2737
    f.evaluate(vals, y, c);
 
2738
    values[27] = vals[2];
 
2739
    y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
2740
    y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
2741
    y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
2742
    f.evaluate(vals, y, c);
 
2743
    values[28] = vals[2];
 
2744
    y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
2745
    y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
2746
    y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
2747
    f.evaluate(vals, y, c);
 
2748
    values[29] = vals[2];
 
2749
  }
 
2750
 
 
2751
  /// Interpolate vertex values from dof values
 
2752
  virtual void interpolate_vertex_values(double* vertex_values,
 
2753
                                         const double* dof_values,
 
2754
                                         const ufc::cell& c) const
 
2755
  {
 
2756
    // Evaluate function and change variables
 
2757
    vertex_values[0] = dof_values[0];
 
2758
    vertex_values[3] = dof_values[1];
 
2759
    vertex_values[6] = dof_values[2];
 
2760
    vertex_values[9] = dof_values[3];
 
2761
    // Evaluate function and change variables
 
2762
    vertex_values[1] = dof_values[10];
 
2763
    vertex_values[4] = dof_values[11];
 
2764
    vertex_values[7] = dof_values[12];
 
2765
    vertex_values[10] = dof_values[13];
 
2766
    // Evaluate function and change variables
 
2767
    vertex_values[2] = dof_values[20];
 
2768
    vertex_values[5] = dof_values[21];
 
2769
    vertex_values[8] = dof_values[22];
 
2770
    vertex_values[11] = dof_values[23];
 
2771
  }
 
2772
 
 
2773
  /// Return the number of sub elements (for a mixed element)
 
2774
  virtual unsigned int num_sub_elements() const
 
2775
  {
 
2776
    return 3;
 
2777
  }
 
2778
 
 
2779
  /// Create a new finite element for sub element i (for a mixed element)
 
2780
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
2781
  {
 
2782
    switch (i)
 
2783
    {
 
2784
    case 0:
 
2785
      {
 
2786
        return new vectorlaplacegradcurl_finite_element_0();
 
2787
        break;
 
2788
      }
 
2789
    case 1:
 
2790
      {
 
2791
        return new vectorlaplacegradcurl_finite_element_0();
 
2792
        break;
 
2793
      }
 
2794
    case 2:
 
2795
      {
 
2796
        return new vectorlaplacegradcurl_finite_element_0();
 
2797
        break;
 
2798
      }
 
2799
    }
 
2800
    
 
2801
    return 0;
 
2802
  }
 
2803
 
 
2804
};
 
2805
 
 
2806
/// This class defines the interface for a finite element.
 
2807
 
 
2808
class vectorlaplacegradcurl_finite_element_2: public ufc::finite_element
 
2809
{
 
2810
public:
 
2811
 
 
2812
  /// Constructor
 
2813
  vectorlaplacegradcurl_finite_element_2() : ufc::finite_element()
 
2814
  {
 
2815
    // Do nothing
 
2816
  }
 
2817
 
 
2818
  /// Destructor
 
2819
  virtual ~vectorlaplacegradcurl_finite_element_2()
 
2820
  {
 
2821
    // Do nothing
 
2822
  }
 
2823
 
 
2824
  /// Return a string identifying the finite element
 
2825
  virtual const char* signature() const
 
2826
  {
 
2827
    return "FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1)";
 
2828
  }
 
2829
 
 
2830
  /// Return the cell shape
 
2831
  virtual ufc::shape cell_shape() const
 
2832
  {
 
2833
    return ufc::tetrahedron;
 
2834
  }
 
2835
 
 
2836
  /// Return the dimension of the finite element function space
 
2837
  virtual unsigned int space_dimension() const
 
2838
  {
 
2839
    return 4;
 
2840
  }
 
2841
 
 
2842
  /// Return the rank of the value space
 
2843
  virtual unsigned int value_rank() const
 
2844
  {
 
2845
    return 0;
 
2846
  }
 
2847
 
 
2848
  /// Return the dimension of the value space for axis i
 
2849
  virtual unsigned int value_dimension(unsigned int i) const
 
2850
  {
 
2851
    return 1;
 
2852
  }
 
2853
 
 
2854
  /// Evaluate basis function i at given point in cell
 
2855
  virtual void evaluate_basis(unsigned int i,
 
2856
                              double* values,
 
2857
                              const double* coordinates,
 
2858
                              const ufc::cell& c) const
 
2859
  {
 
2860
    // Extract vertex coordinates
 
2861
    const double * const * x = c.coordinates;
 
2862
    
 
2863
    // Compute Jacobian of affine map from reference cell
 
2864
    const double J_00 = x[1][0] - x[0][0];
 
2865
    const double J_01 = x[2][0] - x[0][0];
 
2866
    const double J_02 = x[3][0] - x[0][0];
 
2867
    const double J_10 = x[1][1] - x[0][1];
 
2868
    const double J_11 = x[2][1] - x[0][1];
 
2869
    const double J_12 = x[3][1] - x[0][1];
 
2870
    const double J_20 = x[1][2] - x[0][2];
 
2871
    const double J_21 = x[2][2] - x[0][2];
 
2872
    const double J_22 = x[3][2] - x[0][2];
 
2873
    
 
2874
    // Compute sub determinants
 
2875
    const double d_00 = J_11*J_22 - J_12*J_21;
 
2876
    const double d_01 = J_12*J_20 - J_10*J_22;
 
2877
    const double d_02 = J_10*J_21 - J_11*J_20;
 
2878
    const double d_10 = J_02*J_21 - J_01*J_22;
 
2879
    const double d_11 = J_00*J_22 - J_02*J_20;
 
2880
    const double d_12 = J_01*J_20 - J_00*J_21;
 
2881
    const double d_20 = J_01*J_12 - J_02*J_11;
 
2882
    const double d_21 = J_02*J_10 - J_00*J_12;
 
2883
    const double d_22 = J_00*J_11 - J_01*J_10;
 
2884
    
 
2885
    // Compute determinant of Jacobian
 
2886
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
2887
    
 
2888
    // Compute inverse of Jacobian
 
2889
    
 
2890
    // Compute constants
 
2891
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
2892
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
2893
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
2894
    
 
2895
    // Get coordinates and map to the reference (FIAT) element
 
2896
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
2897
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
2898
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
2899
    
 
2900
    
 
2901
    // Reset values
 
2902
    *values = 0.00000000;
 
2903
    
 
2904
    // Map degree of freedom to element degree of freedom
 
2905
    const unsigned int dof = i;
 
2906
    
 
2907
    // Array of basisvalues
 
2908
    double basisvalues[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
2909
    
 
2910
    // Declare helper variables
 
2911
    unsigned int rr = 0;
 
2912
    unsigned int ss = 0;
 
2913
    double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
2914
    
 
2915
    // Compute basisvalues
 
2916
    basisvalues[0] = 1.00000000;
 
2917
    basisvalues[1] = tmp0;
 
2918
    for (unsigned int r = 0; r < 1; r++)
 
2919
    {
 
2920
      rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
2921
      ss = r*(r + 1)*(r + 2)/6;
 
2922
      basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
2923
    }// end loop over 'r'
 
2924
    for (unsigned int r = 0; r < 1; r++)
 
2925
    {
 
2926
      for (unsigned int s = 0; s < 1 - r; s++)
 
2927
      {
 
2928
        rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
2929
        ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
2930
        basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
2931
      }// end loop over 's'
 
2932
    }// end loop over 'r'
 
2933
    for (unsigned int r = 0; r < 2; r++)
 
2934
    {
 
2935
      for (unsigned int s = 0; s < 2 - r; s++)
 
2936
      {
 
2937
        for (unsigned int t = 0; t < 2 - r - s; t++)
 
2938
        {
 
2939
          rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
2940
          basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
2941
        }// end loop over 't'
 
2942
      }// end loop over 's'
 
2943
    }// end loop over 'r'
 
2944
    
 
2945
    // Table(s) of coefficients
 
2946
    static const double coefficients0[4][4] = \
 
2947
    {{0.28867513, -0.18257419, -0.10540926, -0.07453560},
 
2948
    {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
2949
    {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
2950
    {0.28867513, 0.00000000, 0.00000000, 0.22360680}};
 
2951
    
 
2952
    // Compute value(s).
 
2953
    for (unsigned int r = 0; r < 4; r++)
 
2954
    {
 
2955
      *values += coefficients0[dof][r]*basisvalues[r];
 
2956
    }// end loop over 'r'
 
2957
  }
 
2958
 
 
2959
  /// Evaluate all basis functions at given point in cell
 
2960
  virtual void evaluate_basis_all(double* values,
 
2961
                                  const double* coordinates,
 
2962
                                  const ufc::cell& c) const
 
2963
  {
 
2964
    // Helper variable to hold values of a single dof.
 
2965
    double dof_values = 0.00000000;
 
2966
    
 
2967
    // Loop dofs and call evaluate_basis.
 
2968
    for (unsigned int r = 0; r < 4; r++)
 
2969
    {
 
2970
      evaluate_basis(r, &dof_values, coordinates, c);
 
2971
      values[r] = dof_values;
 
2972
    }// end loop over 'r'
 
2973
  }
 
2974
 
 
2975
  /// Evaluate order n derivatives of basis function i at given point in cell
 
2976
  virtual void evaluate_basis_derivatives(unsigned int i,
 
2977
                                          unsigned int n,
 
2978
                                          double* values,
 
2979
                                          const double* coordinates,
 
2980
                                          const ufc::cell& c) const
 
2981
  {
 
2982
    // Extract vertex coordinates
 
2983
    const double * const * x = c.coordinates;
 
2984
    
 
2985
    // Compute Jacobian of affine map from reference cell
 
2986
    const double J_00 = x[1][0] - x[0][0];
 
2987
    const double J_01 = x[2][0] - x[0][0];
 
2988
    const double J_02 = x[3][0] - x[0][0];
 
2989
    const double J_10 = x[1][1] - x[0][1];
 
2990
    const double J_11 = x[2][1] - x[0][1];
 
2991
    const double J_12 = x[3][1] - x[0][1];
 
2992
    const double J_20 = x[1][2] - x[0][2];
 
2993
    const double J_21 = x[2][2] - x[0][2];
 
2994
    const double J_22 = x[3][2] - x[0][2];
 
2995
    
 
2996
    // Compute sub determinants
 
2997
    const double d_00 = J_11*J_22 - J_12*J_21;
 
2998
    const double d_01 = J_12*J_20 - J_10*J_22;
 
2999
    const double d_02 = J_10*J_21 - J_11*J_20;
 
3000
    const double d_10 = J_02*J_21 - J_01*J_22;
 
3001
    const double d_11 = J_00*J_22 - J_02*J_20;
 
3002
    const double d_12 = J_01*J_20 - J_00*J_21;
 
3003
    const double d_20 = J_01*J_12 - J_02*J_11;
 
3004
    const double d_21 = J_02*J_10 - J_00*J_12;
 
3005
    const double d_22 = J_00*J_11 - J_01*J_10;
 
3006
    
 
3007
    // Compute determinant of Jacobian
 
3008
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
3009
    
 
3010
    // Compute inverse of Jacobian
 
3011
    const double K_00 = d_00 / detJ;
 
3012
    const double K_01 = d_10 / detJ;
 
3013
    const double K_02 = d_20 / detJ;
 
3014
    const double K_10 = d_01 / detJ;
 
3015
    const double K_11 = d_11 / detJ;
 
3016
    const double K_12 = d_21 / detJ;
 
3017
    const double K_20 = d_02 / detJ;
 
3018
    const double K_21 = d_12 / detJ;
 
3019
    const double K_22 = d_22 / detJ;
 
3020
    
 
3021
    // Compute constants
 
3022
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
3023
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
3024
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
3025
    
 
3026
    // Get coordinates and map to the reference (FIAT) element
 
3027
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
3028
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
3029
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
3030
    
 
3031
    
 
3032
    // Compute number of derivatives.
 
3033
    unsigned int  num_derivatives = 1;
 
3034
    
 
3035
    for (unsigned int r = 0; r < n; r++)
 
3036
    {
 
3037
      num_derivatives *= 3;
 
3038
    }// end loop over 'r'
 
3039
    
 
3040
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
3041
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
3042
    for (unsigned int row = 0; row < num_derivatives; row++)
 
3043
    {
 
3044
      combinations[row] = new unsigned int [n];
 
3045
      for (unsigned int col = 0; col < n; col++)
 
3046
        combinations[row][col] = 0;
 
3047
    }
 
3048
    
 
3049
    // Generate combinations of derivatives
 
3050
    for (unsigned int row = 1; row < num_derivatives; row++)
 
3051
    {
 
3052
      for (unsigned int num = 0; num < row; num++)
 
3053
      {
 
3054
        for (unsigned int col = n-1; col+1 > 0; col--)
 
3055
        {
 
3056
          if (combinations[row][col] + 1 > 2)
 
3057
            combinations[row][col] = 0;
 
3058
          else
 
3059
          {
 
3060
            combinations[row][col] += 1;
 
3061
            break;
 
3062
          }
 
3063
        }
 
3064
      }
 
3065
    }
 
3066
    
 
3067
    // Compute inverse of Jacobian
 
3068
    const double Jinv[3][3] = {{K_00, K_01, K_02}, {K_10, K_11, K_12}, {K_20, K_21, K_22}};
 
3069
    
 
3070
    // Declare transformation matrix
 
3071
    // Declare pointer to two dimensional array and initialise
 
3072
    double **transform = new double *[num_derivatives];
 
3073
    
 
3074
    for (unsigned int j = 0; j < num_derivatives; j++)
 
3075
    {
 
3076
      transform[j] = new double [num_derivatives];
 
3077
      for (unsigned int k = 0; k < num_derivatives; k++)
 
3078
        transform[j][k] = 1;
 
3079
    }
 
3080
    
 
3081
    // Construct transformation matrix
 
3082
    for (unsigned int row = 0; row < num_derivatives; row++)
 
3083
    {
 
3084
      for (unsigned int col = 0; col < num_derivatives; col++)
 
3085
      {
 
3086
        for (unsigned int k = 0; k < n; k++)
 
3087
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
3088
      }
 
3089
    }
 
3090
    
 
3091
    // Reset values. Assuming that values is always an array.
 
3092
    for (unsigned int r = 0; r < num_derivatives; r++)
 
3093
    {
 
3094
      values[r] = 0.00000000;
 
3095
    }// end loop over 'r'
 
3096
    
 
3097
    // Map degree of freedom to element degree of freedom
 
3098
    const unsigned int dof = i;
 
3099
    
 
3100
    // Array of basisvalues
 
3101
    double basisvalues[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
3102
    
 
3103
    // Declare helper variables
 
3104
    unsigned int rr = 0;
 
3105
    unsigned int ss = 0;
 
3106
    double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
3107
    
 
3108
    // Compute basisvalues
 
3109
    basisvalues[0] = 1.00000000;
 
3110
    basisvalues[1] = tmp0;
 
3111
    for (unsigned int r = 0; r < 1; r++)
 
3112
    {
 
3113
      rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
3114
      ss = r*(r + 1)*(r + 2)/6;
 
3115
      basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
3116
    }// end loop over 'r'
 
3117
    for (unsigned int r = 0; r < 1; r++)
 
3118
    {
 
3119
      for (unsigned int s = 0; s < 1 - r; s++)
 
3120
      {
 
3121
        rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
3122
        ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
3123
        basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
3124
      }// end loop over 's'
 
3125
    }// end loop over 'r'
 
3126
    for (unsigned int r = 0; r < 2; r++)
 
3127
    {
 
3128
      for (unsigned int s = 0; s < 2 - r; s++)
 
3129
      {
 
3130
        for (unsigned int t = 0; t < 2 - r - s; t++)
 
3131
        {
 
3132
          rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
3133
          basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
3134
        }// end loop over 't'
 
3135
      }// end loop over 's'
 
3136
    }// end loop over 'r'
 
3137
    
 
3138
    // Table(s) of coefficients
 
3139
    static const double coefficients0[4][4] = \
 
3140
    {{0.28867513, -0.18257419, -0.10540926, -0.07453560},
 
3141
    {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
3142
    {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
3143
    {0.28867513, 0.00000000, 0.00000000, 0.22360680}};
 
3144
    
 
3145
    // Tables of derivatives of the polynomial base (transpose).
 
3146
    static const double dmats0[4][4] = \
 
3147
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3148
    {6.32455532, 0.00000000, 0.00000000, 0.00000000},
 
3149
    {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3150
    {0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
3151
    
 
3152
    static const double dmats1[4][4] = \
 
3153
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3154
    {3.16227766, 0.00000000, 0.00000000, 0.00000000},
 
3155
    {5.47722558, 0.00000000, 0.00000000, 0.00000000},
 
3156
    {0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
3157
    
 
3158
    static const double dmats2[4][4] = \
 
3159
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3160
    {3.16227766, 0.00000000, 0.00000000, 0.00000000},
 
3161
    {1.82574186, 0.00000000, 0.00000000, 0.00000000},
 
3162
    {5.16397779, 0.00000000, 0.00000000, 0.00000000}};
 
3163
    
 
3164
    // Compute reference derivatives
 
3165
    // Declare pointer to array of derivatives on FIAT element
 
3166
    double *derivatives = new double [num_derivatives];
 
3167
    for (unsigned int r = 0; r < num_derivatives; r++)
 
3168
    {
 
3169
      derivatives[r] = 0.00000000;
 
3170
    }// end loop over 'r'
 
3171
    
 
3172
    // Declare derivative matrix (of polynomial basis).
 
3173
    double dmats[4][4] = \
 
3174
    {{1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3175
    {0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
3176
    {0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
3177
    {0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
3178
    
 
3179
    // Declare (auxiliary) derivative matrix (of polynomial basis).
 
3180
    double dmats_old[4][4] = \
 
3181
    {{1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3182
    {0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
3183
    {0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
3184
    {0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
3185
    
 
3186
    // Loop possible derivatives.
 
3187
    for (unsigned int r = 0; r < num_derivatives; r++)
 
3188
    {
 
3189
      // Resetting dmats values to compute next derivative.
 
3190
      for (unsigned int t = 0; t < 4; t++)
 
3191
      {
 
3192
        for (unsigned int u = 0; u < 4; u++)
 
3193
        {
 
3194
          dmats[t][u] = 0.00000000;
 
3195
          if (t == u)
 
3196
          {
 
3197
          dmats[t][u] = 1.00000000;
 
3198
          }
 
3199
          
 
3200
        }// end loop over 'u'
 
3201
      }// end loop over 't'
 
3202
      
 
3203
      // Looping derivative order to generate dmats.
 
3204
      for (unsigned int s = 0; s < n; s++)
 
3205
      {
 
3206
        // Updating dmats_old with new values and resetting dmats.
 
3207
        for (unsigned int t = 0; t < 4; t++)
 
3208
        {
 
3209
          for (unsigned int u = 0; u < 4; u++)
 
3210
          {
 
3211
            dmats_old[t][u] = dmats[t][u];
 
3212
            dmats[t][u] = 0.00000000;
 
3213
          }// end loop over 'u'
 
3214
        }// end loop over 't'
 
3215
        
 
3216
        // Update dmats using an inner product.
 
3217
        if (combinations[r][s] == 0)
 
3218
        {
 
3219
        for (unsigned int t = 0; t < 4; t++)
 
3220
        {
 
3221
          for (unsigned int u = 0; u < 4; u++)
 
3222
          {
 
3223
            for (unsigned int tu = 0; tu < 4; tu++)
 
3224
            {
 
3225
              dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
3226
            }// end loop over 'tu'
 
3227
          }// end loop over 'u'
 
3228
        }// end loop over 't'
 
3229
        }
 
3230
        
 
3231
        if (combinations[r][s] == 1)
 
3232
        {
 
3233
        for (unsigned int t = 0; t < 4; t++)
 
3234
        {
 
3235
          for (unsigned int u = 0; u < 4; u++)
 
3236
          {
 
3237
            for (unsigned int tu = 0; tu < 4; tu++)
 
3238
            {
 
3239
              dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
3240
            }// end loop over 'tu'
 
3241
          }// end loop over 'u'
 
3242
        }// end loop over 't'
 
3243
        }
 
3244
        
 
3245
        if (combinations[r][s] == 2)
 
3246
        {
 
3247
        for (unsigned int t = 0; t < 4; t++)
 
3248
        {
 
3249
          for (unsigned int u = 0; u < 4; u++)
 
3250
          {
 
3251
            for (unsigned int tu = 0; tu < 4; tu++)
 
3252
            {
 
3253
              dmats[t][u] += dmats2[t][tu]*dmats_old[tu][u];
 
3254
            }// end loop over 'tu'
 
3255
          }// end loop over 'u'
 
3256
        }// end loop over 't'
 
3257
        }
 
3258
        
 
3259
      }// end loop over 's'
 
3260
      for (unsigned int s = 0; s < 4; s++)
 
3261
      {
 
3262
        for (unsigned int t = 0; t < 4; t++)
 
3263
        {
 
3264
          derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
 
3265
        }// end loop over 't'
 
3266
      }// end loop over 's'
 
3267
    }// end loop over 'r'
 
3268
    
 
3269
    // Transform derivatives back to physical element
 
3270
    for (unsigned int row = 0; row < num_derivatives; row++)
 
3271
    {
 
3272
      for (unsigned int col = 0; col < num_derivatives; col++)
 
3273
      {
 
3274
        values[row] += transform[row][col]*derivatives[col];
 
3275
      }
 
3276
    }
 
3277
    
 
3278
    // Delete pointer to array of derivatives on FIAT element
 
3279
    delete [] derivatives;
 
3280
    
 
3281
    // Delete pointer to array of combinations of derivatives and transform
 
3282
    for (unsigned int r = 0; r < num_derivatives; r++)
 
3283
    {
 
3284
      delete [] combinations[r];
 
3285
      delete [] transform[r];
 
3286
    }// end loop over 'r'
 
3287
    delete [] combinations;
 
3288
    delete [] transform;
 
3289
  }
 
3290
 
 
3291
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
3292
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
3293
                                              double* values,
 
3294
                                              const double* coordinates,
 
3295
                                              const ufc::cell& c) const
 
3296
  {
 
3297
    // Compute number of derivatives.
 
3298
    unsigned int  num_derivatives = 1;
 
3299
    
 
3300
    for (unsigned int r = 0; r < n; r++)
 
3301
    {
 
3302
      num_derivatives *= 3;
 
3303
    }// end loop over 'r'
 
3304
    
 
3305
    // Helper variable to hold values of a single dof.
 
3306
    double *dof_values = new double [num_derivatives];
 
3307
    for (unsigned int r = 0; r < num_derivatives; r++)
 
3308
    {
 
3309
      dof_values[r] = 0.00000000;
 
3310
    }// end loop over 'r'
 
3311
    
 
3312
    // Loop dofs and call evaluate_basis_derivatives.
 
3313
    for (unsigned int r = 0; r < 4; r++)
 
3314
    {
 
3315
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
3316
      for (unsigned int s = 0; s < num_derivatives; s++)
 
3317
      {
 
3318
        values[r*num_derivatives + s] = dof_values[s];
 
3319
      }// end loop over 's'
 
3320
    }// end loop over 'r'
 
3321
    
 
3322
    // Delete pointer.
 
3323
    delete [] dof_values;
 
3324
  }
 
3325
 
 
3326
  /// Evaluate linear functional for dof i on the function f
 
3327
  virtual double evaluate_dof(unsigned int i,
 
3328
                              const ufc::function& f,
 
3329
                              const ufc::cell& c) const
 
3330
  {
 
3331
    // Declare variables for result of evaluation
 
3332
    double vals[1];
 
3333
    
 
3334
    // Declare variable for physical coordinates
 
3335
    double y[3];
 
3336
    
 
3337
    const double * const * x = c.coordinates;
 
3338
    switch (i)
 
3339
    {
 
3340
    case 0:
 
3341
      {
 
3342
        y[0] = x[0][0];
 
3343
      y[1] = x[0][1];
 
3344
      y[2] = x[0][2];
 
3345
      f.evaluate(vals, y, c);
 
3346
      return vals[0];
 
3347
        break;
 
3348
      }
 
3349
    case 1:
 
3350
      {
 
3351
        y[0] = x[1][0];
 
3352
      y[1] = x[1][1];
 
3353
      y[2] = x[1][2];
 
3354
      f.evaluate(vals, y, c);
 
3355
      return vals[0];
 
3356
        break;
 
3357
      }
 
3358
    case 2:
 
3359
      {
 
3360
        y[0] = x[2][0];
 
3361
      y[1] = x[2][1];
 
3362
      y[2] = x[2][2];
 
3363
      f.evaluate(vals, y, c);
 
3364
      return vals[0];
 
3365
        break;
 
3366
      }
 
3367
    case 3:
 
3368
      {
 
3369
        y[0] = x[3][0];
 
3370
      y[1] = x[3][1];
 
3371
      y[2] = x[3][2];
 
3372
      f.evaluate(vals, y, c);
 
3373
      return vals[0];
 
3374
        break;
 
3375
      }
 
3376
    }
 
3377
    
 
3378
    return 0.0;
 
3379
  }
 
3380
 
 
3381
  /// Evaluate linear functionals for all dofs on the function f
 
3382
  virtual void evaluate_dofs(double* values,
 
3383
                             const ufc::function& f,
 
3384
                             const ufc::cell& c) const
 
3385
  {
 
3386
    // Declare variables for result of evaluation
 
3387
    double vals[1];
 
3388
    
 
3389
    // Declare variable for physical coordinates
 
3390
    double y[3];
 
3391
    
 
3392
    const double * const * x = c.coordinates;
 
3393
    y[0] = x[0][0];
 
3394
    y[1] = x[0][1];
 
3395
    y[2] = x[0][2];
 
3396
    f.evaluate(vals, y, c);
 
3397
    values[0] = vals[0];
 
3398
    y[0] = x[1][0];
 
3399
    y[1] = x[1][1];
 
3400
    y[2] = x[1][2];
 
3401
    f.evaluate(vals, y, c);
 
3402
    values[1] = vals[0];
 
3403
    y[0] = x[2][0];
 
3404
    y[1] = x[2][1];
 
3405
    y[2] = x[2][2];
 
3406
    f.evaluate(vals, y, c);
 
3407
    values[2] = vals[0];
 
3408
    y[0] = x[3][0];
 
3409
    y[1] = x[3][1];
 
3410
    y[2] = x[3][2];
 
3411
    f.evaluate(vals, y, c);
 
3412
    values[3] = vals[0];
 
3413
  }
 
3414
 
 
3415
  /// Interpolate vertex values from dof values
 
3416
  virtual void interpolate_vertex_values(double* vertex_values,
 
3417
                                         const double* dof_values,
 
3418
                                         const ufc::cell& c) const
 
3419
  {
 
3420
    // Evaluate function and change variables
 
3421
    vertex_values[0] = dof_values[0];
 
3422
    vertex_values[1] = dof_values[1];
 
3423
    vertex_values[2] = dof_values[2];
 
3424
    vertex_values[3] = dof_values[3];
 
3425
  }
 
3426
 
 
3427
  /// Return the number of sub elements (for a mixed element)
 
3428
  virtual unsigned int num_sub_elements() const
 
3429
  {
 
3430
    return 0;
 
3431
  }
 
3432
 
 
3433
  /// Create a new finite element for sub element i (for a mixed element)
 
3434
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
3435
  {
 
3436
    return 0;
 
3437
  }
 
3438
 
 
3439
};
 
3440
 
 
3441
/// This class defines the interface for a finite element.
 
3442
 
 
3443
class vectorlaplacegradcurl_finite_element_3: public ufc::finite_element
 
3444
{
 
3445
public:
 
3446
 
 
3447
  /// Constructor
 
3448
  vectorlaplacegradcurl_finite_element_3() : ufc::finite_element()
 
3449
  {
 
3450
    // Do nothing
 
3451
  }
 
3452
 
 
3453
  /// Destructor
 
3454
  virtual ~vectorlaplacegradcurl_finite_element_3()
 
3455
  {
 
3456
    // Do nothing
 
3457
  }
 
3458
 
 
3459
  /// Return a string identifying the finite element
 
3460
  virtual const char* signature() const
 
3461
  {
 
3462
    return "FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)";
 
3463
  }
 
3464
 
 
3465
  /// Return the cell shape
 
3466
  virtual ufc::shape cell_shape() const
 
3467
  {
 
3468
    return ufc::tetrahedron;
 
3469
  }
 
3470
 
 
3471
  /// Return the dimension of the finite element function space
 
3472
  virtual unsigned int space_dimension() const
 
3473
  {
 
3474
    return 6;
 
3475
  }
 
3476
 
 
3477
  /// Return the rank of the value space
 
3478
  virtual unsigned int value_rank() const
 
3479
  {
 
3480
    return 1;
 
3481
  }
 
3482
 
 
3483
  /// Return the dimension of the value space for axis i
 
3484
  virtual unsigned int value_dimension(unsigned int i) const
 
3485
  {
 
3486
    switch (i)
 
3487
    {
 
3488
    case 0:
 
3489
      {
 
3490
        return 3;
 
3491
        break;
 
3492
      }
 
3493
    }
 
3494
    
 
3495
    return 0;
 
3496
  }
 
3497
 
 
3498
  /// Evaluate basis function i at given point in cell
 
3499
  virtual void evaluate_basis(unsigned int i,
 
3500
                              double* values,
 
3501
                              const double* coordinates,
 
3502
                              const ufc::cell& c) const
 
3503
  {
 
3504
    // Extract vertex coordinates
 
3505
    const double * const * x = c.coordinates;
 
3506
    
 
3507
    // Compute Jacobian of affine map from reference cell
 
3508
    const double J_00 = x[1][0] - x[0][0];
 
3509
    const double J_01 = x[2][0] - x[0][0];
 
3510
    const double J_02 = x[3][0] - x[0][0];
 
3511
    const double J_10 = x[1][1] - x[0][1];
 
3512
    const double J_11 = x[2][1] - x[0][1];
 
3513
    const double J_12 = x[3][1] - x[0][1];
 
3514
    const double J_20 = x[1][2] - x[0][2];
 
3515
    const double J_21 = x[2][2] - x[0][2];
 
3516
    const double J_22 = x[3][2] - x[0][2];
 
3517
    
 
3518
    // Compute sub determinants
 
3519
    const double d_00 = J_11*J_22 - J_12*J_21;
 
3520
    const double d_01 = J_12*J_20 - J_10*J_22;
 
3521
    const double d_02 = J_10*J_21 - J_11*J_20;
 
3522
    const double d_10 = J_02*J_21 - J_01*J_22;
 
3523
    const double d_11 = J_00*J_22 - J_02*J_20;
 
3524
    const double d_12 = J_01*J_20 - J_00*J_21;
 
3525
    const double d_20 = J_01*J_12 - J_02*J_11;
 
3526
    const double d_21 = J_02*J_10 - J_00*J_12;
 
3527
    const double d_22 = J_00*J_11 - J_01*J_10;
 
3528
    
 
3529
    // Compute determinant of Jacobian
 
3530
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
3531
    
 
3532
    // Compute inverse of Jacobian
 
3533
    const double K_00 = d_00 / detJ;
 
3534
    const double K_01 = d_10 / detJ;
 
3535
    const double K_02 = d_20 / detJ;
 
3536
    const double K_10 = d_01 / detJ;
 
3537
    const double K_11 = d_11 / detJ;
 
3538
    const double K_12 = d_21 / detJ;
 
3539
    const double K_20 = d_02 / detJ;
 
3540
    const double K_21 = d_12 / detJ;
 
3541
    const double K_22 = d_22 / detJ;
 
3542
    
 
3543
    // Compute constants
 
3544
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
3545
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
3546
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
3547
    
 
3548
    // Get coordinates and map to the reference (FIAT) element
 
3549
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
3550
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
3551
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
3552
    
 
3553
    
 
3554
    // Reset values
 
3555
    values[0] = 0.00000000;
 
3556
    values[1] = 0.00000000;
 
3557
    values[2] = 0.00000000;
 
3558
    
 
3559
    // Map degree of freedom to element degree of freedom
 
3560
    const unsigned int dof = i;
 
3561
    
 
3562
    // Array of basisvalues
 
3563
    double basisvalues[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
3564
    
 
3565
    // Declare helper variables
 
3566
    unsigned int rr = 0;
 
3567
    unsigned int ss = 0;
 
3568
    double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
3569
    
 
3570
    // Compute basisvalues
 
3571
    basisvalues[0] = 1.00000000;
 
3572
    basisvalues[1] = tmp0;
 
3573
    for (unsigned int r = 0; r < 1; r++)
 
3574
    {
 
3575
      rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
3576
      ss = r*(r + 1)*(r + 2)/6;
 
3577
      basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
3578
    }// end loop over 'r'
 
3579
    for (unsigned int r = 0; r < 1; r++)
 
3580
    {
 
3581
      for (unsigned int s = 0; s < 1 - r; s++)
 
3582
      {
 
3583
        rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
3584
        ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
3585
        basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
3586
      }// end loop over 's'
 
3587
    }// end loop over 'r'
 
3588
    for (unsigned int r = 0; r < 2; r++)
 
3589
    {
 
3590
      for (unsigned int s = 0; s < 2 - r; s++)
 
3591
      {
 
3592
        for (unsigned int t = 0; t < 2 - r - s; t++)
 
3593
        {
 
3594
          rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
3595
          basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
3596
        }// end loop over 't'
 
3597
      }// end loop over 's'
 
3598
    }// end loop over 'r'
 
3599
    
 
3600
    // Table(s) of coefficients
 
3601
    static const double coefficients0[6][4] = \
 
3602
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3603
    {-0.28867513, 0.00000000, 0.00000000, -0.22360680},
 
3604
    {-0.28867513, 0.00000000, -0.21081851, 0.07453560},
 
3605
    {0.28867513, 0.00000000, 0.00000000, 0.22360680},
 
3606
    {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
3607
    {0.57735027, 0.00000000, -0.21081851, -0.14907120}};
 
3608
    
 
3609
    static const double coefficients1[6][4] = \
 
3610
    {{-0.28867513, 0.00000000, 0.00000000, -0.22360680},
 
3611
    {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3612
    {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
3613
    {0.28867513, 0.00000000, 0.00000000, 0.22360680},
 
3614
    {0.57735027, -0.18257419, 0.10540926, -0.14907120},
 
3615
    {0.28867513, 0.18257419, -0.10540926, -0.07453560}};
 
3616
    
 
3617
    static const double coefficients2[6][4] = \
 
3618
    {{0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
3619
    {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
3620
    {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3621
    {0.57735027, -0.18257419, -0.10540926, 0.14907120},
 
3622
    {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
3623
    {0.28867513, 0.18257419, -0.10540926, -0.07453560}};
 
3624
    
 
3625
    // Compute value(s).
 
3626
    for (unsigned int r = 0; r < 4; r++)
 
3627
    {
 
3628
      values[0] += coefficients0[dof][r]*basisvalues[r];
 
3629
      values[1] += coefficients1[dof][r]*basisvalues[r];
 
3630
      values[2] += coefficients2[dof][r]*basisvalues[r];
 
3631
    }// end loop over 'r'
 
3632
    
 
3633
    // Using covariant Piola transform to map values back to the physical element
 
3634
    const double tmp_ref0 = values[0];
 
3635
    const double tmp_ref1 = values[1];
 
3636
    const double tmp_ref2 = values[2];
 
3637
    values[0] = (K_00*tmp_ref0 + K_10*tmp_ref1 + K_20*tmp_ref2);
 
3638
    values[1] = (K_01*tmp_ref0 + K_11*tmp_ref1 + K_21*tmp_ref2);
 
3639
    values[2] = (K_02*tmp_ref0 + K_12*tmp_ref1 + K_22*tmp_ref2);
 
3640
  }
 
3641
 
 
3642
  /// Evaluate all basis functions at given point in cell
 
3643
  virtual void evaluate_basis_all(double* values,
 
3644
                                  const double* coordinates,
 
3645
                                  const ufc::cell& c) const
 
3646
  {
 
3647
    // Helper variable to hold values of a single dof.
 
3648
    double dof_values[3] = {0.00000000, 0.00000000, 0.00000000};
 
3649
    
 
3650
    // Loop dofs and call evaluate_basis.
 
3651
    for (unsigned int r = 0; r < 6; r++)
 
3652
    {
 
3653
      evaluate_basis(r, dof_values, coordinates, c);
 
3654
      for (unsigned int s = 0; s < 3; s++)
 
3655
      {
 
3656
        values[r*3 + s] = dof_values[s];
 
3657
      }// end loop over 's'
 
3658
    }// end loop over 'r'
 
3659
  }
 
3660
 
 
3661
  /// Evaluate order n derivatives of basis function i at given point in cell
 
3662
  virtual void evaluate_basis_derivatives(unsigned int i,
 
3663
                                          unsigned int n,
 
3664
                                          double* values,
 
3665
                                          const double* coordinates,
 
3666
                                          const ufc::cell& c) const
 
3667
  {
 
3668
    // Extract vertex coordinates
 
3669
    const double * const * x = c.coordinates;
 
3670
    
 
3671
    // Compute Jacobian of affine map from reference cell
 
3672
    const double J_00 = x[1][0] - x[0][0];
 
3673
    const double J_01 = x[2][0] - x[0][0];
 
3674
    const double J_02 = x[3][0] - x[0][0];
 
3675
    const double J_10 = x[1][1] - x[0][1];
 
3676
    const double J_11 = x[2][1] - x[0][1];
 
3677
    const double J_12 = x[3][1] - x[0][1];
 
3678
    const double J_20 = x[1][2] - x[0][2];
 
3679
    const double J_21 = x[2][2] - x[0][2];
 
3680
    const double J_22 = x[3][2] - x[0][2];
 
3681
    
 
3682
    // Compute sub determinants
 
3683
    const double d_00 = J_11*J_22 - J_12*J_21;
 
3684
    const double d_01 = J_12*J_20 - J_10*J_22;
 
3685
    const double d_02 = J_10*J_21 - J_11*J_20;
 
3686
    const double d_10 = J_02*J_21 - J_01*J_22;
 
3687
    const double d_11 = J_00*J_22 - J_02*J_20;
 
3688
    const double d_12 = J_01*J_20 - J_00*J_21;
 
3689
    const double d_20 = J_01*J_12 - J_02*J_11;
 
3690
    const double d_21 = J_02*J_10 - J_00*J_12;
 
3691
    const double d_22 = J_00*J_11 - J_01*J_10;
 
3692
    
 
3693
    // Compute determinant of Jacobian
 
3694
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
3695
    
 
3696
    // Compute inverse of Jacobian
 
3697
    const double K_00 = d_00 / detJ;
 
3698
    const double K_01 = d_10 / detJ;
 
3699
    const double K_02 = d_20 / detJ;
 
3700
    const double K_10 = d_01 / detJ;
 
3701
    const double K_11 = d_11 / detJ;
 
3702
    const double K_12 = d_21 / detJ;
 
3703
    const double K_20 = d_02 / detJ;
 
3704
    const double K_21 = d_12 / detJ;
 
3705
    const double K_22 = d_22 / detJ;
 
3706
    
 
3707
    // Compute constants
 
3708
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
3709
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
3710
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
3711
    
 
3712
    // Get coordinates and map to the reference (FIAT) element
 
3713
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
3714
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
3715
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
3716
    
 
3717
    
 
3718
    // Compute number of derivatives.
 
3719
    unsigned int  num_derivatives = 1;
 
3720
    
 
3721
    for (unsigned int r = 0; r < n; r++)
 
3722
    {
 
3723
      num_derivatives *= 3;
 
3724
    }// end loop over 'r'
 
3725
    
 
3726
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
3727
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
3728
    for (unsigned int row = 0; row < num_derivatives; row++)
 
3729
    {
 
3730
      combinations[row] = new unsigned int [n];
 
3731
      for (unsigned int col = 0; col < n; col++)
 
3732
        combinations[row][col] = 0;
 
3733
    }
 
3734
    
 
3735
    // Generate combinations of derivatives
 
3736
    for (unsigned int row = 1; row < num_derivatives; row++)
 
3737
    {
 
3738
      for (unsigned int num = 0; num < row; num++)
 
3739
      {
 
3740
        for (unsigned int col = n-1; col+1 > 0; col--)
 
3741
        {
 
3742
          if (combinations[row][col] + 1 > 2)
 
3743
            combinations[row][col] = 0;
 
3744
          else
 
3745
          {
 
3746
            combinations[row][col] += 1;
 
3747
            break;
 
3748
          }
 
3749
        }
 
3750
      }
 
3751
    }
 
3752
    
 
3753
    // Compute inverse of Jacobian
 
3754
    const double Jinv[3][3] = {{K_00, K_01, K_02}, {K_10, K_11, K_12}, {K_20, K_21, K_22}};
 
3755
    
 
3756
    // Declare transformation matrix
 
3757
    // Declare pointer to two dimensional array and initialise
 
3758
    double **transform = new double *[num_derivatives];
 
3759
    
 
3760
    for (unsigned int j = 0; j < num_derivatives; j++)
 
3761
    {
 
3762
      transform[j] = new double [num_derivatives];
 
3763
      for (unsigned int k = 0; k < num_derivatives; k++)
 
3764
        transform[j][k] = 1;
 
3765
    }
 
3766
    
 
3767
    // Construct transformation matrix
 
3768
    for (unsigned int row = 0; row < num_derivatives; row++)
 
3769
    {
 
3770
      for (unsigned int col = 0; col < num_derivatives; col++)
 
3771
      {
 
3772
        for (unsigned int k = 0; k < n; k++)
 
3773
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
3774
      }
 
3775
    }
 
3776
    
 
3777
    // Reset values. Assuming that values is always an array.
 
3778
    for (unsigned int r = 0; r < 3*num_derivatives; r++)
 
3779
    {
 
3780
      values[r] = 0.00000000;
 
3781
    }// end loop over 'r'
 
3782
    
 
3783
    // Map degree of freedom to element degree of freedom
 
3784
    const unsigned int dof = i;
 
3785
    
 
3786
    // Array of basisvalues
 
3787
    double basisvalues[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
3788
    
 
3789
    // Declare helper variables
 
3790
    unsigned int rr = 0;
 
3791
    unsigned int ss = 0;
 
3792
    double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
3793
    
 
3794
    // Compute basisvalues
 
3795
    basisvalues[0] = 1.00000000;
 
3796
    basisvalues[1] = tmp0;
 
3797
    for (unsigned int r = 0; r < 1; r++)
 
3798
    {
 
3799
      rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
3800
      ss = r*(r + 1)*(r + 2)/6;
 
3801
      basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
3802
    }// end loop over 'r'
 
3803
    for (unsigned int r = 0; r < 1; r++)
 
3804
    {
 
3805
      for (unsigned int s = 0; s < 1 - r; s++)
 
3806
      {
 
3807
        rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
3808
        ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
3809
        basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
3810
      }// end loop over 's'
 
3811
    }// end loop over 'r'
 
3812
    for (unsigned int r = 0; r < 2; r++)
 
3813
    {
 
3814
      for (unsigned int s = 0; s < 2 - r; s++)
 
3815
      {
 
3816
        for (unsigned int t = 0; t < 2 - r - s; t++)
 
3817
        {
 
3818
          rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
3819
          basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
3820
        }// end loop over 't'
 
3821
      }// end loop over 's'
 
3822
    }// end loop over 'r'
 
3823
    
 
3824
    // Table(s) of coefficients
 
3825
    static const double coefficients0[6][4] = \
 
3826
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3827
    {-0.28867513, 0.00000000, 0.00000000, -0.22360680},
 
3828
    {-0.28867513, 0.00000000, -0.21081851, 0.07453560},
 
3829
    {0.28867513, 0.00000000, 0.00000000, 0.22360680},
 
3830
    {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
3831
    {0.57735027, 0.00000000, -0.21081851, -0.14907120}};
 
3832
    
 
3833
    static const double coefficients1[6][4] = \
 
3834
    {{-0.28867513, 0.00000000, 0.00000000, -0.22360680},
 
3835
    {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3836
    {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
3837
    {0.28867513, 0.00000000, 0.00000000, 0.22360680},
 
3838
    {0.57735027, -0.18257419, 0.10540926, -0.14907120},
 
3839
    {0.28867513, 0.18257419, -0.10540926, -0.07453560}};
 
3840
    
 
3841
    static const double coefficients2[6][4] = \
 
3842
    {{0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
3843
    {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
3844
    {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3845
    {0.57735027, -0.18257419, -0.10540926, 0.14907120},
 
3846
    {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
3847
    {0.28867513, 0.18257419, -0.10540926, -0.07453560}};
 
3848
    
 
3849
    // Tables of derivatives of the polynomial base (transpose).
 
3850
    static const double dmats0[4][4] = \
 
3851
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3852
    {6.32455532, 0.00000000, 0.00000000, 0.00000000},
 
3853
    {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3854
    {0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
3855
    
 
3856
    static const double dmats1[4][4] = \
 
3857
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3858
    {3.16227766, 0.00000000, 0.00000000, 0.00000000},
 
3859
    {5.47722558, 0.00000000, 0.00000000, 0.00000000},
 
3860
    {0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
3861
    
 
3862
    static const double dmats2[4][4] = \
 
3863
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3864
    {3.16227766, 0.00000000, 0.00000000, 0.00000000},
 
3865
    {1.82574186, 0.00000000, 0.00000000, 0.00000000},
 
3866
    {5.16397779, 0.00000000, 0.00000000, 0.00000000}};
 
3867
    
 
3868
    // Compute reference derivatives
 
3869
    // Declare pointer to array of derivatives on FIAT element
 
3870
    double *derivatives = new double [3*num_derivatives];
 
3871
    for (unsigned int r = 0; r < 3*num_derivatives; r++)
 
3872
    {
 
3873
      derivatives[r] = 0.00000000;
 
3874
    }// end loop over 'r'
 
3875
    
 
3876
    // Declare derivative matrix (of polynomial basis).
 
3877
    double dmats[4][4] = \
 
3878
    {{1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3879
    {0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
3880
    {0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
3881
    {0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
3882
    
 
3883
    // Declare (auxiliary) derivative matrix (of polynomial basis).
 
3884
    double dmats_old[4][4] = \
 
3885
    {{1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
3886
    {0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
3887
    {0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
3888
    {0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
3889
    
 
3890
    // Loop possible derivatives.
 
3891
    for (unsigned int r = 0; r < num_derivatives; r++)
 
3892
    {
 
3893
      // Resetting dmats values to compute next derivative.
 
3894
      for (unsigned int t = 0; t < 4; t++)
 
3895
      {
 
3896
        for (unsigned int u = 0; u < 4; u++)
 
3897
        {
 
3898
          dmats[t][u] = 0.00000000;
 
3899
          if (t == u)
 
3900
          {
 
3901
          dmats[t][u] = 1.00000000;
 
3902
          }
 
3903
          
 
3904
        }// end loop over 'u'
 
3905
      }// end loop over 't'
 
3906
      
 
3907
      // Looping derivative order to generate dmats.
 
3908
      for (unsigned int s = 0; s < n; s++)
 
3909
      {
 
3910
        // Updating dmats_old with new values and resetting dmats.
 
3911
        for (unsigned int t = 0; t < 4; t++)
 
3912
        {
 
3913
          for (unsigned int u = 0; u < 4; u++)
 
3914
          {
 
3915
            dmats_old[t][u] = dmats[t][u];
 
3916
            dmats[t][u] = 0.00000000;
 
3917
          }// end loop over 'u'
 
3918
        }// end loop over 't'
 
3919
        
 
3920
        // Update dmats using an inner product.
 
3921
        if (combinations[r][s] == 0)
 
3922
        {
 
3923
        for (unsigned int t = 0; t < 4; t++)
 
3924
        {
 
3925
          for (unsigned int u = 0; u < 4; u++)
 
3926
          {
 
3927
            for (unsigned int tu = 0; tu < 4; tu++)
 
3928
            {
 
3929
              dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
3930
            }// end loop over 'tu'
 
3931
          }// end loop over 'u'
 
3932
        }// end loop over 't'
 
3933
        }
 
3934
        
 
3935
        if (combinations[r][s] == 1)
 
3936
        {
 
3937
        for (unsigned int t = 0; t < 4; t++)
 
3938
        {
 
3939
          for (unsigned int u = 0; u < 4; u++)
 
3940
          {
 
3941
            for (unsigned int tu = 0; tu < 4; tu++)
 
3942
            {
 
3943
              dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
3944
            }// end loop over 'tu'
 
3945
          }// end loop over 'u'
 
3946
        }// end loop over 't'
 
3947
        }
 
3948
        
 
3949
        if (combinations[r][s] == 2)
 
3950
        {
 
3951
        for (unsigned int t = 0; t < 4; t++)
 
3952
        {
 
3953
          for (unsigned int u = 0; u < 4; u++)
 
3954
          {
 
3955
            for (unsigned int tu = 0; tu < 4; tu++)
 
3956
            {
 
3957
              dmats[t][u] += dmats2[t][tu]*dmats_old[tu][u];
 
3958
            }// end loop over 'tu'
 
3959
          }// end loop over 'u'
 
3960
        }// end loop over 't'
 
3961
        }
 
3962
        
 
3963
      }// end loop over 's'
 
3964
      for (unsigned int s = 0; s < 4; s++)
 
3965
      {
 
3966
        for (unsigned int t = 0; t < 4; t++)
 
3967
        {
 
3968
          derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
 
3969
          derivatives[num_derivatives + r] += coefficients1[dof][s]*dmats[s][t]*basisvalues[t];
 
3970
          derivatives[2*num_derivatives + r] += coefficients2[dof][s]*dmats[s][t]*basisvalues[t];
 
3971
        }// end loop over 't'
 
3972
      }// end loop over 's'
 
3973
      
 
3974
      // Using covariant Piola transform to map values back to the physical element
 
3975
      const double tmp_ref0 = derivatives[r];
 
3976
      const double tmp_ref1 = derivatives[num_derivatives + r];
 
3977
      const double tmp_ref2 = derivatives[2*num_derivatives + r];
 
3978
      derivatives[r] = (K_00*tmp_ref0 + K_10*tmp_ref1 + K_20*tmp_ref2);
 
3979
      derivatives[num_derivatives + r] = (K_01*tmp_ref0 + K_11*tmp_ref1 + K_21*tmp_ref2);
 
3980
      derivatives[2*num_derivatives + r] = (K_02*tmp_ref0 + K_12*tmp_ref1 + K_22*tmp_ref2);
 
3981
    }// end loop over 'r'
 
3982
    
 
3983
    // Transform derivatives back to physical element
 
3984
    for (unsigned int row = 0; row < num_derivatives; row++)
 
3985
    {
 
3986
      for (unsigned int col = 0; col < num_derivatives; col++)
 
3987
      {
 
3988
        values[row] += transform[row][col]*derivatives[col];
 
3989
        values[num_derivatives + row] += transform[row][col]*derivatives[num_derivatives + col];
 
3990
        values[2*num_derivatives + row] += transform[row][col]*derivatives[2*num_derivatives + col];
 
3991
      }
 
3992
    }
 
3993
    
 
3994
    // Delete pointer to array of derivatives on FIAT element
 
3995
    delete [] derivatives;
 
3996
    
 
3997
    // Delete pointer to array of combinations of derivatives and transform
 
3998
    for (unsigned int r = 0; r < num_derivatives; r++)
 
3999
    {
 
4000
      delete [] combinations[r];
 
4001
      delete [] transform[r];
 
4002
    }// end loop over 'r'
 
4003
    delete [] combinations;
 
4004
    delete [] transform;
 
4005
  }
 
4006
 
 
4007
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
4008
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
4009
                                              double* values,
 
4010
                                              const double* coordinates,
 
4011
                                              const ufc::cell& c) const
 
4012
  {
 
4013
    // Compute number of derivatives.
 
4014
    unsigned int  num_derivatives = 1;
 
4015
    
 
4016
    for (unsigned int r = 0; r < n; r++)
 
4017
    {
 
4018
      num_derivatives *= 3;
 
4019
    }// end loop over 'r'
 
4020
    
 
4021
    // Helper variable to hold values of a single dof.
 
4022
    double *dof_values = new double [3*num_derivatives];
 
4023
    for (unsigned int r = 0; r < 3*num_derivatives; r++)
 
4024
    {
 
4025
      dof_values[r] = 0.00000000;
 
4026
    }// end loop over 'r'
 
4027
    
 
4028
    // Loop dofs and call evaluate_basis_derivatives.
 
4029
    for (unsigned int r = 0; r < 6; r++)
 
4030
    {
 
4031
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
4032
      for (unsigned int s = 0; s < 3*num_derivatives; s++)
 
4033
      {
 
4034
        values[r*3*num_derivatives + s] = dof_values[s];
 
4035
      }// end loop over 's'
 
4036
    }// end loop over 'r'
 
4037
    
 
4038
    // Delete pointer.
 
4039
    delete [] dof_values;
 
4040
  }
 
4041
 
 
4042
  /// Evaluate linear functional for dof i on the function f
 
4043
  virtual double evaluate_dof(unsigned int i,
 
4044
                              const ufc::function& f,
 
4045
                              const ufc::cell& c) const
 
4046
  {
 
4047
    // Declare variables for result of evaluation
 
4048
    double vals[3];
 
4049
    
 
4050
    // Declare variable for physical coordinates
 
4051
    double y[3];
 
4052
    
 
4053
    double result;
 
4054
    
 
4055
    // Extract vertex coordinates
 
4056
    const double * const * x = c.coordinates;
 
4057
    
 
4058
    // Compute Jacobian of affine map from reference cell
 
4059
    const double J_00 = x[1][0] - x[0][0];
 
4060
    const double J_01 = x[2][0] - x[0][0];
 
4061
    const double J_02 = x[3][0] - x[0][0];
 
4062
    const double J_10 = x[1][1] - x[0][1];
 
4063
    const double J_11 = x[2][1] - x[0][1];
 
4064
    const double J_12 = x[3][1] - x[0][1];
 
4065
    const double J_20 = x[1][2] - x[0][2];
 
4066
    const double J_21 = x[2][2] - x[0][2];
 
4067
    const double J_22 = x[3][2] - x[0][2];switch (i)
 
4068
    {
 
4069
    case 0:
 
4070
      {
 
4071
        y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
4072
      y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
4073
      y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
4074
      f.evaluate(vals, y, c);
 
4075
      result = (-1.0)*(J_01*vals[0] + J_11*vals[1] + J_21*vals[2]) + (J_02*vals[0] + J_12*vals[1] + J_22*vals[2]);
 
4076
      return result;
 
4077
        break;
 
4078
      }
 
4079
    case 1:
 
4080
      {
 
4081
        y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
4082
      y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
4083
      y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
4084
      f.evaluate(vals, y, c);
 
4085
      result = (-1.0)*(J_00*vals[0] + J_10*vals[1] + J_20*vals[2]) + (J_02*vals[0] + J_12*vals[1] + J_22*vals[2]);
 
4086
      return result;
 
4087
        break;
 
4088
      }
 
4089
    case 2:
 
4090
      {
 
4091
        y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
4092
      y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
4093
      y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
4094
      f.evaluate(vals, y, c);
 
4095
      result = (-1.0)*(J_00*vals[0] + J_10*vals[1] + J_20*vals[2]) + (J_01*vals[0] + J_11*vals[1] + J_21*vals[2]);
 
4096
      return result;
 
4097
        break;
 
4098
      }
 
4099
    case 3:
 
4100
      {
 
4101
        y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
4102
      y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
4103
      y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
4104
      f.evaluate(vals, y, c);
 
4105
      result = (J_02*vals[0] + J_12*vals[1] + J_22*vals[2]);
 
4106
      return result;
 
4107
        break;
 
4108
      }
 
4109
    case 4:
 
4110
      {
 
4111
        y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
4112
      y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
4113
      y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
4114
      f.evaluate(vals, y, c);
 
4115
      result = (J_01*vals[0] + J_11*vals[1] + J_21*vals[2]);
 
4116
      return result;
 
4117
        break;
 
4118
      }
 
4119
    case 5:
 
4120
      {
 
4121
        y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
4122
      y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
4123
      y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
4124
      f.evaluate(vals, y, c);
 
4125
      result = (J_00*vals[0] + J_10*vals[1] + J_20*vals[2]);
 
4126
      return result;
 
4127
        break;
 
4128
      }
 
4129
    }
 
4130
    
 
4131
    return 0.0;
 
4132
  }
 
4133
 
 
4134
  /// Evaluate linear functionals for all dofs on the function f
 
4135
  virtual void evaluate_dofs(double* values,
 
4136
                             const ufc::function& f,
 
4137
                             const ufc::cell& c) const
 
4138
  {
 
4139
    // Declare variables for result of evaluation
 
4140
    double vals[3];
 
4141
    
 
4142
    // Declare variable for physical coordinates
 
4143
    double y[3];
 
4144
    
 
4145
    double result;
 
4146
    
 
4147
    // Extract vertex coordinates
 
4148
    const double * const * x = c.coordinates;
 
4149
    
 
4150
    // Compute Jacobian of affine map from reference cell
 
4151
    const double J_00 = x[1][0] - x[0][0];
 
4152
    const double J_01 = x[2][0] - x[0][0];
 
4153
    const double J_02 = x[3][0] - x[0][0];
 
4154
    const double J_10 = x[1][1] - x[0][1];
 
4155
    const double J_11 = x[2][1] - x[0][1];
 
4156
    const double J_12 = x[3][1] - x[0][1];
 
4157
    const double J_20 = x[1][2] - x[0][2];
 
4158
    const double J_21 = x[2][2] - x[0][2];
 
4159
    const double J_22 = x[3][2] - x[0][2];y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
4160
    y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
4161
    y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
4162
    f.evaluate(vals, y, c);
 
4163
    result = (-1.0)*(J_01*vals[0] + J_11*vals[1] + J_21*vals[2]) + (J_02*vals[0] + J_12*vals[1] + J_22*vals[2]);
 
4164
    values[0] = result;
 
4165
    y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
4166
    y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
4167
    y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
4168
    f.evaluate(vals, y, c);
 
4169
    result = (-1.0)*(J_00*vals[0] + J_10*vals[1] + J_20*vals[2]) + (J_02*vals[0] + J_12*vals[1] + J_22*vals[2]);
 
4170
    values[1] = result;
 
4171
    y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
4172
    y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
4173
    y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
4174
    f.evaluate(vals, y, c);
 
4175
    result = (-1.0)*(J_00*vals[0] + J_10*vals[1] + J_20*vals[2]) + (J_01*vals[0] + J_11*vals[1] + J_21*vals[2]);
 
4176
    values[2] = result;
 
4177
    y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
4178
    y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
4179
    y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
4180
    f.evaluate(vals, y, c);
 
4181
    result = (J_02*vals[0] + J_12*vals[1] + J_22*vals[2]);
 
4182
    values[3] = result;
 
4183
    y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
4184
    y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
4185
    y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
4186
    f.evaluate(vals, y, c);
 
4187
    result = (J_01*vals[0] + J_11*vals[1] + J_21*vals[2]);
 
4188
    values[4] = result;
 
4189
    y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
4190
    y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
4191
    y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
4192
    f.evaluate(vals, y, c);
 
4193
    result = (J_00*vals[0] + J_10*vals[1] + J_20*vals[2]);
 
4194
    values[5] = result;
 
4195
  }
 
4196
 
 
4197
  /// Interpolate vertex values from dof values
 
4198
  virtual void interpolate_vertex_values(double* vertex_values,
 
4199
                                         const double* dof_values,
 
4200
                                         const ufc::cell& c) const
 
4201
  {
 
4202
    // Extract vertex coordinates
 
4203
    const double * const * x = c.coordinates;
 
4204
    
 
4205
    // Compute Jacobian of affine map from reference cell
 
4206
    const double J_00 = x[1][0] - x[0][0];
 
4207
    const double J_01 = x[2][0] - x[0][0];
 
4208
    const double J_02 = x[3][0] - x[0][0];
 
4209
    const double J_10 = x[1][1] - x[0][1];
 
4210
    const double J_11 = x[2][1] - x[0][1];
 
4211
    const double J_12 = x[3][1] - x[0][1];
 
4212
    const double J_20 = x[1][2] - x[0][2];
 
4213
    const double J_21 = x[2][2] - x[0][2];
 
4214
    const double J_22 = x[3][2] - x[0][2];
 
4215
    
 
4216
    // Compute sub determinants
 
4217
    const double d_00 = J_11*J_22 - J_12*J_21;
 
4218
    const double d_01 = J_12*J_20 - J_10*J_22;
 
4219
    const double d_02 = J_10*J_21 - J_11*J_20;
 
4220
    const double d_10 = J_02*J_21 - J_01*J_22;
 
4221
    const double d_11 = J_00*J_22 - J_02*J_20;
 
4222
    const double d_12 = J_01*J_20 - J_00*J_21;
 
4223
    const double d_20 = J_01*J_12 - J_02*J_11;
 
4224
    const double d_21 = J_02*J_10 - J_00*J_12;
 
4225
    const double d_22 = J_00*J_11 - J_01*J_10;
 
4226
    
 
4227
    // Compute determinant of Jacobian
 
4228
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
4229
    
 
4230
    // Compute inverse of Jacobian
 
4231
    const double K_00 = d_00 / detJ;
 
4232
    const double K_01 = d_10 / detJ;
 
4233
    const double K_02 = d_20 / detJ;
 
4234
    const double K_10 = d_01 / detJ;
 
4235
    const double K_11 = d_11 / detJ;
 
4236
    const double K_12 = d_21 / detJ;
 
4237
    const double K_20 = d_02 / detJ;
 
4238
    const double K_21 = d_12 / detJ;
 
4239
    const double K_22 = d_22 / detJ;
 
4240
    // Evaluate function and change variables
 
4241
    vertex_values[0] = dof_values[3]*K_20 + dof_values[4]*K_10 + dof_values[5]*K_00;
 
4242
    vertex_values[3] = dof_values[1]*K_20 + dof_values[2]*K_10 + dof_values[5]*(K_00 + K_10 + K_20);
 
4243
    vertex_values[6] = dof_values[0]*K_20 + dof_values[2]*(K_00*(-1.0)) + dof_values[4]*(K_00 + K_10 + K_20);
 
4244
    vertex_values[9] = dof_values[0]*(K_10*(-1.0)) + dof_values[1]*(K_00*(-1.0)) + dof_values[3]*(K_00 + K_10 + K_20);
 
4245
    vertex_values[1] = dof_values[3]*K_21 + dof_values[4]*K_11 + dof_values[5]*K_01;
 
4246
    vertex_values[4] = dof_values[1]*K_21 + dof_values[2]*K_11 + dof_values[5]*(K_01 + K_11 + K_21);
 
4247
    vertex_values[7] = dof_values[0]*K_21 + dof_values[2]*(K_01*(-1.0)) + dof_values[4]*(K_01 + K_11 + K_21);
 
4248
    vertex_values[10] = dof_values[0]*(K_11*(-1.0)) + dof_values[1]*(K_01*(-1.0)) + dof_values[3]*(K_01 + K_11 + K_21);
 
4249
    vertex_values[2] = dof_values[3]*K_22 + dof_values[4]*K_12 + dof_values[5]*K_02;
 
4250
    vertex_values[5] = dof_values[1]*K_22 + dof_values[2]*K_12 + dof_values[5]*(K_02 + K_12 + K_22);
 
4251
    vertex_values[8] = dof_values[0]*K_22 + dof_values[2]*(K_02*(-1.0)) + dof_values[4]*(K_02 + K_12 + K_22);
 
4252
    vertex_values[11] = dof_values[0]*(K_12*(-1.0)) + dof_values[1]*(K_02*(-1.0)) + dof_values[3]*(K_02 + K_12 + K_22);
 
4253
  }
 
4254
 
 
4255
  /// Return the number of sub elements (for a mixed element)
 
4256
  virtual unsigned int num_sub_elements() const
 
4257
  {
 
4258
    return 0;
 
4259
  }
 
4260
 
 
4261
  /// Create a new finite element for sub element i (for a mixed element)
 
4262
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
4263
  {
 
4264
    return 0;
 
4265
  }
 
4266
 
 
4267
};
 
4268
 
 
4269
/// This class defines the interface for a finite element.
 
4270
 
 
4271
class vectorlaplacegradcurl_finite_element_4: public ufc::finite_element
 
4272
{
 
4273
public:
 
4274
 
 
4275
  /// Constructor
 
4276
  vectorlaplacegradcurl_finite_element_4() : ufc::finite_element()
 
4277
  {
 
4278
    // Do nothing
 
4279
  }
 
4280
 
 
4281
  /// Destructor
 
4282
  virtual ~vectorlaplacegradcurl_finite_element_4()
 
4283
  {
 
4284
    // Do nothing
 
4285
  }
 
4286
 
 
4287
  /// Return a string identifying the finite element
 
4288
  virtual const char* signature() const
 
4289
  {
 
4290
    return "MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) })";
 
4291
  }
 
4292
 
 
4293
  /// Return the cell shape
 
4294
  virtual ufc::shape cell_shape() const
 
4295
  {
 
4296
    return ufc::tetrahedron;
 
4297
  }
 
4298
 
 
4299
  /// Return the dimension of the finite element function space
 
4300
  virtual unsigned int space_dimension() const
 
4301
  {
 
4302
    return 10;
 
4303
  }
 
4304
 
 
4305
  /// Return the rank of the value space
 
4306
  virtual unsigned int value_rank() const
 
4307
  {
 
4308
    return 1;
 
4309
  }
 
4310
 
 
4311
  /// Return the dimension of the value space for axis i
 
4312
  virtual unsigned int value_dimension(unsigned int i) const
 
4313
  {
 
4314
    switch (i)
 
4315
    {
 
4316
    case 0:
 
4317
      {
 
4318
        return 4;
 
4319
        break;
 
4320
      }
 
4321
    }
 
4322
    
 
4323
    return 0;
 
4324
  }
 
4325
 
 
4326
  /// Evaluate basis function i at given point in cell
 
4327
  virtual void evaluate_basis(unsigned int i,
 
4328
                              double* values,
 
4329
                              const double* coordinates,
 
4330
                              const ufc::cell& c) const
 
4331
  {
 
4332
    // Extract vertex coordinates
 
4333
    const double * const * x = c.coordinates;
 
4334
    
 
4335
    // Compute Jacobian of affine map from reference cell
 
4336
    const double J_00 = x[1][0] - x[0][0];
 
4337
    const double J_01 = x[2][0] - x[0][0];
 
4338
    const double J_02 = x[3][0] - x[0][0];
 
4339
    const double J_10 = x[1][1] - x[0][1];
 
4340
    const double J_11 = x[2][1] - x[0][1];
 
4341
    const double J_12 = x[3][1] - x[0][1];
 
4342
    const double J_20 = x[1][2] - x[0][2];
 
4343
    const double J_21 = x[2][2] - x[0][2];
 
4344
    const double J_22 = x[3][2] - x[0][2];
 
4345
    
 
4346
    // Compute sub determinants
 
4347
    const double d_00 = J_11*J_22 - J_12*J_21;
 
4348
    const double d_01 = J_12*J_20 - J_10*J_22;
 
4349
    const double d_02 = J_10*J_21 - J_11*J_20;
 
4350
    const double d_10 = J_02*J_21 - J_01*J_22;
 
4351
    const double d_11 = J_00*J_22 - J_02*J_20;
 
4352
    const double d_12 = J_01*J_20 - J_00*J_21;
 
4353
    const double d_20 = J_01*J_12 - J_02*J_11;
 
4354
    const double d_21 = J_02*J_10 - J_00*J_12;
 
4355
    const double d_22 = J_00*J_11 - J_01*J_10;
 
4356
    
 
4357
    // Compute determinant of Jacobian
 
4358
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
4359
    
 
4360
    // Compute inverse of Jacobian
 
4361
    const double K_00 = d_00 / detJ;
 
4362
    const double K_01 = d_10 / detJ;
 
4363
    const double K_02 = d_20 / detJ;
 
4364
    const double K_10 = d_01 / detJ;
 
4365
    const double K_11 = d_11 / detJ;
 
4366
    const double K_12 = d_21 / detJ;
 
4367
    const double K_20 = d_02 / detJ;
 
4368
    const double K_21 = d_12 / detJ;
 
4369
    const double K_22 = d_22 / detJ;
 
4370
    
 
4371
    // Compute constants
 
4372
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
4373
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
4374
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
4375
    
 
4376
    // Get coordinates and map to the reference (FIAT) element
 
4377
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
4378
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
4379
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
4380
    
 
4381
    
 
4382
    // Reset values
 
4383
    values[0] = 0.00000000;
 
4384
    values[1] = 0.00000000;
 
4385
    values[2] = 0.00000000;
 
4386
    values[3] = 0.00000000;
 
4387
    if (0 <= i && i <= 3)
 
4388
    {
 
4389
      // Map degree of freedom to element degree of freedom
 
4390
      const unsigned int dof = i;
 
4391
      
 
4392
      // Array of basisvalues
 
4393
      double basisvalues[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
4394
      
 
4395
      // Declare helper variables
 
4396
      unsigned int rr = 0;
 
4397
      unsigned int ss = 0;
 
4398
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
4399
      
 
4400
      // Compute basisvalues
 
4401
      basisvalues[0] = 1.00000000;
 
4402
      basisvalues[1] = tmp0;
 
4403
      for (unsigned int r = 0; r < 1; r++)
 
4404
      {
 
4405
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
4406
        ss = r*(r + 1)*(r + 2)/6;
 
4407
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
4408
      }// end loop over 'r'
 
4409
      for (unsigned int r = 0; r < 1; r++)
 
4410
      {
 
4411
        for (unsigned int s = 0; s < 1 - r; s++)
 
4412
        {
 
4413
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
4414
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
4415
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
4416
        }// end loop over 's'
 
4417
      }// end loop over 'r'
 
4418
      for (unsigned int r = 0; r < 2; r++)
 
4419
      {
 
4420
        for (unsigned int s = 0; s < 2 - r; s++)
 
4421
        {
 
4422
          for (unsigned int t = 0; t < 2 - r - s; t++)
 
4423
          {
 
4424
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
4425
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
4426
          }// end loop over 't'
 
4427
        }// end loop over 's'
 
4428
      }// end loop over 'r'
 
4429
      
 
4430
      // Table(s) of coefficients
 
4431
      static const double coefficients0[4][4] = \
 
4432
      {{0.28867513, -0.18257419, -0.10540926, -0.07453560},
 
4433
      {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
4434
      {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
4435
      {0.28867513, 0.00000000, 0.00000000, 0.22360680}};
 
4436
      
 
4437
      // Compute value(s).
 
4438
      for (unsigned int r = 0; r < 4; r++)
 
4439
      {
 
4440
        values[0] += coefficients0[dof][r]*basisvalues[r];
 
4441
      }// end loop over 'r'
 
4442
    }
 
4443
    
 
4444
    if (4 <= i && i <= 9)
 
4445
    {
 
4446
      // Map degree of freedom to element degree of freedom
 
4447
      const unsigned int dof = i - 4;
 
4448
      
 
4449
      // Array of basisvalues
 
4450
      double basisvalues[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
4451
      
 
4452
      // Declare helper variables
 
4453
      unsigned int rr = 0;
 
4454
      unsigned int ss = 0;
 
4455
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
4456
      
 
4457
      // Compute basisvalues
 
4458
      basisvalues[0] = 1.00000000;
 
4459
      basisvalues[1] = tmp0;
 
4460
      for (unsigned int r = 0; r < 1; r++)
 
4461
      {
 
4462
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
4463
        ss = r*(r + 1)*(r + 2)/6;
 
4464
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
4465
      }// end loop over 'r'
 
4466
      for (unsigned int r = 0; r < 1; r++)
 
4467
      {
 
4468
        for (unsigned int s = 0; s < 1 - r; s++)
 
4469
        {
 
4470
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
4471
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
4472
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
4473
        }// end loop over 's'
 
4474
      }// end loop over 'r'
 
4475
      for (unsigned int r = 0; r < 2; r++)
 
4476
      {
 
4477
        for (unsigned int s = 0; s < 2 - r; s++)
 
4478
        {
 
4479
          for (unsigned int t = 0; t < 2 - r - s; t++)
 
4480
          {
 
4481
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
4482
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
4483
          }// end loop over 't'
 
4484
        }// end loop over 's'
 
4485
      }// end loop over 'r'
 
4486
      
 
4487
      // Table(s) of coefficients
 
4488
      static const double coefficients0[6][4] = \
 
4489
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4490
      {-0.28867513, 0.00000000, 0.00000000, -0.22360680},
 
4491
      {-0.28867513, 0.00000000, -0.21081851, 0.07453560},
 
4492
      {0.28867513, 0.00000000, 0.00000000, 0.22360680},
 
4493
      {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
4494
      {0.57735027, 0.00000000, -0.21081851, -0.14907120}};
 
4495
      
 
4496
      static const double coefficients1[6][4] = \
 
4497
      {{-0.28867513, 0.00000000, 0.00000000, -0.22360680},
 
4498
      {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4499
      {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
4500
      {0.28867513, 0.00000000, 0.00000000, 0.22360680},
 
4501
      {0.57735027, -0.18257419, 0.10540926, -0.14907120},
 
4502
      {0.28867513, 0.18257419, -0.10540926, -0.07453560}};
 
4503
      
 
4504
      static const double coefficients2[6][4] = \
 
4505
      {{0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
4506
      {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
4507
      {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4508
      {0.57735027, -0.18257419, -0.10540926, 0.14907120},
 
4509
      {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
4510
      {0.28867513, 0.18257419, -0.10540926, -0.07453560}};
 
4511
      
 
4512
      // Compute value(s).
 
4513
      for (unsigned int r = 0; r < 4; r++)
 
4514
      {
 
4515
        values[1] += coefficients0[dof][r]*basisvalues[r];
 
4516
        values[2] += coefficients1[dof][r]*basisvalues[r];
 
4517
        values[3] += coefficients2[dof][r]*basisvalues[r];
 
4518
      }// end loop over 'r'
 
4519
      
 
4520
      // Using covariant Piola transform to map values back to the physical element
 
4521
      const double tmp_ref0 = values[1];
 
4522
      const double tmp_ref1 = values[2];
 
4523
      const double tmp_ref2 = values[3];
 
4524
      values[1] = (K_00*tmp_ref0 + K_10*tmp_ref1 + K_20*tmp_ref2);
 
4525
      values[2] = (K_01*tmp_ref0 + K_11*tmp_ref1 + K_21*tmp_ref2);
 
4526
      values[3] = (K_02*tmp_ref0 + K_12*tmp_ref1 + K_22*tmp_ref2);
 
4527
    }
 
4528
    
 
4529
  }
 
4530
 
 
4531
  /// Evaluate all basis functions at given point in cell
 
4532
  virtual void evaluate_basis_all(double* values,
 
4533
                                  const double* coordinates,
 
4534
                                  const ufc::cell& c) const
 
4535
  {
 
4536
    // Helper variable to hold values of a single dof.
 
4537
    double dof_values[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
4538
    
 
4539
    // Loop dofs and call evaluate_basis.
 
4540
    for (unsigned int r = 0; r < 10; r++)
 
4541
    {
 
4542
      evaluate_basis(r, dof_values, coordinates, c);
 
4543
      for (unsigned int s = 0; s < 4; s++)
 
4544
      {
 
4545
        values[r*4 + s] = dof_values[s];
 
4546
      }// end loop over 's'
 
4547
    }// end loop over 'r'
 
4548
  }
 
4549
 
 
4550
  /// Evaluate order n derivatives of basis function i at given point in cell
 
4551
  virtual void evaluate_basis_derivatives(unsigned int i,
 
4552
                                          unsigned int n,
 
4553
                                          double* values,
 
4554
                                          const double* coordinates,
 
4555
                                          const ufc::cell& c) const
 
4556
  {
 
4557
    // Extract vertex coordinates
 
4558
    const double * const * x = c.coordinates;
 
4559
    
 
4560
    // Compute Jacobian of affine map from reference cell
 
4561
    const double J_00 = x[1][0] - x[0][0];
 
4562
    const double J_01 = x[2][0] - x[0][0];
 
4563
    const double J_02 = x[3][0] - x[0][0];
 
4564
    const double J_10 = x[1][1] - x[0][1];
 
4565
    const double J_11 = x[2][1] - x[0][1];
 
4566
    const double J_12 = x[3][1] - x[0][1];
 
4567
    const double J_20 = x[1][2] - x[0][2];
 
4568
    const double J_21 = x[2][2] - x[0][2];
 
4569
    const double J_22 = x[3][2] - x[0][2];
 
4570
    
 
4571
    // Compute sub determinants
 
4572
    const double d_00 = J_11*J_22 - J_12*J_21;
 
4573
    const double d_01 = J_12*J_20 - J_10*J_22;
 
4574
    const double d_02 = J_10*J_21 - J_11*J_20;
 
4575
    const double d_10 = J_02*J_21 - J_01*J_22;
 
4576
    const double d_11 = J_00*J_22 - J_02*J_20;
 
4577
    const double d_12 = J_01*J_20 - J_00*J_21;
 
4578
    const double d_20 = J_01*J_12 - J_02*J_11;
 
4579
    const double d_21 = J_02*J_10 - J_00*J_12;
 
4580
    const double d_22 = J_00*J_11 - J_01*J_10;
 
4581
    
 
4582
    // Compute determinant of Jacobian
 
4583
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
4584
    
 
4585
    // Compute inverse of Jacobian
 
4586
    const double K_00 = d_00 / detJ;
 
4587
    const double K_01 = d_10 / detJ;
 
4588
    const double K_02 = d_20 / detJ;
 
4589
    const double K_10 = d_01 / detJ;
 
4590
    const double K_11 = d_11 / detJ;
 
4591
    const double K_12 = d_21 / detJ;
 
4592
    const double K_20 = d_02 / detJ;
 
4593
    const double K_21 = d_12 / detJ;
 
4594
    const double K_22 = d_22 / detJ;
 
4595
    
 
4596
    // Compute constants
 
4597
    const double C0 = x[3][0] + x[2][0] + x[1][0] - x[0][0];
 
4598
    const double C1 = x[3][1] + x[2][1] + x[1][1] - x[0][1];
 
4599
    const double C2 = x[3][2] + x[2][2] + x[1][2] - x[0][2];
 
4600
    
 
4601
    // Get coordinates and map to the reference (FIAT) element
 
4602
    double X = (d_00*(2.0*coordinates[0] - C0) + d_10*(2.0*coordinates[1] - C1) + d_20*(2.0*coordinates[2] - C2)) / detJ;
 
4603
    double Y = (d_01*(2.0*coordinates[0] - C0) + d_11*(2.0*coordinates[1] - C1) + d_21*(2.0*coordinates[2] - C2)) / detJ;
 
4604
    double Z = (d_02*(2.0*coordinates[0] - C0) + d_12*(2.0*coordinates[1] - C1) + d_22*(2.0*coordinates[2] - C2)) / detJ;
 
4605
    
 
4606
    
 
4607
    // Compute number of derivatives.
 
4608
    unsigned int  num_derivatives = 1;
 
4609
    
 
4610
    for (unsigned int r = 0; r < n; r++)
 
4611
    {
 
4612
      num_derivatives *= 3;
 
4613
    }// end loop over 'r'
 
4614
    
 
4615
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
4616
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
4617
    for (unsigned int row = 0; row < num_derivatives; row++)
 
4618
    {
 
4619
      combinations[row] = new unsigned int [n];
 
4620
      for (unsigned int col = 0; col < n; col++)
 
4621
        combinations[row][col] = 0;
 
4622
    }
 
4623
    
 
4624
    // Generate combinations of derivatives
 
4625
    for (unsigned int row = 1; row < num_derivatives; row++)
 
4626
    {
 
4627
      for (unsigned int num = 0; num < row; num++)
 
4628
      {
 
4629
        for (unsigned int col = n-1; col+1 > 0; col--)
 
4630
        {
 
4631
          if (combinations[row][col] + 1 > 2)
 
4632
            combinations[row][col] = 0;
 
4633
          else
 
4634
          {
 
4635
            combinations[row][col] += 1;
 
4636
            break;
 
4637
          }
 
4638
        }
 
4639
      }
 
4640
    }
 
4641
    
 
4642
    // Compute inverse of Jacobian
 
4643
    const double Jinv[3][3] = {{K_00, K_01, K_02}, {K_10, K_11, K_12}, {K_20, K_21, K_22}};
 
4644
    
 
4645
    // Declare transformation matrix
 
4646
    // Declare pointer to two dimensional array and initialise
 
4647
    double **transform = new double *[num_derivatives];
 
4648
    
 
4649
    for (unsigned int j = 0; j < num_derivatives; j++)
 
4650
    {
 
4651
      transform[j] = new double [num_derivatives];
 
4652
      for (unsigned int k = 0; k < num_derivatives; k++)
 
4653
        transform[j][k] = 1;
 
4654
    }
 
4655
    
 
4656
    // Construct transformation matrix
 
4657
    for (unsigned int row = 0; row < num_derivatives; row++)
 
4658
    {
 
4659
      for (unsigned int col = 0; col < num_derivatives; col++)
 
4660
      {
 
4661
        for (unsigned int k = 0; k < n; k++)
 
4662
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
4663
      }
 
4664
    }
 
4665
    
 
4666
    // Reset values. Assuming that values is always an array.
 
4667
    for (unsigned int r = 0; r < 4*num_derivatives; r++)
 
4668
    {
 
4669
      values[r] = 0.00000000;
 
4670
    }// end loop over 'r'
 
4671
    
 
4672
    if (0 <= i && i <= 3)
 
4673
    {
 
4674
      // Map degree of freedom to element degree of freedom
 
4675
      const unsigned int dof = i;
 
4676
      
 
4677
      // Array of basisvalues
 
4678
      double basisvalues[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
4679
      
 
4680
      // Declare helper variables
 
4681
      unsigned int rr = 0;
 
4682
      unsigned int ss = 0;
 
4683
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
4684
      
 
4685
      // Compute basisvalues
 
4686
      basisvalues[0] = 1.00000000;
 
4687
      basisvalues[1] = tmp0;
 
4688
      for (unsigned int r = 0; r < 1; r++)
 
4689
      {
 
4690
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
4691
        ss = r*(r + 1)*(r + 2)/6;
 
4692
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
4693
      }// end loop over 'r'
 
4694
      for (unsigned int r = 0; r < 1; r++)
 
4695
      {
 
4696
        for (unsigned int s = 0; s < 1 - r; s++)
 
4697
        {
 
4698
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
4699
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
4700
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
4701
        }// end loop over 's'
 
4702
      }// end loop over 'r'
 
4703
      for (unsigned int r = 0; r < 2; r++)
 
4704
      {
 
4705
        for (unsigned int s = 0; s < 2 - r; s++)
 
4706
        {
 
4707
          for (unsigned int t = 0; t < 2 - r - s; t++)
 
4708
          {
 
4709
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
4710
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
4711
          }// end loop over 't'
 
4712
        }// end loop over 's'
 
4713
      }// end loop over 'r'
 
4714
      
 
4715
      // Table(s) of coefficients
 
4716
      static const double coefficients0[4][4] = \
 
4717
      {{0.28867513, -0.18257419, -0.10540926, -0.07453560},
 
4718
      {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
4719
      {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
4720
      {0.28867513, 0.00000000, 0.00000000, 0.22360680}};
 
4721
      
 
4722
      // Tables of derivatives of the polynomial base (transpose).
 
4723
      static const double dmats0[4][4] = \
 
4724
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4725
      {6.32455532, 0.00000000, 0.00000000, 0.00000000},
 
4726
      {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4727
      {0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
4728
      
 
4729
      static const double dmats1[4][4] = \
 
4730
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4731
      {3.16227766, 0.00000000, 0.00000000, 0.00000000},
 
4732
      {5.47722558, 0.00000000, 0.00000000, 0.00000000},
 
4733
      {0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
4734
      
 
4735
      static const double dmats2[4][4] = \
 
4736
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4737
      {3.16227766, 0.00000000, 0.00000000, 0.00000000},
 
4738
      {1.82574186, 0.00000000, 0.00000000, 0.00000000},
 
4739
      {5.16397779, 0.00000000, 0.00000000, 0.00000000}};
 
4740
      
 
4741
      // Compute reference derivatives
 
4742
      // Declare pointer to array of derivatives on FIAT element
 
4743
      double *derivatives = new double [num_derivatives];
 
4744
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4745
      {
 
4746
        derivatives[r] = 0.00000000;
 
4747
      }// end loop over 'r'
 
4748
      
 
4749
      // Declare derivative matrix (of polynomial basis).
 
4750
      double dmats[4][4] = \
 
4751
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4752
      {0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
4753
      {0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
4754
      {0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
4755
      
 
4756
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
4757
      double dmats_old[4][4] = \
 
4758
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4759
      {0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
4760
      {0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
4761
      {0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
4762
      
 
4763
      // Loop possible derivatives.
 
4764
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4765
      {
 
4766
        // Resetting dmats values to compute next derivative.
 
4767
        for (unsigned int t = 0; t < 4; t++)
 
4768
        {
 
4769
          for (unsigned int u = 0; u < 4; u++)
 
4770
          {
 
4771
            dmats[t][u] = 0.00000000;
 
4772
            if (t == u)
 
4773
            {
 
4774
            dmats[t][u] = 1.00000000;
 
4775
            }
 
4776
            
 
4777
          }// end loop over 'u'
 
4778
        }// end loop over 't'
 
4779
        
 
4780
        // Looping derivative order to generate dmats.
 
4781
        for (unsigned int s = 0; s < n; s++)
 
4782
        {
 
4783
          // Updating dmats_old with new values and resetting dmats.
 
4784
          for (unsigned int t = 0; t < 4; t++)
 
4785
          {
 
4786
            for (unsigned int u = 0; u < 4; u++)
 
4787
            {
 
4788
              dmats_old[t][u] = dmats[t][u];
 
4789
              dmats[t][u] = 0.00000000;
 
4790
            }// end loop over 'u'
 
4791
          }// end loop over 't'
 
4792
          
 
4793
          // Update dmats using an inner product.
 
4794
          if (combinations[r][s] == 0)
 
4795
          {
 
4796
          for (unsigned int t = 0; t < 4; t++)
 
4797
          {
 
4798
            for (unsigned int u = 0; u < 4; u++)
 
4799
            {
 
4800
              for (unsigned int tu = 0; tu < 4; tu++)
 
4801
              {
 
4802
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
4803
              }// end loop over 'tu'
 
4804
            }// end loop over 'u'
 
4805
          }// end loop over 't'
 
4806
          }
 
4807
          
 
4808
          if (combinations[r][s] == 1)
 
4809
          {
 
4810
          for (unsigned int t = 0; t < 4; t++)
 
4811
          {
 
4812
            for (unsigned int u = 0; u < 4; u++)
 
4813
            {
 
4814
              for (unsigned int tu = 0; tu < 4; tu++)
 
4815
              {
 
4816
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
4817
              }// end loop over 'tu'
 
4818
            }// end loop over 'u'
 
4819
          }// end loop over 't'
 
4820
          }
 
4821
          
 
4822
          if (combinations[r][s] == 2)
 
4823
          {
 
4824
          for (unsigned int t = 0; t < 4; t++)
 
4825
          {
 
4826
            for (unsigned int u = 0; u < 4; u++)
 
4827
            {
 
4828
              for (unsigned int tu = 0; tu < 4; tu++)
 
4829
              {
 
4830
                dmats[t][u] += dmats2[t][tu]*dmats_old[tu][u];
 
4831
              }// end loop over 'tu'
 
4832
            }// end loop over 'u'
 
4833
          }// end loop over 't'
 
4834
          }
 
4835
          
 
4836
        }// end loop over 's'
 
4837
        for (unsigned int s = 0; s < 4; s++)
 
4838
        {
 
4839
          for (unsigned int t = 0; t < 4; t++)
 
4840
          {
 
4841
            derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
 
4842
          }// end loop over 't'
 
4843
        }// end loop over 's'
 
4844
      }// end loop over 'r'
 
4845
      
 
4846
      // Transform derivatives back to physical element
 
4847
      for (unsigned int row = 0; row < num_derivatives; row++)
 
4848
      {
 
4849
        for (unsigned int col = 0; col < num_derivatives; col++)
 
4850
        {
 
4851
          values[row] += transform[row][col]*derivatives[col];
 
4852
        }
 
4853
      }
 
4854
      
 
4855
      // Delete pointer to array of derivatives on FIAT element
 
4856
      delete [] derivatives;
 
4857
      
 
4858
      // Delete pointer to array of combinations of derivatives and transform
 
4859
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4860
      {
 
4861
        delete [] combinations[r];
 
4862
        delete [] transform[r];
 
4863
      }// end loop over 'r'
 
4864
      delete [] combinations;
 
4865
      delete [] transform;
 
4866
    }
 
4867
    
 
4868
    if (4 <= i && i <= 9)
 
4869
    {
 
4870
      // Map degree of freedom to element degree of freedom
 
4871
      const unsigned int dof = i - 4;
 
4872
      
 
4873
      // Array of basisvalues
 
4874
      double basisvalues[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
 
4875
      
 
4876
      // Declare helper variables
 
4877
      unsigned int rr = 0;
 
4878
      unsigned int ss = 0;
 
4879
      double tmp0 = 0.50000000*(2.00000000 + Y + Z + 2.00000000*X);
 
4880
      
 
4881
      // Compute basisvalues
 
4882
      basisvalues[0] = 1.00000000;
 
4883
      basisvalues[1] = tmp0;
 
4884
      for (unsigned int r = 0; r < 1; r++)
 
4885
      {
 
4886
        rr = (r + 1)*(r + 1 + 1)*(r + 1 + 2)/6 + 1*(1 + 1)/2;
 
4887
        ss = r*(r + 1)*(r + 2)/6;
 
4888
        basisvalues[rr] = basisvalues[ss]*(r*(1.00000000 + Y) + (2.00000000 + Z + 3.00000000*Y)/2.00000000);
 
4889
      }// end loop over 'r'
 
4890
      for (unsigned int r = 0; r < 1; r++)
 
4891
      {
 
4892
        for (unsigned int s = 0; s < 1 - r; s++)
 
4893
        {
 
4894
          rr = (r + s + 1)*(r + s + 1 + 1)*(r + s + 1 + 2)/6 + (s + 1)*(s + 1 + 1)/2 + 1;
 
4895
          ss = (r + s)*(r + s + 1)*(r + s + 2)/6 + s*(s + 1)/2;
 
4896
          basisvalues[rr] = basisvalues[ss]*(1.00000000 + r + s + Z*(2.00000000 + r + s));
 
4897
        }// end loop over 's'
 
4898
      }// end loop over 'r'
 
4899
      for (unsigned int r = 0; r < 2; r++)
 
4900
      {
 
4901
        for (unsigned int s = 0; s < 2 - r; s++)
 
4902
        {
 
4903
          for (unsigned int t = 0; t < 2 - r - s; t++)
 
4904
          {
 
4905
            rr = (r + s + t)*(r + s + t + 1)*(r + s + t + 2)/6 + (s + t)*(s + t + 1)/2 + t;
 
4906
            basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s)*(1.50000000 + r + s + t));
 
4907
          }// end loop over 't'
 
4908
        }// end loop over 's'
 
4909
      }// end loop over 'r'
 
4910
      
 
4911
      // Table(s) of coefficients
 
4912
      static const double coefficients0[6][4] = \
 
4913
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4914
      {-0.28867513, 0.00000000, 0.00000000, -0.22360680},
 
4915
      {-0.28867513, 0.00000000, -0.21081851, 0.07453560},
 
4916
      {0.28867513, 0.00000000, 0.00000000, 0.22360680},
 
4917
      {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
4918
      {0.57735027, 0.00000000, -0.21081851, -0.14907120}};
 
4919
      
 
4920
      static const double coefficients1[6][4] = \
 
4921
      {{-0.28867513, 0.00000000, 0.00000000, -0.22360680},
 
4922
      {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4923
      {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
4924
      {0.28867513, 0.00000000, 0.00000000, 0.22360680},
 
4925
      {0.57735027, -0.18257419, 0.10540926, -0.14907120},
 
4926
      {0.28867513, 0.18257419, -0.10540926, -0.07453560}};
 
4927
      
 
4928
      static const double coefficients2[6][4] = \
 
4929
      {{0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
4930
      {0.28867513, 0.18257419, -0.10540926, -0.07453560},
 
4931
      {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4932
      {0.57735027, -0.18257419, -0.10540926, 0.14907120},
 
4933
      {0.28867513, 0.00000000, 0.21081851, -0.07453560},
 
4934
      {0.28867513, 0.18257419, -0.10540926, -0.07453560}};
 
4935
      
 
4936
      // Tables of derivatives of the polynomial base (transpose).
 
4937
      static const double dmats0[4][4] = \
 
4938
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4939
      {6.32455532, 0.00000000, 0.00000000, 0.00000000},
 
4940
      {0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4941
      {0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
4942
      
 
4943
      static const double dmats1[4][4] = \
 
4944
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4945
      {3.16227766, 0.00000000, 0.00000000, 0.00000000},
 
4946
      {5.47722558, 0.00000000, 0.00000000, 0.00000000},
 
4947
      {0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
4948
      
 
4949
      static const double dmats2[4][4] = \
 
4950
      {{0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4951
      {3.16227766, 0.00000000, 0.00000000, 0.00000000},
 
4952
      {1.82574186, 0.00000000, 0.00000000, 0.00000000},
 
4953
      {5.16397779, 0.00000000, 0.00000000, 0.00000000}};
 
4954
      
 
4955
      // Compute reference derivatives
 
4956
      // Declare pointer to array of derivatives on FIAT element
 
4957
      double *derivatives = new double [3*num_derivatives];
 
4958
      for (unsigned int r = 0; r < 3*num_derivatives; r++)
 
4959
      {
 
4960
        derivatives[r] = 0.00000000;
 
4961
      }// end loop over 'r'
 
4962
      
 
4963
      // Declare derivative matrix (of polynomial basis).
 
4964
      double dmats[4][4] = \
 
4965
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4966
      {0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
4967
      {0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
4968
      {0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
4969
      
 
4970
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
4971
      double dmats_old[4][4] = \
 
4972
      {{1.00000000, 0.00000000, 0.00000000, 0.00000000},
 
4973
      {0.00000000, 1.00000000, 0.00000000, 0.00000000},
 
4974
      {0.00000000, 0.00000000, 1.00000000, 0.00000000},
 
4975
      {0.00000000, 0.00000000, 0.00000000, 1.00000000}};
 
4976
      
 
4977
      // Loop possible derivatives.
 
4978
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4979
      {
 
4980
        // Resetting dmats values to compute next derivative.
 
4981
        for (unsigned int t = 0; t < 4; t++)
 
4982
        {
 
4983
          for (unsigned int u = 0; u < 4; u++)
 
4984
          {
 
4985
            dmats[t][u] = 0.00000000;
 
4986
            if (t == u)
 
4987
            {
 
4988
            dmats[t][u] = 1.00000000;
 
4989
            }
 
4990
            
 
4991
          }// end loop over 'u'
 
4992
        }// end loop over 't'
 
4993
        
 
4994
        // Looping derivative order to generate dmats.
 
4995
        for (unsigned int s = 0; s < n; s++)
 
4996
        {
 
4997
          // Updating dmats_old with new values and resetting dmats.
 
4998
          for (unsigned int t = 0; t < 4; t++)
 
4999
          {
 
5000
            for (unsigned int u = 0; u < 4; u++)
 
5001
            {
 
5002
              dmats_old[t][u] = dmats[t][u];
 
5003
              dmats[t][u] = 0.00000000;
 
5004
            }// end loop over 'u'
 
5005
          }// end loop over 't'
 
5006
          
 
5007
          // Update dmats using an inner product.
 
5008
          if (combinations[r][s] == 0)
 
5009
          {
 
5010
          for (unsigned int t = 0; t < 4; t++)
 
5011
          {
 
5012
            for (unsigned int u = 0; u < 4; u++)
 
5013
            {
 
5014
              for (unsigned int tu = 0; tu < 4; tu++)
 
5015
              {
 
5016
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
5017
              }// end loop over 'tu'
 
5018
            }// end loop over 'u'
 
5019
          }// end loop over 't'
 
5020
          }
 
5021
          
 
5022
          if (combinations[r][s] == 1)
 
5023
          {
 
5024
          for (unsigned int t = 0; t < 4; t++)
 
5025
          {
 
5026
            for (unsigned int u = 0; u < 4; u++)
 
5027
            {
 
5028
              for (unsigned int tu = 0; tu < 4; tu++)
 
5029
              {
 
5030
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
5031
              }// end loop over 'tu'
 
5032
            }// end loop over 'u'
 
5033
          }// end loop over 't'
 
5034
          }
 
5035
          
 
5036
          if (combinations[r][s] == 2)
 
5037
          {
 
5038
          for (unsigned int t = 0; t < 4; t++)
 
5039
          {
 
5040
            for (unsigned int u = 0; u < 4; u++)
 
5041
            {
 
5042
              for (unsigned int tu = 0; tu < 4; tu++)
 
5043
              {
 
5044
                dmats[t][u] += dmats2[t][tu]*dmats_old[tu][u];
 
5045
              }// end loop over 'tu'
 
5046
            }// end loop over 'u'
 
5047
          }// end loop over 't'
 
5048
          }
 
5049
          
 
5050
        }// end loop over 's'
 
5051
        for (unsigned int s = 0; s < 4; s++)
 
5052
        {
 
5053
          for (unsigned int t = 0; t < 4; t++)
 
5054
          {
 
5055
            derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
 
5056
            derivatives[num_derivatives + r] += coefficients1[dof][s]*dmats[s][t]*basisvalues[t];
 
5057
            derivatives[2*num_derivatives + r] += coefficients2[dof][s]*dmats[s][t]*basisvalues[t];
 
5058
          }// end loop over 't'
 
5059
        }// end loop over 's'
 
5060
        
 
5061
        // Using covariant Piola transform to map values back to the physical element
 
5062
        const double tmp_ref0 = derivatives[r];
 
5063
        const double tmp_ref1 = derivatives[num_derivatives + r];
 
5064
        const double tmp_ref2 = derivatives[2*num_derivatives + r];
 
5065
        derivatives[r] = (K_00*tmp_ref0 + K_10*tmp_ref1 + K_20*tmp_ref2);
 
5066
        derivatives[num_derivatives + r] = (K_01*tmp_ref0 + K_11*tmp_ref1 + K_21*tmp_ref2);
 
5067
        derivatives[2*num_derivatives + r] = (K_02*tmp_ref0 + K_12*tmp_ref1 + K_22*tmp_ref2);
 
5068
      }// end loop over 'r'
 
5069
      
 
5070
      // Transform derivatives back to physical element
 
5071
      for (unsigned int row = 0; row < num_derivatives; row++)
 
5072
      {
 
5073
        for (unsigned int col = 0; col < num_derivatives; col++)
 
5074
        {
 
5075
          values[num_derivatives + row] += transform[row][col]*derivatives[col];
 
5076
          values[2*num_derivatives + row] += transform[row][col]*derivatives[num_derivatives + col];
 
5077
          values[3*num_derivatives + row] += transform[row][col]*derivatives[2*num_derivatives + col];
 
5078
        }
 
5079
      }
 
5080
      
 
5081
      // Delete pointer to array of derivatives on FIAT element
 
5082
      delete [] derivatives;
 
5083
      
 
5084
      // Delete pointer to array of combinations of derivatives and transform
 
5085
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5086
      {
 
5087
        delete [] combinations[r];
 
5088
        delete [] transform[r];
 
5089
      }// end loop over 'r'
 
5090
      delete [] combinations;
 
5091
      delete [] transform;
 
5092
    }
 
5093
    
 
5094
  }
 
5095
 
 
5096
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
5097
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
5098
                                              double* values,
 
5099
                                              const double* coordinates,
 
5100
                                              const ufc::cell& c) const
 
5101
  {
 
5102
    // Compute number of derivatives.
 
5103
    unsigned int  num_derivatives = 1;
 
5104
    
 
5105
    for (unsigned int r = 0; r < n; r++)
 
5106
    {
 
5107
      num_derivatives *= 3;
 
5108
    }// end loop over 'r'
 
5109
    
 
5110
    // Helper variable to hold values of a single dof.
 
5111
    double *dof_values = new double [4*num_derivatives];
 
5112
    for (unsigned int r = 0; r < 4*num_derivatives; r++)
 
5113
    {
 
5114
      dof_values[r] = 0.00000000;
 
5115
    }// end loop over 'r'
 
5116
    
 
5117
    // Loop dofs and call evaluate_basis_derivatives.
 
5118
    for (unsigned int r = 0; r < 10; r++)
 
5119
    {
 
5120
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
5121
      for (unsigned int s = 0; s < 4*num_derivatives; s++)
 
5122
      {
 
5123
        values[r*4*num_derivatives + s] = dof_values[s];
 
5124
      }// end loop over 's'
 
5125
    }// end loop over 'r'
 
5126
    
 
5127
    // Delete pointer.
 
5128
    delete [] dof_values;
 
5129
  }
 
5130
 
 
5131
  /// Evaluate linear functional for dof i on the function f
 
5132
  virtual double evaluate_dof(unsigned int i,
 
5133
                              const ufc::function& f,
 
5134
                              const ufc::cell& c) const
 
5135
  {
 
5136
    // Declare variables for result of evaluation
 
5137
    double vals[4];
 
5138
    
 
5139
    // Declare variable for physical coordinates
 
5140
    double y[3];
 
5141
    
 
5142
    double result;
 
5143
    
 
5144
    // Extract vertex coordinates
 
5145
    const double * const * x = c.coordinates;
 
5146
    
 
5147
    // Compute Jacobian of affine map from reference cell
 
5148
    const double J_00 = x[1][0] - x[0][0];
 
5149
    const double J_01 = x[2][0] - x[0][0];
 
5150
    const double J_02 = x[3][0] - x[0][0];
 
5151
    const double J_10 = x[1][1] - x[0][1];
 
5152
    const double J_11 = x[2][1] - x[0][1];
 
5153
    const double J_12 = x[3][1] - x[0][1];
 
5154
    const double J_20 = x[1][2] - x[0][2];
 
5155
    const double J_21 = x[2][2] - x[0][2];
 
5156
    const double J_22 = x[3][2] - x[0][2];switch (i)
 
5157
    {
 
5158
    case 0:
 
5159
      {
 
5160
        y[0] = x[0][0];
 
5161
      y[1] = x[0][1];
 
5162
      y[2] = x[0][2];
 
5163
      f.evaluate(vals, y, c);
 
5164
      return vals[0];
 
5165
        break;
 
5166
      }
 
5167
    case 1:
 
5168
      {
 
5169
        y[0] = x[1][0];
 
5170
      y[1] = x[1][1];
 
5171
      y[2] = x[1][2];
 
5172
      f.evaluate(vals, y, c);
 
5173
      return vals[0];
 
5174
        break;
 
5175
      }
 
5176
    case 2:
 
5177
      {
 
5178
        y[0] = x[2][0];
 
5179
      y[1] = x[2][1];
 
5180
      y[2] = x[2][2];
 
5181
      f.evaluate(vals, y, c);
 
5182
      return vals[0];
 
5183
        break;
 
5184
      }
 
5185
    case 3:
 
5186
      {
 
5187
        y[0] = x[3][0];
 
5188
      y[1] = x[3][1];
 
5189
      y[2] = x[3][2];
 
5190
      f.evaluate(vals, y, c);
 
5191
      return vals[0];
 
5192
        break;
 
5193
      }
 
5194
    case 4:
 
5195
      {
 
5196
        y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
5197
      y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
5198
      y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
5199
      f.evaluate(vals, y, c);
 
5200
      result = (-1.0)*(J_01*vals[1] + J_11*vals[2] + J_21*vals[3]) + (J_02*vals[1] + J_12*vals[2] + J_22*vals[3]);
 
5201
      return result;
 
5202
        break;
 
5203
      }
 
5204
    case 5:
 
5205
      {
 
5206
        y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
5207
      y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
5208
      y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
5209
      f.evaluate(vals, y, c);
 
5210
      result = (-1.0)*(J_00*vals[1] + J_10*vals[2] + J_20*vals[3]) + (J_02*vals[1] + J_12*vals[2] + J_22*vals[3]);
 
5211
      return result;
 
5212
        break;
 
5213
      }
 
5214
    case 6:
 
5215
      {
 
5216
        y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
5217
      y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
5218
      y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
5219
      f.evaluate(vals, y, c);
 
5220
      result = (-1.0)*(J_00*vals[1] + J_10*vals[2] + J_20*vals[3]) + (J_01*vals[1] + J_11*vals[2] + J_21*vals[3]);
 
5221
      return result;
 
5222
        break;
 
5223
      }
 
5224
    case 7:
 
5225
      {
 
5226
        y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
5227
      y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
5228
      y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
5229
      f.evaluate(vals, y, c);
 
5230
      result = (J_02*vals[1] + J_12*vals[2] + J_22*vals[3]);
 
5231
      return result;
 
5232
        break;
 
5233
      }
 
5234
    case 8:
 
5235
      {
 
5236
        y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
5237
      y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
5238
      y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
5239
      f.evaluate(vals, y, c);
 
5240
      result = (J_01*vals[1] + J_11*vals[2] + J_21*vals[3]);
 
5241
      return result;
 
5242
        break;
 
5243
      }
 
5244
    case 9:
 
5245
      {
 
5246
        y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
5247
      y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
5248
      y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
5249
      f.evaluate(vals, y, c);
 
5250
      result = (J_00*vals[1] + J_10*vals[2] + J_20*vals[3]);
 
5251
      return result;
 
5252
        break;
 
5253
      }
 
5254
    }
 
5255
    
 
5256
    return 0.0;
 
5257
  }
 
5258
 
 
5259
  /// Evaluate linear functionals for all dofs on the function f
 
5260
  virtual void evaluate_dofs(double* values,
 
5261
                             const ufc::function& f,
 
5262
                             const ufc::cell& c) const
 
5263
  {
 
5264
    // Declare variables for result of evaluation
 
5265
    double vals[4];
 
5266
    
 
5267
    // Declare variable for physical coordinates
 
5268
    double y[3];
 
5269
    
 
5270
    double result;
 
5271
    
 
5272
    // Extract vertex coordinates
 
5273
    const double * const * x = c.coordinates;
 
5274
    
 
5275
    // Compute Jacobian of affine map from reference cell
 
5276
    const double J_00 = x[1][0] - x[0][0];
 
5277
    const double J_01 = x[2][0] - x[0][0];
 
5278
    const double J_02 = x[3][0] - x[0][0];
 
5279
    const double J_10 = x[1][1] - x[0][1];
 
5280
    const double J_11 = x[2][1] - x[0][1];
 
5281
    const double J_12 = x[3][1] - x[0][1];
 
5282
    const double J_20 = x[1][2] - x[0][2];
 
5283
    const double J_21 = x[2][2] - x[0][2];
 
5284
    const double J_22 = x[3][2] - x[0][2];y[0] = x[0][0];
 
5285
    y[1] = x[0][1];
 
5286
    y[2] = x[0][2];
 
5287
    f.evaluate(vals, y, c);
 
5288
    values[0] = vals[0];
 
5289
    y[0] = x[1][0];
 
5290
    y[1] = x[1][1];
 
5291
    y[2] = x[1][2];
 
5292
    f.evaluate(vals, y, c);
 
5293
    values[1] = vals[0];
 
5294
    y[0] = x[2][0];
 
5295
    y[1] = x[2][1];
 
5296
    y[2] = x[2][2];
 
5297
    f.evaluate(vals, y, c);
 
5298
    values[2] = vals[0];
 
5299
    y[0] = x[3][0];
 
5300
    y[1] = x[3][1];
 
5301
    y[2] = x[3][2];
 
5302
    f.evaluate(vals, y, c);
 
5303
    values[3] = vals[0];
 
5304
    y[0] = 0.5*x[2][0] + 0.5*x[3][0];
 
5305
    y[1] = 0.5*x[2][1] + 0.5*x[3][1];
 
5306
    y[2] = 0.5*x[2][2] + 0.5*x[3][2];
 
5307
    f.evaluate(vals, y, c);
 
5308
    result = (-1.0)*(J_01*vals[1] + J_11*vals[2] + J_21*vals[3]) + (J_02*vals[1] + J_12*vals[2] + J_22*vals[3]);
 
5309
    values[4] = result;
 
5310
    y[0] = 0.5*x[1][0] + 0.5*x[3][0];
 
5311
    y[1] = 0.5*x[1][1] + 0.5*x[3][1];
 
5312
    y[2] = 0.5*x[1][2] + 0.5*x[3][2];
 
5313
    f.evaluate(vals, y, c);
 
5314
    result = (-1.0)*(J_00*vals[1] + J_10*vals[2] + J_20*vals[3]) + (J_02*vals[1] + J_12*vals[2] + J_22*vals[3]);
 
5315
    values[5] = result;
 
5316
    y[0] = 0.5*x[1][0] + 0.5*x[2][0];
 
5317
    y[1] = 0.5*x[1][1] + 0.5*x[2][1];
 
5318
    y[2] = 0.5*x[1][2] + 0.5*x[2][2];
 
5319
    f.evaluate(vals, y, c);
 
5320
    result = (-1.0)*(J_00*vals[1] + J_10*vals[2] + J_20*vals[3]) + (J_01*vals[1] + J_11*vals[2] + J_21*vals[3]);
 
5321
    values[6] = result;
 
5322
    y[0] = 0.5*x[0][0] + 0.5*x[3][0];
 
5323
    y[1] = 0.5*x[0][1] + 0.5*x[3][1];
 
5324
    y[2] = 0.5*x[0][2] + 0.5*x[3][2];
 
5325
    f.evaluate(vals, y, c);
 
5326
    result = (J_02*vals[1] + J_12*vals[2] + J_22*vals[3]);
 
5327
    values[7] = result;
 
5328
    y[0] = 0.5*x[0][0] + 0.5*x[2][0];
 
5329
    y[1] = 0.5*x[0][1] + 0.5*x[2][1];
 
5330
    y[2] = 0.5*x[0][2] + 0.5*x[2][2];
 
5331
    f.evaluate(vals, y, c);
 
5332
    result = (J_01*vals[1] + J_11*vals[2] + J_21*vals[3]);
 
5333
    values[8] = result;
 
5334
    y[0] = 0.5*x[0][0] + 0.5*x[1][0];
 
5335
    y[1] = 0.5*x[0][1] + 0.5*x[1][1];
 
5336
    y[2] = 0.5*x[0][2] + 0.5*x[1][2];
 
5337
    f.evaluate(vals, y, c);
 
5338
    result = (J_00*vals[1] + J_10*vals[2] + J_20*vals[3]);
 
5339
    values[9] = result;
 
5340
  }
 
5341
 
 
5342
  /// Interpolate vertex values from dof values
 
5343
  virtual void interpolate_vertex_values(double* vertex_values,
 
5344
                                         const double* dof_values,
 
5345
                                         const ufc::cell& c) const
 
5346
  {
 
5347
    // Extract vertex coordinates
 
5348
    const double * const * x = c.coordinates;
 
5349
    
 
5350
    // Compute Jacobian of affine map from reference cell
 
5351
    const double J_00 = x[1][0] - x[0][0];
 
5352
    const double J_01 = x[2][0] - x[0][0];
 
5353
    const double J_02 = x[3][0] - x[0][0];
 
5354
    const double J_10 = x[1][1] - x[0][1];
 
5355
    const double J_11 = x[2][1] - x[0][1];
 
5356
    const double J_12 = x[3][1] - x[0][1];
 
5357
    const double J_20 = x[1][2] - x[0][2];
 
5358
    const double J_21 = x[2][2] - x[0][2];
 
5359
    const double J_22 = x[3][2] - x[0][2];
 
5360
    
 
5361
    // Compute sub determinants
 
5362
    const double d_00 = J_11*J_22 - J_12*J_21;
 
5363
    const double d_01 = J_12*J_20 - J_10*J_22;
 
5364
    const double d_02 = J_10*J_21 - J_11*J_20;
 
5365
    const double d_10 = J_02*J_21 - J_01*J_22;
 
5366
    const double d_11 = J_00*J_22 - J_02*J_20;
 
5367
    const double d_12 = J_01*J_20 - J_00*J_21;
 
5368
    const double d_20 = J_01*J_12 - J_02*J_11;
 
5369
    const double d_21 = J_02*J_10 - J_00*J_12;
 
5370
    const double d_22 = J_00*J_11 - J_01*J_10;
 
5371
    
 
5372
    // Compute determinant of Jacobian
 
5373
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
5374
    
 
5375
    // Compute inverse of Jacobian
 
5376
    const double K_00 = d_00 / detJ;
 
5377
    const double K_01 = d_10 / detJ;
 
5378
    const double K_02 = d_20 / detJ;
 
5379
    const double K_10 = d_01 / detJ;
 
5380
    const double K_11 = d_11 / detJ;
 
5381
    const double K_12 = d_21 / detJ;
 
5382
    const double K_20 = d_02 / detJ;
 
5383
    const double K_21 = d_12 / detJ;
 
5384
    const double K_22 = d_22 / detJ;
 
5385
    // Evaluate function and change variables
 
5386
    vertex_values[0] = dof_values[0];
 
5387
    vertex_values[4] = dof_values[1];
 
5388
    vertex_values[8] = dof_values[2];
 
5389
    vertex_values[12] = dof_values[3];
 
5390
    // Evaluate function and change variables
 
5391
    vertex_values[1] = dof_values[7]*K_20 + dof_values[8]*K_10 + dof_values[9]*K_00;
 
5392
    vertex_values[5] = dof_values[5]*K_20 + dof_values[6]*K_10 + dof_values[9]*(K_00 + K_10 + K_20);
 
5393
    vertex_values[9] = dof_values[4]*K_20 + dof_values[6]*(K_00*(-1.0)) + dof_values[8]*(K_00 + K_10 + K_20);
 
5394
    vertex_values[13] = dof_values[4]*(K_10*(-1.0)) + dof_values[5]*(K_00*(-1.0)) + dof_values[7]*(K_00 + K_10 + K_20);
 
5395
    vertex_values[2] = dof_values[7]*K_21 + dof_values[8]*K_11 + dof_values[9]*K_01;
 
5396
    vertex_values[6] = dof_values[5]*K_21 + dof_values[6]*K_11 + dof_values[9]*(K_01 + K_11 + K_21);
 
5397
    vertex_values[10] = dof_values[4]*K_21 + dof_values[6]*(K_01*(-1.0)) + dof_values[8]*(K_01 + K_11 + K_21);
 
5398
    vertex_values[14] = dof_values[4]*(K_11*(-1.0)) + dof_values[5]*(K_01*(-1.0)) + dof_values[7]*(K_01 + K_11 + K_21);
 
5399
    vertex_values[3] = dof_values[7]*K_22 + dof_values[8]*K_12 + dof_values[9]*K_02;
 
5400
    vertex_values[7] = dof_values[5]*K_22 + dof_values[6]*K_12 + dof_values[9]*(K_02 + K_12 + K_22);
 
5401
    vertex_values[11] = dof_values[4]*K_22 + dof_values[6]*(K_02*(-1.0)) + dof_values[8]*(K_02 + K_12 + K_22);
 
5402
    vertex_values[15] = dof_values[4]*(K_12*(-1.0)) + dof_values[5]*(K_02*(-1.0)) + dof_values[7]*(K_02 + K_12 + K_22);
 
5403
  }
 
5404
 
 
5405
  /// Return the number of sub elements (for a mixed element)
 
5406
  virtual unsigned int num_sub_elements() const
 
5407
  {
 
5408
    return 2;
 
5409
  }
 
5410
 
 
5411
  /// Create a new finite element for sub element i (for a mixed element)
 
5412
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
5413
  {
 
5414
    switch (i)
 
5415
    {
 
5416
    case 0:
 
5417
      {
 
5418
        return new vectorlaplacegradcurl_finite_element_2();
 
5419
        break;
 
5420
      }
 
5421
    case 1:
 
5422
      {
 
5423
        return new vectorlaplacegradcurl_finite_element_3();
 
5424
        break;
 
5425
      }
 
5426
    }
 
5427
    
 
5428
    return 0;
 
5429
  }
 
5430
 
 
5431
};
 
5432
 
 
5433
/// This class defines the interface for a local-to-global mapping of
 
5434
/// degrees of freedom (dofs).
 
5435
 
 
5436
class vectorlaplacegradcurl_dof_map_0: public ufc::dof_map
 
5437
{
 
5438
private:
 
5439
 
 
5440
  unsigned int _global_dimension;
 
5441
 
 
5442
public:
 
5443
 
 
5444
  /// Constructor
 
5445
  vectorlaplacegradcurl_dof_map_0() : ufc::dof_map()
 
5446
  {
 
5447
    _global_dimension = 0;
 
5448
  }
 
5449
 
 
5450
  /// Destructor
 
5451
  virtual ~vectorlaplacegradcurl_dof_map_0()
 
5452
  {
 
5453
    // Do nothing
 
5454
  }
 
5455
 
 
5456
  /// Return a string identifying the dof map
 
5457
  virtual const char* signature() const
 
5458
  {
 
5459
    return "FFC dofmap for FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2)";
 
5460
  }
 
5461
 
 
5462
  /// Return true iff mesh entities of topological dimension d are needed
 
5463
  virtual bool needs_mesh_entities(unsigned int d) const
 
5464
  {
 
5465
    switch (d)
 
5466
    {
 
5467
    case 0:
 
5468
      {
 
5469
        return true;
 
5470
        break;
 
5471
      }
 
5472
    case 1:
 
5473
      {
 
5474
        return true;
 
5475
        break;
 
5476
      }
 
5477
    case 2:
 
5478
      {
 
5479
        return false;
 
5480
        break;
 
5481
      }
 
5482
    case 3:
 
5483
      {
 
5484
        return false;
 
5485
        break;
 
5486
      }
 
5487
    }
 
5488
    
 
5489
    return false;
 
5490
  }
 
5491
 
 
5492
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
5493
  virtual bool init_mesh(const ufc::mesh& m)
 
5494
  {
 
5495
    _global_dimension = m.num_entities[0] + m.num_entities[1];
 
5496
    return false;
 
5497
  }
 
5498
 
 
5499
  /// Initialize dof map for given cell
 
5500
  virtual void init_cell(const ufc::mesh& m,
 
5501
                         const ufc::cell& c)
 
5502
  {
 
5503
    // Do nothing
 
5504
  }
 
5505
 
 
5506
  /// Finish initialization of dof map for cells
 
5507
  virtual void init_cell_finalize()
 
5508
  {
 
5509
    // Do nothing
 
5510
  }
 
5511
 
 
5512
  /// Return the dimension of the global finite element function space
 
5513
  virtual unsigned int global_dimension() const
 
5514
  {
 
5515
    return _global_dimension;
 
5516
  }
 
5517
 
 
5518
  /// Return the dimension of the local finite element function space for a cell
 
5519
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
5520
  {
 
5521
    return 10;
 
5522
  }
 
5523
 
 
5524
  /// Return the maximum dimension of the local finite element function space
 
5525
  virtual unsigned int max_local_dimension() const
 
5526
  {
 
5527
    return 10;
 
5528
  }
 
5529
 
 
5530
  // Return the geometric dimension of the coordinates this dof map provides
 
5531
  virtual unsigned int geometric_dimension() const
 
5532
  {
 
5533
    return 3;
 
5534
  }
 
5535
 
 
5536
  /// Return the number of dofs on each cell facet
 
5537
  virtual unsigned int num_facet_dofs() const
 
5538
  {
 
5539
    return 6;
 
5540
  }
 
5541
 
 
5542
  /// Return the number of dofs associated with each cell entity of dimension d
 
5543
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
5544
  {
 
5545
    switch (d)
 
5546
    {
 
5547
    case 0:
 
5548
      {
 
5549
        return 1;
 
5550
        break;
 
5551
      }
 
5552
    case 1:
 
5553
      {
 
5554
        return 1;
 
5555
        break;
 
5556
      }
 
5557
    case 2:
 
5558
      {
 
5559
        return 0;
 
5560
        break;
 
5561
      }
 
5562
    case 3:
 
5563
      {
 
5564
        return 0;
 
5565
        break;
 
5566
      }
 
5567
    }
 
5568
    
 
5569
    return 0;
 
5570
  }
 
5571
 
 
5572
  /// Tabulate the local-to-global mapping of dofs on a cell
 
5573
  virtual void tabulate_dofs(unsigned int* dofs,
 
5574
                             const ufc::mesh& m,
 
5575
                             const ufc::cell& c) const
 
5576
  {
 
5577
    unsigned int offset = 0;
 
5578
    
 
5579
    dofs[0] = offset + c.entity_indices[0][0];
 
5580
    dofs[1] = offset + c.entity_indices[0][1];
 
5581
    dofs[2] = offset + c.entity_indices[0][2];
 
5582
    dofs[3] = offset + c.entity_indices[0][3];
 
5583
    offset += m.num_entities[0];
 
5584
    dofs[4] = offset + c.entity_indices[1][0];
 
5585
    dofs[5] = offset + c.entity_indices[1][1];
 
5586
    dofs[6] = offset + c.entity_indices[1][2];
 
5587
    dofs[7] = offset + c.entity_indices[1][3];
 
5588
    dofs[8] = offset + c.entity_indices[1][4];
 
5589
    dofs[9] = offset + c.entity_indices[1][5];
 
5590
    offset += m.num_entities[1];
 
5591
  }
 
5592
 
 
5593
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
5594
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
5595
                                   unsigned int facet) const
 
5596
  {
 
5597
    switch (facet)
 
5598
    {
 
5599
    case 0:
 
5600
      {
 
5601
        dofs[0] = 1;
 
5602
      dofs[1] = 2;
 
5603
      dofs[2] = 3;
 
5604
      dofs[3] = 4;
 
5605
      dofs[4] = 5;
 
5606
      dofs[5] = 6;
 
5607
        break;
 
5608
      }
 
5609
    case 1:
 
5610
      {
 
5611
        dofs[0] = 0;
 
5612
      dofs[1] = 2;
 
5613
      dofs[2] = 3;
 
5614
      dofs[3] = 4;
 
5615
      dofs[4] = 7;
 
5616
      dofs[5] = 8;
 
5617
        break;
 
5618
      }
 
5619
    case 2:
 
5620
      {
 
5621
        dofs[0] = 0;
 
5622
      dofs[1] = 1;
 
5623
      dofs[2] = 3;
 
5624
      dofs[3] = 5;
 
5625
      dofs[4] = 7;
 
5626
      dofs[5] = 9;
 
5627
        break;
 
5628
      }
 
5629
    case 3:
 
5630
      {
 
5631
        dofs[0] = 0;
 
5632
      dofs[1] = 1;
 
5633
      dofs[2] = 2;
 
5634
      dofs[3] = 6;
 
5635
      dofs[4] = 8;
 
5636
      dofs[5] = 9;
 
5637
        break;
 
5638
      }
 
5639
    }
 
5640
    
 
5641
  }
 
5642
 
 
5643
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
5644
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
5645
                                    unsigned int d, unsigned int i) const
 
5646
  {
 
5647
    if (d > 3)
 
5648
    {
 
5649
    std::cerr << "*** FFC warning: " << "d is larger than dimension (3)" << std::endl;
 
5650
    }
 
5651
    
 
5652
    switch (d)
 
5653
    {
 
5654
    case 0:
 
5655
      {
 
5656
        if (i > 3)
 
5657
      {
 
5658
      std::cerr << "*** FFC warning: " << "i is larger than number of entities (3)" << std::endl;
 
5659
      }
 
5660
      
 
5661
      switch (i)
 
5662
      {
 
5663
      case 0:
 
5664
        {
 
5665
          dofs[0] = 0;
 
5666
          break;
 
5667
        }
 
5668
      case 1:
 
5669
        {
 
5670
          dofs[0] = 1;
 
5671
          break;
 
5672
        }
 
5673
      case 2:
 
5674
        {
 
5675
          dofs[0] = 2;
 
5676
          break;
 
5677
        }
 
5678
      case 3:
 
5679
        {
 
5680
          dofs[0] = 3;
 
5681
          break;
 
5682
        }
 
5683
      }
 
5684
      
 
5685
        break;
 
5686
      }
 
5687
    case 1:
 
5688
      {
 
5689
        if (i > 5)
 
5690
      {
 
5691
      std::cerr << "*** FFC warning: " << "i is larger than number of entities (5)" << std::endl;
 
5692
      }
 
5693
      
 
5694
      switch (i)
 
5695
      {
 
5696
      case 0:
 
5697
        {
 
5698
          dofs[0] = 4;
 
5699
          break;
 
5700
        }
 
5701
      case 1:
 
5702
        {
 
5703
          dofs[0] = 5;
 
5704
          break;
 
5705
        }
 
5706
      case 2:
 
5707
        {
 
5708
          dofs[0] = 6;
 
5709
          break;
 
5710
        }
 
5711
      case 3:
 
5712
        {
 
5713
          dofs[0] = 7;
 
5714
          break;
 
5715
        }
 
5716
      case 4:
 
5717
        {
 
5718
          dofs[0] = 8;
 
5719
          break;
 
5720
        }
 
5721
      case 5:
 
5722
        {
 
5723
          dofs[0] = 9;
 
5724
          break;
 
5725
        }
 
5726
      }
 
5727
      
 
5728
        break;
 
5729
      }
 
5730
    case 2:
 
5731
      {
 
5732
        
 
5733
        break;
 
5734
      }
 
5735
    case 3:
 
5736
      {
 
5737
        
 
5738
        break;
 
5739
      }
 
5740
    }
 
5741
    
 
5742
  }
 
5743
 
 
5744
  /// Tabulate the coordinates of all dofs on a cell
 
5745
  virtual void tabulate_coordinates(double** coordinates,
 
5746
                                    const ufc::cell& c) const
 
5747
  {
 
5748
    const double * const * x = c.coordinates;
 
5749
    
 
5750
    coordinates[0][0] = x[0][0];
 
5751
    coordinates[0][1] = x[0][1];
 
5752
    coordinates[0][2] = x[0][2];
 
5753
    coordinates[1][0] = x[1][0];
 
5754
    coordinates[1][1] = x[1][1];
 
5755
    coordinates[1][2] = x[1][2];
 
5756
    coordinates[2][0] = x[2][0];
 
5757
    coordinates[2][1] = x[2][1];
 
5758
    coordinates[2][2] = x[2][2];
 
5759
    coordinates[3][0] = x[3][0];
 
5760
    coordinates[3][1] = x[3][1];
 
5761
    coordinates[3][2] = x[3][2];
 
5762
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
5763
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
5764
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
5765
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
5766
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
5767
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
5768
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
5769
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
5770
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
5771
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
5772
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
5773
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
5774
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
5775
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
5776
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
5777
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
5778
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
5779
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
5780
  }
 
5781
 
 
5782
  /// Return the number of sub dof maps (for a mixed element)
 
5783
  virtual unsigned int num_sub_dof_maps() const
 
5784
  {
 
5785
    return 0;
 
5786
  }
 
5787
 
 
5788
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
5789
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
5790
  {
 
5791
    return 0;
 
5792
  }
 
5793
 
 
5794
};
 
5795
 
 
5796
/// This class defines the interface for a local-to-global mapping of
 
5797
/// degrees of freedom (dofs).
 
5798
 
 
5799
class vectorlaplacegradcurl_dof_map_1: public ufc::dof_map
 
5800
{
 
5801
private:
 
5802
 
 
5803
  unsigned int _global_dimension;
 
5804
 
 
5805
public:
 
5806
 
 
5807
  /// Constructor
 
5808
  vectorlaplacegradcurl_dof_map_1() : ufc::dof_map()
 
5809
  {
 
5810
    _global_dimension = 0;
 
5811
  }
 
5812
 
 
5813
  /// Destructor
 
5814
  virtual ~vectorlaplacegradcurl_dof_map_1()
 
5815
  {
 
5816
    // Do nothing
 
5817
  }
 
5818
 
 
5819
  /// Return a string identifying the dof map
 
5820
  virtual const char* signature() const
 
5821
  {
 
5822
    return "FFC dofmap for VectorElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2, 3)";
 
5823
  }
 
5824
 
 
5825
  /// Return true iff mesh entities of topological dimension d are needed
 
5826
  virtual bool needs_mesh_entities(unsigned int d) const
 
5827
  {
 
5828
    switch (d)
 
5829
    {
 
5830
    case 0:
 
5831
      {
 
5832
        return true;
 
5833
        break;
 
5834
      }
 
5835
    case 1:
 
5836
      {
 
5837
        return true;
 
5838
        break;
 
5839
      }
 
5840
    case 2:
 
5841
      {
 
5842
        return false;
 
5843
        break;
 
5844
      }
 
5845
    case 3:
 
5846
      {
 
5847
        return false;
 
5848
        break;
 
5849
      }
 
5850
    }
 
5851
    
 
5852
    return false;
 
5853
  }
 
5854
 
 
5855
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
5856
  virtual bool init_mesh(const ufc::mesh& m)
 
5857
  {
 
5858
    _global_dimension = 3*m.num_entities[0] + 3*m.num_entities[1];
 
5859
    return false;
 
5860
  }
 
5861
 
 
5862
  /// Initialize dof map for given cell
 
5863
  virtual void init_cell(const ufc::mesh& m,
 
5864
                         const ufc::cell& c)
 
5865
  {
 
5866
    // Do nothing
 
5867
  }
 
5868
 
 
5869
  /// Finish initialization of dof map for cells
 
5870
  virtual void init_cell_finalize()
 
5871
  {
 
5872
    // Do nothing
 
5873
  }
 
5874
 
 
5875
  /// Return the dimension of the global finite element function space
 
5876
  virtual unsigned int global_dimension() const
 
5877
  {
 
5878
    return _global_dimension;
 
5879
  }
 
5880
 
 
5881
  /// Return the dimension of the local finite element function space for a cell
 
5882
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
5883
  {
 
5884
    return 30;
 
5885
  }
 
5886
 
 
5887
  /// Return the maximum dimension of the local finite element function space
 
5888
  virtual unsigned int max_local_dimension() const
 
5889
  {
 
5890
    return 30;
 
5891
  }
 
5892
 
 
5893
  // Return the geometric dimension of the coordinates this dof map provides
 
5894
  virtual unsigned int geometric_dimension() const
 
5895
  {
 
5896
    return 3;
 
5897
  }
 
5898
 
 
5899
  /// Return the number of dofs on each cell facet
 
5900
  virtual unsigned int num_facet_dofs() const
 
5901
  {
 
5902
    return 18;
 
5903
  }
 
5904
 
 
5905
  /// Return the number of dofs associated with each cell entity of dimension d
 
5906
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
5907
  {
 
5908
    switch (d)
 
5909
    {
 
5910
    case 0:
 
5911
      {
 
5912
        return 3;
 
5913
        break;
 
5914
      }
 
5915
    case 1:
 
5916
      {
 
5917
        return 3;
 
5918
        break;
 
5919
      }
 
5920
    case 2:
 
5921
      {
 
5922
        return 0;
 
5923
        break;
 
5924
      }
 
5925
    case 3:
 
5926
      {
 
5927
        return 0;
 
5928
        break;
 
5929
      }
 
5930
    }
 
5931
    
 
5932
    return 0;
 
5933
  }
 
5934
 
 
5935
  /// Tabulate the local-to-global mapping of dofs on a cell
 
5936
  virtual void tabulate_dofs(unsigned int* dofs,
 
5937
                             const ufc::mesh& m,
 
5938
                             const ufc::cell& c) const
 
5939
  {
 
5940
    unsigned int offset = 0;
 
5941
    
 
5942
    dofs[0] = offset + c.entity_indices[0][0];
 
5943
    dofs[1] = offset + c.entity_indices[0][1];
 
5944
    dofs[2] = offset + c.entity_indices[0][2];
 
5945
    dofs[3] = offset + c.entity_indices[0][3];
 
5946
    offset += m.num_entities[0];
 
5947
    dofs[4] = offset + c.entity_indices[1][0];
 
5948
    dofs[5] = offset + c.entity_indices[1][1];
 
5949
    dofs[6] = offset + c.entity_indices[1][2];
 
5950
    dofs[7] = offset + c.entity_indices[1][3];
 
5951
    dofs[8] = offset + c.entity_indices[1][4];
 
5952
    dofs[9] = offset + c.entity_indices[1][5];
 
5953
    offset += m.num_entities[1];
 
5954
    dofs[10] = offset + c.entity_indices[0][0];
 
5955
    dofs[11] = offset + c.entity_indices[0][1];
 
5956
    dofs[12] = offset + c.entity_indices[0][2];
 
5957
    dofs[13] = offset + c.entity_indices[0][3];
 
5958
    offset += m.num_entities[0];
 
5959
    dofs[14] = offset + c.entity_indices[1][0];
 
5960
    dofs[15] = offset + c.entity_indices[1][1];
 
5961
    dofs[16] = offset + c.entity_indices[1][2];
 
5962
    dofs[17] = offset + c.entity_indices[1][3];
 
5963
    dofs[18] = offset + c.entity_indices[1][4];
 
5964
    dofs[19] = offset + c.entity_indices[1][5];
 
5965
    offset += m.num_entities[1];
 
5966
    dofs[20] = offset + c.entity_indices[0][0];
 
5967
    dofs[21] = offset + c.entity_indices[0][1];
 
5968
    dofs[22] = offset + c.entity_indices[0][2];
 
5969
    dofs[23] = offset + c.entity_indices[0][3];
 
5970
    offset += m.num_entities[0];
 
5971
    dofs[24] = offset + c.entity_indices[1][0];
 
5972
    dofs[25] = offset + c.entity_indices[1][1];
 
5973
    dofs[26] = offset + c.entity_indices[1][2];
 
5974
    dofs[27] = offset + c.entity_indices[1][3];
 
5975
    dofs[28] = offset + c.entity_indices[1][4];
 
5976
    dofs[29] = offset + c.entity_indices[1][5];
 
5977
    offset += m.num_entities[1];
 
5978
  }
 
5979
 
 
5980
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
5981
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
5982
                                   unsigned int facet) const
 
5983
  {
 
5984
    switch (facet)
 
5985
    {
 
5986
    case 0:
 
5987
      {
 
5988
        dofs[0] = 1;
 
5989
      dofs[1] = 2;
 
5990
      dofs[2] = 3;
 
5991
      dofs[3] = 4;
 
5992
      dofs[4] = 5;
 
5993
      dofs[5] = 6;
 
5994
      dofs[6] = 11;
 
5995
      dofs[7] = 12;
 
5996
      dofs[8] = 13;
 
5997
      dofs[9] = 14;
 
5998
      dofs[10] = 15;
 
5999
      dofs[11] = 16;
 
6000
      dofs[12] = 21;
 
6001
      dofs[13] = 22;
 
6002
      dofs[14] = 23;
 
6003
      dofs[15] = 24;
 
6004
      dofs[16] = 25;
 
6005
      dofs[17] = 26;
 
6006
        break;
 
6007
      }
 
6008
    case 1:
 
6009
      {
 
6010
        dofs[0] = 0;
 
6011
      dofs[1] = 2;
 
6012
      dofs[2] = 3;
 
6013
      dofs[3] = 4;
 
6014
      dofs[4] = 7;
 
6015
      dofs[5] = 8;
 
6016
      dofs[6] = 10;
 
6017
      dofs[7] = 12;
 
6018
      dofs[8] = 13;
 
6019
      dofs[9] = 14;
 
6020
      dofs[10] = 17;
 
6021
      dofs[11] = 18;
 
6022
      dofs[12] = 20;
 
6023
      dofs[13] = 22;
 
6024
      dofs[14] = 23;
 
6025
      dofs[15] = 24;
 
6026
      dofs[16] = 27;
 
6027
      dofs[17] = 28;
 
6028
        break;
 
6029
      }
 
6030
    case 2:
 
6031
      {
 
6032
        dofs[0] = 0;
 
6033
      dofs[1] = 1;
 
6034
      dofs[2] = 3;
 
6035
      dofs[3] = 5;
 
6036
      dofs[4] = 7;
 
6037
      dofs[5] = 9;
 
6038
      dofs[6] = 10;
 
6039
      dofs[7] = 11;
 
6040
      dofs[8] = 13;
 
6041
      dofs[9] = 15;
 
6042
      dofs[10] = 17;
 
6043
      dofs[11] = 19;
 
6044
      dofs[12] = 20;
 
6045
      dofs[13] = 21;
 
6046
      dofs[14] = 23;
 
6047
      dofs[15] = 25;
 
6048
      dofs[16] = 27;
 
6049
      dofs[17] = 29;
 
6050
        break;
 
6051
      }
 
6052
    case 3:
 
6053
      {
 
6054
        dofs[0] = 0;
 
6055
      dofs[1] = 1;
 
6056
      dofs[2] = 2;
 
6057
      dofs[3] = 6;
 
6058
      dofs[4] = 8;
 
6059
      dofs[5] = 9;
 
6060
      dofs[6] = 10;
 
6061
      dofs[7] = 11;
 
6062
      dofs[8] = 12;
 
6063
      dofs[9] = 16;
 
6064
      dofs[10] = 18;
 
6065
      dofs[11] = 19;
 
6066
      dofs[12] = 20;
 
6067
      dofs[13] = 21;
 
6068
      dofs[14] = 22;
 
6069
      dofs[15] = 26;
 
6070
      dofs[16] = 28;
 
6071
      dofs[17] = 29;
 
6072
        break;
 
6073
      }
 
6074
    }
 
6075
    
 
6076
  }
 
6077
 
 
6078
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
6079
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
6080
                                    unsigned int d, unsigned int i) const
 
6081
  {
 
6082
    if (d > 3)
 
6083
    {
 
6084
    std::cerr << "*** FFC warning: " << "d is larger than dimension (3)" << std::endl;
 
6085
    }
 
6086
    
 
6087
    switch (d)
 
6088
    {
 
6089
    case 0:
 
6090
      {
 
6091
        if (i > 3)
 
6092
      {
 
6093
      std::cerr << "*** FFC warning: " << "i is larger than number of entities (3)" << std::endl;
 
6094
      }
 
6095
      
 
6096
      switch (i)
 
6097
      {
 
6098
      case 0:
 
6099
        {
 
6100
          dofs[0] = 0;
 
6101
        dofs[1] = 10;
 
6102
        dofs[2] = 20;
 
6103
          break;
 
6104
        }
 
6105
      case 1:
 
6106
        {
 
6107
          dofs[0] = 1;
 
6108
        dofs[1] = 11;
 
6109
        dofs[2] = 21;
 
6110
          break;
 
6111
        }
 
6112
      case 2:
 
6113
        {
 
6114
          dofs[0] = 2;
 
6115
        dofs[1] = 12;
 
6116
        dofs[2] = 22;
 
6117
          break;
 
6118
        }
 
6119
      case 3:
 
6120
        {
 
6121
          dofs[0] = 3;
 
6122
        dofs[1] = 13;
 
6123
        dofs[2] = 23;
 
6124
          break;
 
6125
        }
 
6126
      }
 
6127
      
 
6128
        break;
 
6129
      }
 
6130
    case 1:
 
6131
      {
 
6132
        if (i > 5)
 
6133
      {
 
6134
      std::cerr << "*** FFC warning: " << "i is larger than number of entities (5)" << std::endl;
 
6135
      }
 
6136
      
 
6137
      switch (i)
 
6138
      {
 
6139
      case 0:
 
6140
        {
 
6141
          dofs[0] = 4;
 
6142
        dofs[1] = 14;
 
6143
        dofs[2] = 24;
 
6144
          break;
 
6145
        }
 
6146
      case 1:
 
6147
        {
 
6148
          dofs[0] = 5;
 
6149
        dofs[1] = 15;
 
6150
        dofs[2] = 25;
 
6151
          break;
 
6152
        }
 
6153
      case 2:
 
6154
        {
 
6155
          dofs[0] = 6;
 
6156
        dofs[1] = 16;
 
6157
        dofs[2] = 26;
 
6158
          break;
 
6159
        }
 
6160
      case 3:
 
6161
        {
 
6162
          dofs[0] = 7;
 
6163
        dofs[1] = 17;
 
6164
        dofs[2] = 27;
 
6165
          break;
 
6166
        }
 
6167
      case 4:
 
6168
        {
 
6169
          dofs[0] = 8;
 
6170
        dofs[1] = 18;
 
6171
        dofs[2] = 28;
 
6172
          break;
 
6173
        }
 
6174
      case 5:
 
6175
        {
 
6176
          dofs[0] = 9;
 
6177
        dofs[1] = 19;
 
6178
        dofs[2] = 29;
 
6179
          break;
 
6180
        }
 
6181
      }
 
6182
      
 
6183
        break;
 
6184
      }
 
6185
    case 2:
 
6186
      {
 
6187
        
 
6188
        break;
 
6189
      }
 
6190
    case 3:
 
6191
      {
 
6192
        
 
6193
        break;
 
6194
      }
 
6195
    }
 
6196
    
 
6197
  }
 
6198
 
 
6199
  /// Tabulate the coordinates of all dofs on a cell
 
6200
  virtual void tabulate_coordinates(double** coordinates,
 
6201
                                    const ufc::cell& c) const
 
6202
  {
 
6203
    const double * const * x = c.coordinates;
 
6204
    
 
6205
    coordinates[0][0] = x[0][0];
 
6206
    coordinates[0][1] = x[0][1];
 
6207
    coordinates[0][2] = x[0][2];
 
6208
    coordinates[1][0] = x[1][0];
 
6209
    coordinates[1][1] = x[1][1];
 
6210
    coordinates[1][2] = x[1][2];
 
6211
    coordinates[2][0] = x[2][0];
 
6212
    coordinates[2][1] = x[2][1];
 
6213
    coordinates[2][2] = x[2][2];
 
6214
    coordinates[3][0] = x[3][0];
 
6215
    coordinates[3][1] = x[3][1];
 
6216
    coordinates[3][2] = x[3][2];
 
6217
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
6218
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
6219
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
6220
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
6221
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
6222
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
6223
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
6224
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
6225
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
6226
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
6227
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
6228
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
6229
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
6230
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
6231
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
6232
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
6233
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
6234
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
6235
    coordinates[10][0] = x[0][0];
 
6236
    coordinates[10][1] = x[0][1];
 
6237
    coordinates[10][2] = x[0][2];
 
6238
    coordinates[11][0] = x[1][0];
 
6239
    coordinates[11][1] = x[1][1];
 
6240
    coordinates[11][2] = x[1][2];
 
6241
    coordinates[12][0] = x[2][0];
 
6242
    coordinates[12][1] = x[2][1];
 
6243
    coordinates[12][2] = x[2][2];
 
6244
    coordinates[13][0] = x[3][0];
 
6245
    coordinates[13][1] = x[3][1];
 
6246
    coordinates[13][2] = x[3][2];
 
6247
    coordinates[14][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
6248
    coordinates[14][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
6249
    coordinates[14][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
6250
    coordinates[15][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
6251
    coordinates[15][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
6252
    coordinates[15][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
6253
    coordinates[16][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
6254
    coordinates[16][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
6255
    coordinates[16][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
6256
    coordinates[17][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
6257
    coordinates[17][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
6258
    coordinates[17][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
6259
    coordinates[18][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
6260
    coordinates[18][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
6261
    coordinates[18][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
6262
    coordinates[19][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
6263
    coordinates[19][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
6264
    coordinates[19][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
6265
    coordinates[20][0] = x[0][0];
 
6266
    coordinates[20][1] = x[0][1];
 
6267
    coordinates[20][2] = x[0][2];
 
6268
    coordinates[21][0] = x[1][0];
 
6269
    coordinates[21][1] = x[1][1];
 
6270
    coordinates[21][2] = x[1][2];
 
6271
    coordinates[22][0] = x[2][0];
 
6272
    coordinates[22][1] = x[2][1];
 
6273
    coordinates[22][2] = x[2][2];
 
6274
    coordinates[23][0] = x[3][0];
 
6275
    coordinates[23][1] = x[3][1];
 
6276
    coordinates[23][2] = x[3][2];
 
6277
    coordinates[24][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
6278
    coordinates[24][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
6279
    coordinates[24][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
6280
    coordinates[25][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
6281
    coordinates[25][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
6282
    coordinates[25][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
6283
    coordinates[26][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
6284
    coordinates[26][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
6285
    coordinates[26][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
6286
    coordinates[27][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
6287
    coordinates[27][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
6288
    coordinates[27][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
6289
    coordinates[28][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
6290
    coordinates[28][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
6291
    coordinates[28][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
6292
    coordinates[29][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
6293
    coordinates[29][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
6294
    coordinates[29][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
6295
  }
 
6296
 
 
6297
  /// Return the number of sub dof maps (for a mixed element)
 
6298
  virtual unsigned int num_sub_dof_maps() const
 
6299
  {
 
6300
    return 3;
 
6301
  }
 
6302
 
 
6303
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
6304
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
6305
  {
 
6306
    switch (i)
 
6307
    {
 
6308
    case 0:
 
6309
      {
 
6310
        return new vectorlaplacegradcurl_dof_map_0();
 
6311
        break;
 
6312
      }
 
6313
    case 1:
 
6314
      {
 
6315
        return new vectorlaplacegradcurl_dof_map_0();
 
6316
        break;
 
6317
      }
 
6318
    case 2:
 
6319
      {
 
6320
        return new vectorlaplacegradcurl_dof_map_0();
 
6321
        break;
 
6322
      }
 
6323
    }
 
6324
    
 
6325
    return 0;
 
6326
  }
 
6327
 
 
6328
};
 
6329
 
 
6330
/// This class defines the interface for a local-to-global mapping of
 
6331
/// degrees of freedom (dofs).
 
6332
 
 
6333
class vectorlaplacegradcurl_dof_map_2: public ufc::dof_map
 
6334
{
 
6335
private:
 
6336
 
 
6337
  unsigned int _global_dimension;
 
6338
 
 
6339
public:
 
6340
 
 
6341
  /// Constructor
 
6342
  vectorlaplacegradcurl_dof_map_2() : ufc::dof_map()
 
6343
  {
 
6344
    _global_dimension = 0;
 
6345
  }
 
6346
 
 
6347
  /// Destructor
 
6348
  virtual ~vectorlaplacegradcurl_dof_map_2()
 
6349
  {
 
6350
    // Do nothing
 
6351
  }
 
6352
 
 
6353
  /// Return a string identifying the dof map
 
6354
  virtual const char* signature() const
 
6355
  {
 
6356
    return "FFC dofmap for FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1)";
 
6357
  }
 
6358
 
 
6359
  /// Return true iff mesh entities of topological dimension d are needed
 
6360
  virtual bool needs_mesh_entities(unsigned int d) const
 
6361
  {
 
6362
    switch (d)
 
6363
    {
 
6364
    case 0:
 
6365
      {
 
6366
        return true;
 
6367
        break;
 
6368
      }
 
6369
    case 1:
 
6370
      {
 
6371
        return false;
 
6372
        break;
 
6373
      }
 
6374
    case 2:
 
6375
      {
 
6376
        return false;
 
6377
        break;
 
6378
      }
 
6379
    case 3:
 
6380
      {
 
6381
        return false;
 
6382
        break;
 
6383
      }
 
6384
    }
 
6385
    
 
6386
    return false;
 
6387
  }
 
6388
 
 
6389
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
6390
  virtual bool init_mesh(const ufc::mesh& m)
 
6391
  {
 
6392
    _global_dimension = m.num_entities[0];
 
6393
    return false;
 
6394
  }
 
6395
 
 
6396
  /// Initialize dof map for given cell
 
6397
  virtual void init_cell(const ufc::mesh& m,
 
6398
                         const ufc::cell& c)
 
6399
  {
 
6400
    // Do nothing
 
6401
  }
 
6402
 
 
6403
  /// Finish initialization of dof map for cells
 
6404
  virtual void init_cell_finalize()
 
6405
  {
 
6406
    // Do nothing
 
6407
  }
 
6408
 
 
6409
  /// Return the dimension of the global finite element function space
 
6410
  virtual unsigned int global_dimension() const
 
6411
  {
 
6412
    return _global_dimension;
 
6413
  }
 
6414
 
 
6415
  /// Return the dimension of the local finite element function space for a cell
 
6416
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
6417
  {
 
6418
    return 4;
 
6419
  }
 
6420
 
 
6421
  /// Return the maximum dimension of the local finite element function space
 
6422
  virtual unsigned int max_local_dimension() const
 
6423
  {
 
6424
    return 4;
 
6425
  }
 
6426
 
 
6427
  // Return the geometric dimension of the coordinates this dof map provides
 
6428
  virtual unsigned int geometric_dimension() const
 
6429
  {
 
6430
    return 3;
 
6431
  }
 
6432
 
 
6433
  /// Return the number of dofs on each cell facet
 
6434
  virtual unsigned int num_facet_dofs() const
 
6435
  {
 
6436
    return 3;
 
6437
  }
 
6438
 
 
6439
  /// Return the number of dofs associated with each cell entity of dimension d
 
6440
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
6441
  {
 
6442
    switch (d)
 
6443
    {
 
6444
    case 0:
 
6445
      {
 
6446
        return 1;
 
6447
        break;
 
6448
      }
 
6449
    case 1:
 
6450
      {
 
6451
        return 0;
 
6452
        break;
 
6453
      }
 
6454
    case 2:
 
6455
      {
 
6456
        return 0;
 
6457
        break;
 
6458
      }
 
6459
    case 3:
 
6460
      {
 
6461
        return 0;
 
6462
        break;
 
6463
      }
 
6464
    }
 
6465
    
 
6466
    return 0;
 
6467
  }
 
6468
 
 
6469
  /// Tabulate the local-to-global mapping of dofs on a cell
 
6470
  virtual void tabulate_dofs(unsigned int* dofs,
 
6471
                             const ufc::mesh& m,
 
6472
                             const ufc::cell& c) const
 
6473
  {
 
6474
    dofs[0] = c.entity_indices[0][0];
 
6475
    dofs[1] = c.entity_indices[0][1];
 
6476
    dofs[2] = c.entity_indices[0][2];
 
6477
    dofs[3] = c.entity_indices[0][3];
 
6478
  }
 
6479
 
 
6480
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
6481
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
6482
                                   unsigned int facet) const
 
6483
  {
 
6484
    switch (facet)
 
6485
    {
 
6486
    case 0:
 
6487
      {
 
6488
        dofs[0] = 1;
 
6489
      dofs[1] = 2;
 
6490
      dofs[2] = 3;
 
6491
        break;
 
6492
      }
 
6493
    case 1:
 
6494
      {
 
6495
        dofs[0] = 0;
 
6496
      dofs[1] = 2;
 
6497
      dofs[2] = 3;
 
6498
        break;
 
6499
      }
 
6500
    case 2:
 
6501
      {
 
6502
        dofs[0] = 0;
 
6503
      dofs[1] = 1;
 
6504
      dofs[2] = 3;
 
6505
        break;
 
6506
      }
 
6507
    case 3:
 
6508
      {
 
6509
        dofs[0] = 0;
 
6510
      dofs[1] = 1;
 
6511
      dofs[2] = 2;
 
6512
        break;
 
6513
      }
 
6514
    }
 
6515
    
 
6516
  }
 
6517
 
 
6518
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
6519
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
6520
                                    unsigned int d, unsigned int i) const
 
6521
  {
 
6522
    if (d > 3)
 
6523
    {
 
6524
    std::cerr << "*** FFC warning: " << "d is larger than dimension (3)" << std::endl;
 
6525
    }
 
6526
    
 
6527
    switch (d)
 
6528
    {
 
6529
    case 0:
 
6530
      {
 
6531
        if (i > 3)
 
6532
      {
 
6533
      std::cerr << "*** FFC warning: " << "i is larger than number of entities (3)" << std::endl;
 
6534
      }
 
6535
      
 
6536
      switch (i)
 
6537
      {
 
6538
      case 0:
 
6539
        {
 
6540
          dofs[0] = 0;
 
6541
          break;
 
6542
        }
 
6543
      case 1:
 
6544
        {
 
6545
          dofs[0] = 1;
 
6546
          break;
 
6547
        }
 
6548
      case 2:
 
6549
        {
 
6550
          dofs[0] = 2;
 
6551
          break;
 
6552
        }
 
6553
      case 3:
 
6554
        {
 
6555
          dofs[0] = 3;
 
6556
          break;
 
6557
        }
 
6558
      }
 
6559
      
 
6560
        break;
 
6561
      }
 
6562
    case 1:
 
6563
      {
 
6564
        
 
6565
        break;
 
6566
      }
 
6567
    case 2:
 
6568
      {
 
6569
        
 
6570
        break;
 
6571
      }
 
6572
    case 3:
 
6573
      {
 
6574
        
 
6575
        break;
 
6576
      }
 
6577
    }
 
6578
    
 
6579
  }
 
6580
 
 
6581
  /// Tabulate the coordinates of all dofs on a cell
 
6582
  virtual void tabulate_coordinates(double** coordinates,
 
6583
                                    const ufc::cell& c) const
 
6584
  {
 
6585
    const double * const * x = c.coordinates;
 
6586
    
 
6587
    coordinates[0][0] = x[0][0];
 
6588
    coordinates[0][1] = x[0][1];
 
6589
    coordinates[0][2] = x[0][2];
 
6590
    coordinates[1][0] = x[1][0];
 
6591
    coordinates[1][1] = x[1][1];
 
6592
    coordinates[1][2] = x[1][2];
 
6593
    coordinates[2][0] = x[2][0];
 
6594
    coordinates[2][1] = x[2][1];
 
6595
    coordinates[2][2] = x[2][2];
 
6596
    coordinates[3][0] = x[3][0];
 
6597
    coordinates[3][1] = x[3][1];
 
6598
    coordinates[3][2] = x[3][2];
 
6599
  }
 
6600
 
 
6601
  /// Return the number of sub dof maps (for a mixed element)
 
6602
  virtual unsigned int num_sub_dof_maps() const
 
6603
  {
 
6604
    return 0;
 
6605
  }
 
6606
 
 
6607
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
6608
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
6609
  {
 
6610
    return 0;
 
6611
  }
 
6612
 
 
6613
};
 
6614
 
 
6615
/// This class defines the interface for a local-to-global mapping of
 
6616
/// degrees of freedom (dofs).
 
6617
 
 
6618
class vectorlaplacegradcurl_dof_map_3: public ufc::dof_map
 
6619
{
 
6620
private:
 
6621
 
 
6622
  unsigned int _global_dimension;
 
6623
 
 
6624
public:
 
6625
 
 
6626
  /// Constructor
 
6627
  vectorlaplacegradcurl_dof_map_3() : ufc::dof_map()
 
6628
  {
 
6629
    _global_dimension = 0;
 
6630
  }
 
6631
 
 
6632
  /// Destructor
 
6633
  virtual ~vectorlaplacegradcurl_dof_map_3()
 
6634
  {
 
6635
    // Do nothing
 
6636
  }
 
6637
 
 
6638
  /// Return a string identifying the dof map
 
6639
  virtual const char* signature() const
 
6640
  {
 
6641
    return "FFC dofmap for FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)";
 
6642
  }
 
6643
 
 
6644
  /// Return true iff mesh entities of topological dimension d are needed
 
6645
  virtual bool needs_mesh_entities(unsigned int d) const
 
6646
  {
 
6647
    switch (d)
 
6648
    {
 
6649
    case 0:
 
6650
      {
 
6651
        return false;
 
6652
        break;
 
6653
      }
 
6654
    case 1:
 
6655
      {
 
6656
        return true;
 
6657
        break;
 
6658
      }
 
6659
    case 2:
 
6660
      {
 
6661
        return false;
 
6662
        break;
 
6663
      }
 
6664
    case 3:
 
6665
      {
 
6666
        return false;
 
6667
        break;
 
6668
      }
 
6669
    }
 
6670
    
 
6671
    return false;
 
6672
  }
 
6673
 
 
6674
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
6675
  virtual bool init_mesh(const ufc::mesh& m)
 
6676
  {
 
6677
    _global_dimension = m.num_entities[1];
 
6678
    return false;
 
6679
  }
 
6680
 
 
6681
  /// Initialize dof map for given cell
 
6682
  virtual void init_cell(const ufc::mesh& m,
 
6683
                         const ufc::cell& c)
 
6684
  {
 
6685
    // Do nothing
 
6686
  }
 
6687
 
 
6688
  /// Finish initialization of dof map for cells
 
6689
  virtual void init_cell_finalize()
 
6690
  {
 
6691
    // Do nothing
 
6692
  }
 
6693
 
 
6694
  /// Return the dimension of the global finite element function space
 
6695
  virtual unsigned int global_dimension() const
 
6696
  {
 
6697
    return _global_dimension;
 
6698
  }
 
6699
 
 
6700
  /// Return the dimension of the local finite element function space for a cell
 
6701
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
6702
  {
 
6703
    return 6;
 
6704
  }
 
6705
 
 
6706
  /// Return the maximum dimension of the local finite element function space
 
6707
  virtual unsigned int max_local_dimension() const
 
6708
  {
 
6709
    return 6;
 
6710
  }
 
6711
 
 
6712
  // Return the geometric dimension of the coordinates this dof map provides
 
6713
  virtual unsigned int geometric_dimension() const
 
6714
  {
 
6715
    return 3;
 
6716
  }
 
6717
 
 
6718
  /// Return the number of dofs on each cell facet
 
6719
  virtual unsigned int num_facet_dofs() const
 
6720
  {
 
6721
    return 3;
 
6722
  }
 
6723
 
 
6724
  /// Return the number of dofs associated with each cell entity of dimension d
 
6725
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
6726
  {
 
6727
    switch (d)
 
6728
    {
 
6729
    case 0:
 
6730
      {
 
6731
        return 0;
 
6732
        break;
 
6733
      }
 
6734
    case 1:
 
6735
      {
 
6736
        return 1;
 
6737
        break;
 
6738
      }
 
6739
    case 2:
 
6740
      {
 
6741
        return 0;
 
6742
        break;
 
6743
      }
 
6744
    case 3:
 
6745
      {
 
6746
        return 0;
 
6747
        break;
 
6748
      }
 
6749
    }
 
6750
    
 
6751
    return 0;
 
6752
  }
 
6753
 
 
6754
  /// Tabulate the local-to-global mapping of dofs on a cell
 
6755
  virtual void tabulate_dofs(unsigned int* dofs,
 
6756
                             const ufc::mesh& m,
 
6757
                             const ufc::cell& c) const
 
6758
  {
 
6759
    dofs[0] = c.entity_indices[1][0];
 
6760
    dofs[1] = c.entity_indices[1][1];
 
6761
    dofs[2] = c.entity_indices[1][2];
 
6762
    dofs[3] = c.entity_indices[1][3];
 
6763
    dofs[4] = c.entity_indices[1][4];
 
6764
    dofs[5] = c.entity_indices[1][5];
 
6765
  }
 
6766
 
 
6767
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
6768
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
6769
                                   unsigned int facet) const
 
6770
  {
 
6771
    switch (facet)
 
6772
    {
 
6773
    case 0:
 
6774
      {
 
6775
        dofs[0] = 0;
 
6776
      dofs[1] = 1;
 
6777
      dofs[2] = 2;
 
6778
        break;
 
6779
      }
 
6780
    case 1:
 
6781
      {
 
6782
        dofs[0] = 0;
 
6783
      dofs[1] = 3;
 
6784
      dofs[2] = 4;
 
6785
        break;
 
6786
      }
 
6787
    case 2:
 
6788
      {
 
6789
        dofs[0] = 1;
 
6790
      dofs[1] = 3;
 
6791
      dofs[2] = 5;
 
6792
        break;
 
6793
      }
 
6794
    case 3:
 
6795
      {
 
6796
        dofs[0] = 2;
 
6797
      dofs[1] = 4;
 
6798
      dofs[2] = 5;
 
6799
        break;
 
6800
      }
 
6801
    }
 
6802
    
 
6803
  }
 
6804
 
 
6805
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
6806
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
6807
                                    unsigned int d, unsigned int i) const
 
6808
  {
 
6809
    if (d > 3)
 
6810
    {
 
6811
    std::cerr << "*** FFC warning: " << "d is larger than dimension (3)" << std::endl;
 
6812
    }
 
6813
    
 
6814
    switch (d)
 
6815
    {
 
6816
    case 0:
 
6817
      {
 
6818
        
 
6819
        break;
 
6820
      }
 
6821
    case 1:
 
6822
      {
 
6823
        if (i > 5)
 
6824
      {
 
6825
      std::cerr << "*** FFC warning: " << "i is larger than number of entities (5)" << std::endl;
 
6826
      }
 
6827
      
 
6828
      switch (i)
 
6829
      {
 
6830
      case 0:
 
6831
        {
 
6832
          dofs[0] = 0;
 
6833
          break;
 
6834
        }
 
6835
      case 1:
 
6836
        {
 
6837
          dofs[0] = 1;
 
6838
          break;
 
6839
        }
 
6840
      case 2:
 
6841
        {
 
6842
          dofs[0] = 2;
 
6843
          break;
 
6844
        }
 
6845
      case 3:
 
6846
        {
 
6847
          dofs[0] = 3;
 
6848
          break;
 
6849
        }
 
6850
      case 4:
 
6851
        {
 
6852
          dofs[0] = 4;
 
6853
          break;
 
6854
        }
 
6855
      case 5:
 
6856
        {
 
6857
          dofs[0] = 5;
 
6858
          break;
 
6859
        }
 
6860
      }
 
6861
      
 
6862
        break;
 
6863
      }
 
6864
    case 2:
 
6865
      {
 
6866
        
 
6867
        break;
 
6868
      }
 
6869
    case 3:
 
6870
      {
 
6871
        
 
6872
        break;
 
6873
      }
 
6874
    }
 
6875
    
 
6876
  }
 
6877
 
 
6878
  /// Tabulate the coordinates of all dofs on a cell
 
6879
  virtual void tabulate_coordinates(double** coordinates,
 
6880
                                    const ufc::cell& c) const
 
6881
  {
 
6882
    const double * const * x = c.coordinates;
 
6883
    
 
6884
    coordinates[0][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
6885
    coordinates[0][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
6886
    coordinates[0][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
6887
    coordinates[1][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
6888
    coordinates[1][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
6889
    coordinates[1][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
6890
    coordinates[2][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
6891
    coordinates[2][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
6892
    coordinates[2][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
6893
    coordinates[3][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
6894
    coordinates[3][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
6895
    coordinates[3][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
6896
    coordinates[4][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
6897
    coordinates[4][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
6898
    coordinates[4][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
6899
    coordinates[5][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
6900
    coordinates[5][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
6901
    coordinates[5][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
6902
  }
 
6903
 
 
6904
  /// Return the number of sub dof maps (for a mixed element)
 
6905
  virtual unsigned int num_sub_dof_maps() const
 
6906
  {
 
6907
    return 0;
 
6908
  }
 
6909
 
 
6910
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
6911
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
6912
  {
 
6913
    return 0;
 
6914
  }
 
6915
 
 
6916
};
 
6917
 
 
6918
/// This class defines the interface for a local-to-global mapping of
 
6919
/// degrees of freedom (dofs).
 
6920
 
 
6921
class vectorlaplacegradcurl_dof_map_4: public ufc::dof_map
 
6922
{
 
6923
private:
 
6924
 
 
6925
  unsigned int _global_dimension;
 
6926
 
 
6927
public:
 
6928
 
 
6929
  /// Constructor
 
6930
  vectorlaplacegradcurl_dof_map_4() : ufc::dof_map()
 
6931
  {
 
6932
    _global_dimension = 0;
 
6933
  }
 
6934
 
 
6935
  /// Destructor
 
6936
  virtual ~vectorlaplacegradcurl_dof_map_4()
 
6937
  {
 
6938
    // Do nothing
 
6939
  }
 
6940
 
 
6941
  /// Return a string identifying the dof map
 
6942
  virtual const char* signature() const
 
6943
  {
 
6944
    return "FFC dofmap for MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) })";
 
6945
  }
 
6946
 
 
6947
  /// Return true iff mesh entities of topological dimension d are needed
 
6948
  virtual bool needs_mesh_entities(unsigned int d) const
 
6949
  {
 
6950
    switch (d)
 
6951
    {
 
6952
    case 0:
 
6953
      {
 
6954
        return true;
 
6955
        break;
 
6956
      }
 
6957
    case 1:
 
6958
      {
 
6959
        return true;
 
6960
        break;
 
6961
      }
 
6962
    case 2:
 
6963
      {
 
6964
        return false;
 
6965
        break;
 
6966
      }
 
6967
    case 3:
 
6968
      {
 
6969
        return false;
 
6970
        break;
 
6971
      }
 
6972
    }
 
6973
    
 
6974
    return false;
 
6975
  }
 
6976
 
 
6977
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
6978
  virtual bool init_mesh(const ufc::mesh& m)
 
6979
  {
 
6980
    _global_dimension = m.num_entities[0] + m.num_entities[1];
 
6981
    return false;
 
6982
  }
 
6983
 
 
6984
  /// Initialize dof map for given cell
 
6985
  virtual void init_cell(const ufc::mesh& m,
 
6986
                         const ufc::cell& c)
 
6987
  {
 
6988
    // Do nothing
 
6989
  }
 
6990
 
 
6991
  /// Finish initialization of dof map for cells
 
6992
  virtual void init_cell_finalize()
 
6993
  {
 
6994
    // Do nothing
 
6995
  }
 
6996
 
 
6997
  /// Return the dimension of the global finite element function space
 
6998
  virtual unsigned int global_dimension() const
 
6999
  {
 
7000
    return _global_dimension;
 
7001
  }
 
7002
 
 
7003
  /// Return the dimension of the local finite element function space for a cell
 
7004
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
7005
  {
 
7006
    return 10;
 
7007
  }
 
7008
 
 
7009
  /// Return the maximum dimension of the local finite element function space
 
7010
  virtual unsigned int max_local_dimension() const
 
7011
  {
 
7012
    return 10;
 
7013
  }
 
7014
 
 
7015
  // Return the geometric dimension of the coordinates this dof map provides
 
7016
  virtual unsigned int geometric_dimension() const
 
7017
  {
 
7018
    return 3;
 
7019
  }
 
7020
 
 
7021
  /// Return the number of dofs on each cell facet
 
7022
  virtual unsigned int num_facet_dofs() const
 
7023
  {
 
7024
    return 6;
 
7025
  }
 
7026
 
 
7027
  /// Return the number of dofs associated with each cell entity of dimension d
 
7028
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
7029
  {
 
7030
    switch (d)
 
7031
    {
 
7032
    case 0:
 
7033
      {
 
7034
        return 1;
 
7035
        break;
 
7036
      }
 
7037
    case 1:
 
7038
      {
 
7039
        return 1;
 
7040
        break;
 
7041
      }
 
7042
    case 2:
 
7043
      {
 
7044
        return 0;
 
7045
        break;
 
7046
      }
 
7047
    case 3:
 
7048
      {
 
7049
        return 0;
 
7050
        break;
 
7051
      }
 
7052
    }
 
7053
    
 
7054
    return 0;
 
7055
  }
 
7056
 
 
7057
  /// Tabulate the local-to-global mapping of dofs on a cell
 
7058
  virtual void tabulate_dofs(unsigned int* dofs,
 
7059
                             const ufc::mesh& m,
 
7060
                             const ufc::cell& c) const
 
7061
  {
 
7062
    unsigned int offset = 0;
 
7063
    
 
7064
    dofs[0] = offset + c.entity_indices[0][0];
 
7065
    dofs[1] = offset + c.entity_indices[0][1];
 
7066
    dofs[2] = offset + c.entity_indices[0][2];
 
7067
    dofs[3] = offset + c.entity_indices[0][3];
 
7068
    offset += m.num_entities[0];
 
7069
    dofs[4] = offset + c.entity_indices[1][0];
 
7070
    dofs[5] = offset + c.entity_indices[1][1];
 
7071
    dofs[6] = offset + c.entity_indices[1][2];
 
7072
    dofs[7] = offset + c.entity_indices[1][3];
 
7073
    dofs[8] = offset + c.entity_indices[1][4];
 
7074
    dofs[9] = offset + c.entity_indices[1][5];
 
7075
    offset += m.num_entities[1];
 
7076
  }
 
7077
 
 
7078
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
7079
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
7080
                                   unsigned int facet) const
 
7081
  {
 
7082
    switch (facet)
 
7083
    {
 
7084
    case 0:
 
7085
      {
 
7086
        dofs[0] = 1;
 
7087
      dofs[1] = 2;
 
7088
      dofs[2] = 3;
 
7089
      dofs[3] = 4;
 
7090
      dofs[4] = 5;
 
7091
      dofs[5] = 6;
 
7092
        break;
 
7093
      }
 
7094
    case 1:
 
7095
      {
 
7096
        dofs[0] = 0;
 
7097
      dofs[1] = 2;
 
7098
      dofs[2] = 3;
 
7099
      dofs[3] = 4;
 
7100
      dofs[4] = 7;
 
7101
      dofs[5] = 8;
 
7102
        break;
 
7103
      }
 
7104
    case 2:
 
7105
      {
 
7106
        dofs[0] = 0;
 
7107
      dofs[1] = 1;
 
7108
      dofs[2] = 3;
 
7109
      dofs[3] = 5;
 
7110
      dofs[4] = 7;
 
7111
      dofs[5] = 9;
 
7112
        break;
 
7113
      }
 
7114
    case 3:
 
7115
      {
 
7116
        dofs[0] = 0;
 
7117
      dofs[1] = 1;
 
7118
      dofs[2] = 2;
 
7119
      dofs[3] = 6;
 
7120
      dofs[4] = 8;
 
7121
      dofs[5] = 9;
 
7122
        break;
 
7123
      }
 
7124
    }
 
7125
    
 
7126
  }
 
7127
 
 
7128
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
7129
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
7130
                                    unsigned int d, unsigned int i) const
 
7131
  {
 
7132
    if (d > 3)
 
7133
    {
 
7134
    std::cerr << "*** FFC warning: " << "d is larger than dimension (3)" << std::endl;
 
7135
    }
 
7136
    
 
7137
    switch (d)
 
7138
    {
 
7139
    case 0:
 
7140
      {
 
7141
        if (i > 3)
 
7142
      {
 
7143
      std::cerr << "*** FFC warning: " << "i is larger than number of entities (3)" << std::endl;
 
7144
      }
 
7145
      
 
7146
      switch (i)
 
7147
      {
 
7148
      case 0:
 
7149
        {
 
7150
          dofs[0] = 0;
 
7151
          break;
 
7152
        }
 
7153
      case 1:
 
7154
        {
 
7155
          dofs[0] = 1;
 
7156
          break;
 
7157
        }
 
7158
      case 2:
 
7159
        {
 
7160
          dofs[0] = 2;
 
7161
          break;
 
7162
        }
 
7163
      case 3:
 
7164
        {
 
7165
          dofs[0] = 3;
 
7166
          break;
 
7167
        }
 
7168
      }
 
7169
      
 
7170
        break;
 
7171
      }
 
7172
    case 1:
 
7173
      {
 
7174
        if (i > 5)
 
7175
      {
 
7176
      std::cerr << "*** FFC warning: " << "i is larger than number of entities (5)" << std::endl;
 
7177
      }
 
7178
      
 
7179
      switch (i)
 
7180
      {
 
7181
      case 0:
 
7182
        {
 
7183
          dofs[0] = 4;
 
7184
          break;
 
7185
        }
 
7186
      case 1:
 
7187
        {
 
7188
          dofs[0] = 5;
 
7189
          break;
 
7190
        }
 
7191
      case 2:
 
7192
        {
 
7193
          dofs[0] = 6;
 
7194
          break;
 
7195
        }
 
7196
      case 3:
 
7197
        {
 
7198
          dofs[0] = 7;
 
7199
          break;
 
7200
        }
 
7201
      case 4:
 
7202
        {
 
7203
          dofs[0] = 8;
 
7204
          break;
 
7205
        }
 
7206
      case 5:
 
7207
        {
 
7208
          dofs[0] = 9;
 
7209
          break;
 
7210
        }
 
7211
      }
 
7212
      
 
7213
        break;
 
7214
      }
 
7215
    case 2:
 
7216
      {
 
7217
        
 
7218
        break;
 
7219
      }
 
7220
    case 3:
 
7221
      {
 
7222
        
 
7223
        break;
 
7224
      }
 
7225
    }
 
7226
    
 
7227
  }
 
7228
 
 
7229
  /// Tabulate the coordinates of all dofs on a cell
 
7230
  virtual void tabulate_coordinates(double** coordinates,
 
7231
                                    const ufc::cell& c) const
 
7232
  {
 
7233
    const double * const * x = c.coordinates;
 
7234
    
 
7235
    coordinates[0][0] = x[0][0];
 
7236
    coordinates[0][1] = x[0][1];
 
7237
    coordinates[0][2] = x[0][2];
 
7238
    coordinates[1][0] = x[1][0];
 
7239
    coordinates[1][1] = x[1][1];
 
7240
    coordinates[1][2] = x[1][2];
 
7241
    coordinates[2][0] = x[2][0];
 
7242
    coordinates[2][1] = x[2][1];
 
7243
    coordinates[2][2] = x[2][2];
 
7244
    coordinates[3][0] = x[3][0];
 
7245
    coordinates[3][1] = x[3][1];
 
7246
    coordinates[3][2] = x[3][2];
 
7247
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
7248
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
7249
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
7250
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
7251
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
7252
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
7253
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
7254
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
7255
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
7256
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
7257
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
7258
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
7259
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
7260
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
7261
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
7262
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
7263
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
7264
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
7265
  }
 
7266
 
 
7267
  /// Return the number of sub dof maps (for a mixed element)
 
7268
  virtual unsigned int num_sub_dof_maps() const
 
7269
  {
 
7270
    return 2;
 
7271
  }
 
7272
 
 
7273
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
7274
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
7275
  {
 
7276
    switch (i)
 
7277
    {
 
7278
    case 0:
 
7279
      {
 
7280
        return new vectorlaplacegradcurl_dof_map_2();
 
7281
        break;
 
7282
      }
 
7283
    case 1:
 
7284
      {
 
7285
        return new vectorlaplacegradcurl_dof_map_3();
 
7286
        break;
 
7287
      }
 
7288
    }
 
7289
    
 
7290
    return 0;
 
7291
  }
 
7292
 
 
7293
};
 
7294
 
 
7295
/// This class defines the interface for the tabulation of the cell
 
7296
/// tensor corresponding to the local contribution to a form from
 
7297
/// the integral over a cell.
 
7298
 
 
7299
class vectorlaplacegradcurl_cell_integral_0_0: public ufc::cell_integral
 
7300
{
 
7301
public:
 
7302
 
 
7303
  /// Constructor
 
7304
  vectorlaplacegradcurl_cell_integral_0_0() : ufc::cell_integral()
 
7305
  {
 
7306
    // Do nothing
 
7307
  }
 
7308
 
 
7309
  /// Destructor
 
7310
  virtual ~vectorlaplacegradcurl_cell_integral_0_0()
 
7311
  {
 
7312
    // Do nothing
 
7313
  }
 
7314
 
 
7315
  /// Tabulate the tensor for the contribution from a local cell
 
7316
  virtual void tabulate_tensor(double* A,
 
7317
                               const double * const * w,
 
7318
                               const ufc::cell& c) const
 
7319
  {
 
7320
    // Extract vertex coordinates
 
7321
    const double * const * x = c.coordinates;
 
7322
    
 
7323
    // Compute Jacobian of affine map from reference cell
 
7324
    const double J_00 = x[1][0] - x[0][0];
 
7325
    const double J_01 = x[2][0] - x[0][0];
 
7326
    const double J_02 = x[3][0] - x[0][0];
 
7327
    const double J_10 = x[1][1] - x[0][1];
 
7328
    const double J_11 = x[2][1] - x[0][1];
 
7329
    const double J_12 = x[3][1] - x[0][1];
 
7330
    const double J_20 = x[1][2] - x[0][2];
 
7331
    const double J_21 = x[2][2] - x[0][2];
 
7332
    const double J_22 = x[3][2] - x[0][2];
 
7333
    
 
7334
    // Compute sub determinants
 
7335
    const double d_00 = J_11*J_22 - J_12*J_21;
 
7336
    const double d_01 = J_12*J_20 - J_10*J_22;
 
7337
    const double d_02 = J_10*J_21 - J_11*J_20;
 
7338
    const double d_10 = J_02*J_21 - J_01*J_22;
 
7339
    const double d_11 = J_00*J_22 - J_02*J_20;
 
7340
    const double d_12 = J_01*J_20 - J_00*J_21;
 
7341
    const double d_20 = J_01*J_12 - J_02*J_11;
 
7342
    const double d_21 = J_02*J_10 - J_00*J_12;
 
7343
    const double d_22 = J_00*J_11 - J_01*J_10;
 
7344
    
 
7345
    // Compute determinant of Jacobian
 
7346
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
7347
    
 
7348
    // Compute inverse of Jacobian
 
7349
    const double K_00 = d_00 / detJ;
 
7350
    const double K_01 = d_10 / detJ;
 
7351
    const double K_02 = d_20 / detJ;
 
7352
    const double K_10 = d_01 / detJ;
 
7353
    const double K_11 = d_11 / detJ;
 
7354
    const double K_12 = d_21 / detJ;
 
7355
    const double K_20 = d_02 / detJ;
 
7356
    const double K_21 = d_12 / detJ;
 
7357
    const double K_22 = d_22 / detJ;
 
7358
    
 
7359
    // Set scale factor
 
7360
    const double det = std::abs(detJ);
 
7361
    
 
7362
    // Array of quadrature weights
 
7363
    static const double W8[8] = {0.03697986, 0.01602704, 0.02115701, 0.00916943, 0.03697986, 0.01602704, 0.02115701, 0.00916943};
 
7364
    // Quadrature points on the UFC reference element: (0.15668264, 0.13605498, 0.12251482), (0.08139567, 0.07067972, 0.54415184), (0.06583869, 0.56593317, 0.12251482), (0.03420279, 0.29399880, 0.54415184), (0.58474756, 0.13605498, 0.12251482), (0.30377276, 0.07067972, 0.54415184), (0.24571333, 0.56593317, 0.12251482), (0.12764656, 0.29399880, 0.54415184)
 
7365
    
 
7366
    // Value of basis functions at quadrature points.
 
7367
    static const double FE0_C0[8][10] = \
 
7368
    {{0.58474756, 0.15668264, 0.13605498, 0.12251482, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7369
    {0.30377276, 0.08139567, 0.07067972, 0.54415184, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7370
    {0.24571333, 0.06583869, 0.56593317, 0.12251482, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7371
    {0.12764656, 0.03420279, 0.29399880, 0.54415184, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7372
    {0.15668264, 0.58474756, 0.13605498, 0.12251482, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7373
    {0.08139567, 0.30377276, 0.07067972, 0.54415184, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7374
    {0.06583869, 0.24571333, 0.56593317, 0.12251482, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7375
    {0.03420279, 0.12764656, 0.29399880, 0.54415184, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
7376
    
 
7377
    static const double FE0_C0_D001[8][10] = \
 
7378
    {{-1.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7379
    {-1.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7380
    {-1.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7381
    {-1.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7382
    {-1.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7383
    {-1.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7384
    {-1.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7385
    {-1.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
7386
    
 
7387
    static const double FE0_C0_D010[8][10] = \
 
7388
    {{-1.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7389
    {-1.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7390
    {-1.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7391
    {-1.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7392
    {-1.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7393
    {-1.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7394
    {-1.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7395
    {-1.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
7396
    
 
7397
    static const double FE0_C0_D100[8][10] = \
 
7398
    {{-1.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7399
    {-1.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7400
    {-1.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7401
    {-1.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7402
    {-1.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7403
    {-1.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7404
    {-1.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7405
    {-1.00000000, 1.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
7406
    
 
7407
    static const double FE0_C1[8][10] = \
 
7408
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.12251482, -0.13605498, 0.12251482, 0.13605498, 0.74143020},
 
7409
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.54415184, -0.07067972, 0.54415184, 0.07067972, 0.38516843},
 
7410
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.12251482, -0.56593317, 0.12251482, 0.56593317, 0.31155201},
 
7411
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.54415184, -0.29399880, 0.54415184, 0.29399880, 0.16184936},
 
7412
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.12251482, -0.13605498, 0.12251482, 0.13605498, 0.74143020},
 
7413
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.54415184, -0.07067972, 0.54415184, 0.07067972, 0.38516843},
 
7414
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.12251482, -0.56593317, 0.12251482, 0.56593317, 0.31155201},
 
7415
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.54415184, -0.29399880, 0.54415184, 0.29399880, 0.16184936}};
 
7416
    
 
7417
    static const double FE0_C1_D001[8][10] = \
 
7418
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000},
 
7419
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000},
 
7420
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000},
 
7421
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000},
 
7422
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000},
 
7423
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000},
 
7424
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000},
 
7425
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000}};
 
7426
    
 
7427
    static const double FE0_C1_D010[8][10] = \
 
7428
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, -1.00000000},
 
7429
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, -1.00000000},
 
7430
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, -1.00000000},
 
7431
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, -1.00000000},
 
7432
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, -1.00000000},
 
7433
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, -1.00000000},
 
7434
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, -1.00000000},
 
7435
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000, -1.00000000}};
 
7436
    
 
7437
    static const double FE0_C1_D100[8][10] = \
 
7438
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7439
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7440
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7441
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7442
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7443
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7444
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000},
 
7445
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}};
 
7446
    
 
7447
    static const double FE0_C2[8][10] = \
 
7448
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.12251482, 0.00000000, 0.15668264, 0.12251482, 0.72080254, 0.15668264},
 
7449
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.54415184, 0.00000000, 0.08139567, 0.54415184, 0.37445249, 0.08139567},
 
7450
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.12251482, 0.00000000, 0.06583869, 0.12251482, 0.81164649, 0.06583869},
 
7451
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.54415184, 0.00000000, 0.03420279, 0.54415184, 0.42164536, 0.03420279},
 
7452
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.12251482, 0.00000000, 0.58474756, 0.12251482, 0.29273761, 0.58474756},
 
7453
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.54415184, 0.00000000, 0.30377276, 0.54415184, 0.15207539, 0.30377276},
 
7454
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.12251482, 0.00000000, 0.24571333, 0.12251482, 0.63177185, 0.24571333},
 
7455
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.54415184, 0.00000000, 0.12764656, 0.54415184, 0.32820159, 0.12764656}};
 
7456
    
 
7457
    static const double FE0_C2_D001[8][10] = \
 
7458
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 0.00000000, 1.00000000, -1.00000000, 0.00000000},
 
7459
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 0.00000000, 1.00000000, -1.00000000, 0.00000000},
 
7460
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 0.00000000, 1.00000000, -1.00000000, 0.00000000},
 
7461
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 0.00000000, 1.00000000, -1.00000000, 0.00000000},
 
7462
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 0.00000000, 1.00000000, -1.00000000, 0.00000000},
 
7463
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 0.00000000, 1.00000000, -1.00000000, 0.00000000},
 
7464
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 0.00000000, 1.00000000, -1.00000000, 0.00000000},
 
7465
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, -1.00000000, 0.00000000, 0.00000000, 1.00000000, -1.00000000, 0.00000000}};
 
7466
    
 
7467
    static const double FE0_C2_D100[8][10] = \
 
7468
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 1.00000000},
 
7469
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 1.00000000},
 
7470
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 1.00000000},
 
7471
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 1.00000000},
 
7472
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 1.00000000},
 
7473
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 1.00000000},
 
7474
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 1.00000000},
 
7475
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 1.00000000}};
 
7476
    
 
7477
    static const double FE0_C3[8][10] = \
 
7478
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.13605498, 0.15668264, 0.00000000, 0.70726239, 0.13605498, 0.15668264},
 
7479
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.07067972, 0.08139567, 0.00000000, 0.84792461, 0.07067972, 0.08139567},
 
7480
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.56593317, 0.06583869, 0.00000000, 0.36822815, 0.56593317, 0.06583869},
 
7481
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.29399880, 0.03420279, 0.00000000, 0.67179841, 0.29399880, 0.03420279},
 
7482
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.13605498, 0.58474756, 0.00000000, 0.27919746, 0.13605498, 0.58474756},
 
7483
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.07067972, 0.30377276, 0.00000000, 0.62554751, 0.07067972, 0.30377276},
 
7484
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.56593317, 0.24571333, 0.00000000, 0.18835351, 0.56593317, 0.24571333},
 
7485
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.29399880, 0.12764656, 0.00000000, 0.57835464, 0.29399880, 0.12764656}};
 
7486
    
 
7487
    static const double FE0_C3_D010[8][10] = \
 
7488
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, -1.00000000, 1.00000000, 0.00000000},
 
7489
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, -1.00000000, 1.00000000, 0.00000000},
 
7490
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, -1.00000000, 1.00000000, 0.00000000},
 
7491
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, -1.00000000, 1.00000000, 0.00000000},
 
7492
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, -1.00000000, 1.00000000, 0.00000000},
 
7493
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, -1.00000000, 1.00000000, 0.00000000},
 
7494
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, -1.00000000, 1.00000000, 0.00000000},
 
7495
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, 0.00000000, -1.00000000, 1.00000000, 0.00000000}};
 
7496
    
 
7497
    static const double FE0_C3_D100[8][10] = \
 
7498
    {{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000},
 
7499
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000},
 
7500
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000},
 
7501
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000},
 
7502
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000},
 
7503
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000},
 
7504
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000},
 
7505
    {0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.00000000, 0.00000000, -1.00000000, 0.00000000, 1.00000000}};
 
7506
    
 
7507
    for (unsigned int r = 0; r < 100; r++)
 
7508
    {
 
7509
      A[r] = 0.00000000;
 
7510
    }// end loop over 'r'
 
7511
    
 
7512
    // Compute element tensor using UFL quadrature representation
 
7513
    // Optimisations: ('simplify expressions', False), ('ignore zero tables', False), ('non zero columns', False), ('remove zero terms', False), ('ignore ones', False)
 
7514
    
 
7515
    // Loop quadrature points for integral
 
7516
    // Number of operations to compute element tensor for following IP loop = 325600
 
7517
    for (unsigned int ip = 0; ip < 8; ip++)
 
7518
    {
 
7519
      
 
7520
      // Number of operations for primary indices: 40700
 
7521
      for (unsigned int j = 0; j < 10; j++)
 
7522
      {
 
7523
        for (unsigned int k = 0; k < 10; k++)
 
7524
        {
 
7525
          // Number of operations to compute entry: 407
 
7526
          A[j*10 + k] += (((((((K_02*K_01*FE0_C1_D100[ip][j] + K_02*K_11*FE0_C2_D100[ip][j] + K_02*K_21*FE0_C3_D100[ip][j] + K_12*K_01*FE0_C1_D010[ip][j] + K_12*K_11*FE0_C1_D100[ip][j] + K_12*K_21*FE0_C3_D010[ip][j] + K_22*K_01*FE0_C1_D001[ip][j] + K_22*K_11*FE0_C2_D001[ip][j] + K_22*K_21*FE0_C1_D100[ip][j]))*(-1.00000000) + (K_01*K_02*FE0_C1_D100[ip][j] + K_01*K_12*FE0_C2_D100[ip][j] + K_01*K_22*FE0_C3_D100[ip][j] + K_11*K_02*FE0_C1_D010[ip][j] + K_11*K_12*FE0_C1_D100[ip][j] + K_11*K_22*FE0_C3_D010[ip][j] + K_21*K_02*FE0_C1_D001[ip][j] + K_21*K_12*FE0_C2_D001[ip][j] + K_21*K_22*FE0_C1_D100[ip][j])))*((((K_02*K_01*FE0_C1_D100[ip][k] + K_02*K_11*FE0_C2_D100[ip][k] + K_02*K_21*FE0_C3_D100[ip][k] + K_12*K_01*FE0_C1_D010[ip][k] + K_12*K_11*FE0_C1_D100[ip][k] + K_12*K_21*FE0_C3_D010[ip][k] + K_22*K_01*FE0_C1_D001[ip][k] + K_22*K_11*FE0_C2_D001[ip][k] + K_22*K_21*FE0_C1_D100[ip][k]))*(-1.00000000) + (K_01*K_02*FE0_C1_D100[ip][k] + K_01*K_12*FE0_C2_D100[ip][k] + K_01*K_22*FE0_C3_D100[ip][k] + K_11*K_02*FE0_C1_D010[ip][k] + K_11*K_12*FE0_C1_D100[ip][k] + K_11*K_22*FE0_C3_D010[ip][k] + K_21*K_02*FE0_C1_D001[ip][k] + K_21*K_12*FE0_C2_D001[ip][k] + K_21*K_22*FE0_C1_D100[ip][k]))) + (((K_00*K_01*FE0_C1_D100[ip][j] + K_00*K_11*FE0_C2_D100[ip][j] + K_00*K_21*FE0_C3_D100[ip][j] + K_10*K_01*FE0_C1_D010[ip][j] + K_10*K_11*FE0_C1_D100[ip][j] + K_10*K_21*FE0_C3_D010[ip][j] + K_20*K_01*FE0_C1_D001[ip][j] + K_20*K_11*FE0_C2_D001[ip][j] + K_20*K_21*FE0_C1_D100[ip][j]) + ((K_01*K_00*FE0_C1_D100[ip][j] + K_01*K_10*FE0_C2_D100[ip][j] + K_01*K_20*FE0_C3_D100[ip][j] + K_11*K_00*FE0_C1_D010[ip][j] + K_11*K_10*FE0_C1_D100[ip][j] + K_11*K_20*FE0_C3_D010[ip][j] + K_21*K_00*FE0_C1_D001[ip][j] + K_21*K_10*FE0_C2_D001[ip][j] + K_21*K_20*FE0_C1_D100[ip][j]))*(-1.00000000)))*(((K_00*K_01*FE0_C1_D100[ip][k] + K_00*K_11*FE0_C2_D100[ip][k] + K_00*K_21*FE0_C3_D100[ip][k] + K_10*K_01*FE0_C1_D010[ip][k] + K_10*K_11*FE0_C1_D100[ip][k] + K_10*K_21*FE0_C3_D010[ip][k] + K_20*K_01*FE0_C1_D001[ip][k] + K_20*K_11*FE0_C2_D001[ip][k] + K_20*K_21*FE0_C1_D100[ip][k]) + ((K_01*K_00*FE0_C1_D100[ip][k] + K_01*K_10*FE0_C2_D100[ip][k] + K_01*K_20*FE0_C3_D100[ip][k] + K_11*K_00*FE0_C1_D010[ip][k] + K_11*K_10*FE0_C1_D100[ip][k] + K_11*K_20*FE0_C3_D010[ip][k] + K_21*K_00*FE0_C1_D001[ip][k] + K_21*K_10*FE0_C2_D001[ip][k] + K_21*K_20*FE0_C1_D100[ip][k]))*(-1.00000000))) + (((K_02*K_00*FE0_C1_D100[ip][j] + K_02*K_10*FE0_C2_D100[ip][j] + K_02*K_20*FE0_C3_D100[ip][j] + K_12*K_00*FE0_C1_D010[ip][j] + K_12*K_10*FE0_C1_D100[ip][j] + K_12*K_20*FE0_C3_D010[ip][j] + K_22*K_00*FE0_C1_D001[ip][j] + K_22*K_10*FE0_C2_D001[ip][j] + K_22*K_20*FE0_C1_D100[ip][j]) + ((K_00*K_02*FE0_C1_D100[ip][j] + K_00*K_12*FE0_C2_D100[ip][j] + K_00*K_22*FE0_C3_D100[ip][j] + K_10*K_02*FE0_C1_D010[ip][j] + K_10*K_12*FE0_C1_D100[ip][j] + K_10*K_22*FE0_C3_D010[ip][j] + K_20*K_02*FE0_C1_D001[ip][j] + K_20*K_12*FE0_C2_D001[ip][j] + K_20*K_22*FE0_C1_D100[ip][j]))*(-1.00000000)))*(((K_02*K_00*FE0_C1_D100[ip][k] + K_02*K_10*FE0_C2_D100[ip][k] + K_02*K_20*FE0_C3_D100[ip][k] + K_12*K_00*FE0_C1_D010[ip][k] + K_12*K_10*FE0_C1_D100[ip][k] + K_12*K_20*FE0_C3_D010[ip][k] + K_22*K_00*FE0_C1_D001[ip][k] + K_22*K_10*FE0_C2_D001[ip][k] + K_22*K_20*FE0_C1_D100[ip][k]) + ((K_00*K_02*FE0_C1_D100[ip][k] + K_00*K_12*FE0_C2_D100[ip][k] + K_00*K_22*FE0_C3_D100[ip][k] + K_10*K_02*FE0_C1_D010[ip][k] + K_10*K_12*FE0_C1_D100[ip][k] + K_10*K_22*FE0_C3_D010[ip][k] + K_20*K_02*FE0_C1_D001[ip][k] + K_20*K_12*FE0_C2_D001[ip][k] + K_20*K_22*FE0_C1_D100[ip][k]))*(-1.00000000)))) + ((((K_00*FE0_C0_D100[ip][k] + K_10*FE0_C0_D010[ip][k] + K_20*FE0_C0_D001[ip][k]))*((K_00*FE0_C1[ip][j] + K_10*FE0_C2[ip][j] + K_20*FE0_C3[ip][j])) + ((K_01*FE0_C0_D100[ip][k] + K_11*FE0_C0_D010[ip][k] + K_21*FE0_C0_D001[ip][k]))*((K_01*FE0_C1[ip][j] + K_11*FE0_C2[ip][j] + K_21*FE0_C3[ip][j])) + ((K_02*FE0_C0_D100[ip][k] + K_12*FE0_C0_D010[ip][k] + K_22*FE0_C0_D001[ip][k]))*((K_02*FE0_C1[ip][j] + K_12*FE0_C2[ip][j] + K_22*FE0_C3[ip][j]))) + (((((K_00*FE0_C0_D100[ip][j] + K_10*FE0_C0_D010[ip][j] + K_20*FE0_C0_D001[ip][j]))*((K_00*FE0_C1[ip][k] + K_10*FE0_C2[ip][k] + K_20*FE0_C3[ip][k])) + ((K_01*FE0_C0_D100[ip][j] + K_11*FE0_C0_D010[ip][j] + K_21*FE0_C0_D001[ip][j]))*((K_01*FE0_C1[ip][k] + K_11*FE0_C2[ip][k] + K_21*FE0_C3[ip][k])) + ((K_02*FE0_C0_D100[ip][j] + K_12*FE0_C0_D010[ip][j] + K_22*FE0_C0_D001[ip][j]))*((K_02*FE0_C1[ip][k] + K_12*FE0_C2[ip][k] + K_22*FE0_C3[ip][k]))))*(-1.00000000) + FE0_C0[ip][j]*FE0_C0[ip][k]))))*W8[ip]*det;
 
7527
        }// end loop over 'k'
 
7528
      }// end loop over 'j'
 
7529
    }// end loop over 'ip'
 
7530
  }
 
7531
 
 
7532
};
 
7533
 
 
7534
/// This class defines the interface for the tabulation of the cell
 
7535
/// tensor corresponding to the local contribution to a form from
 
7536
/// the integral over a cell.
 
7537
 
 
7538
class vectorlaplacegradcurl_cell_integral_1_0: public ufc::cell_integral
 
7539
{
 
7540
public:
 
7541
 
 
7542
  /// Constructor
 
7543
  vectorlaplacegradcurl_cell_integral_1_0() : ufc::cell_integral()
 
7544
  {
 
7545
    // Do nothing
 
7546
  }
 
7547
 
 
7548
  /// Destructor
 
7549
  virtual ~vectorlaplacegradcurl_cell_integral_1_0()
 
7550
  {
 
7551
    // Do nothing
 
7552
  }
 
7553
 
 
7554
  /// Tabulate the tensor for the contribution from a local cell
 
7555
  virtual void tabulate_tensor(double* A,
 
7556
                               const double * const * w,
 
7557
                               const ufc::cell& c) const
 
7558
  {
 
7559
    // Number of operations (multiply-add pairs) for Jacobian data:      32
 
7560
    // Number of operations (multiply-add pairs) for geometry tensor:    135
 
7561
    // Number of operations (multiply-add pairs) for tensor contraction: 412
 
7562
    // Total number of operations (multiply-add pairs):                  579
 
7563
    
 
7564
    // Extract vertex coordinates
 
7565
    const double * const * x = c.coordinates;
 
7566
    
 
7567
    // Compute Jacobian of affine map from reference cell
 
7568
    const double J_00 = x[1][0] - x[0][0];
 
7569
    const double J_01 = x[2][0] - x[0][0];
 
7570
    const double J_02 = x[3][0] - x[0][0];
 
7571
    const double J_10 = x[1][1] - x[0][1];
 
7572
    const double J_11 = x[2][1] - x[0][1];
 
7573
    const double J_12 = x[3][1] - x[0][1];
 
7574
    const double J_20 = x[1][2] - x[0][2];
 
7575
    const double J_21 = x[2][2] - x[0][2];
 
7576
    const double J_22 = x[3][2] - x[0][2];
 
7577
    
 
7578
    // Compute sub determinants
 
7579
    const double d_00 = J_11*J_22 - J_12*J_21;
 
7580
    const double d_01 = J_12*J_20 - J_10*J_22;
 
7581
    const double d_02 = J_10*J_21 - J_11*J_20;
 
7582
    const double d_10 = J_02*J_21 - J_01*J_22;
 
7583
    const double d_11 = J_00*J_22 - J_02*J_20;
 
7584
    const double d_12 = J_01*J_20 - J_00*J_21;
 
7585
    const double d_20 = J_01*J_12 - J_02*J_11;
 
7586
    const double d_21 = J_02*J_10 - J_00*J_12;
 
7587
    const double d_22 = J_00*J_11 - J_01*J_10;
 
7588
    
 
7589
    // Compute determinant of Jacobian
 
7590
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
 
7591
    
 
7592
    // Compute inverse of Jacobian
 
7593
    const double K_00 = d_00 / detJ;
 
7594
    const double K_01 = d_10 / detJ;
 
7595
    const double K_02 = d_20 / detJ;
 
7596
    const double K_10 = d_01 / detJ;
 
7597
    const double K_11 = d_11 / detJ;
 
7598
    const double K_12 = d_21 / detJ;
 
7599
    const double K_20 = d_02 / detJ;
 
7600
    const double K_21 = d_12 / detJ;
 
7601
    const double K_22 = d_22 / detJ;
 
7602
    
 
7603
    // Set scale factor
 
7604
    const double det = std::abs(detJ);
 
7605
    
 
7606
    // Compute geometry tensor
 
7607
    const double G0_0_20 = det*w[0][20]*K_02*(1.0);
 
7608
    const double G0_0_21 = det*w[0][21]*K_02*(1.0);
 
7609
    const double G0_0_22 = det*w[0][22]*K_02*(1.0);
 
7610
    const double G0_0_23 = det*w[0][23]*K_02*(1.0);
 
7611
    const double G0_0_24 = det*w[0][24]*K_02*(1.0);
 
7612
    const double G0_0_25 = det*w[0][25]*K_02*(1.0);
 
7613
    const double G0_0_26 = det*w[0][26]*K_02*(1.0);
 
7614
    const double G0_0_27 = det*w[0][27]*K_02*(1.0);
 
7615
    const double G0_0_28 = det*w[0][28]*K_02*(1.0);
 
7616
    const double G0_0_29 = det*w[0][29]*K_02*(1.0);
 
7617
    const double G0_1_20 = det*w[0][20]*K_12*(1.0);
 
7618
    const double G0_1_21 = det*w[0][21]*K_12*(1.0);
 
7619
    const double G0_1_22 = det*w[0][22]*K_12*(1.0);
 
7620
    const double G0_1_23 = det*w[0][23]*K_12*(1.0);
 
7621
    const double G0_1_24 = det*w[0][24]*K_12*(1.0);
 
7622
    const double G0_1_25 = det*w[0][25]*K_12*(1.0);
 
7623
    const double G0_1_26 = det*w[0][26]*K_12*(1.0);
 
7624
    const double G0_1_27 = det*w[0][27]*K_12*(1.0);
 
7625
    const double G0_1_28 = det*w[0][28]*K_12*(1.0);
 
7626
    const double G0_1_29 = det*w[0][29]*K_12*(1.0);
 
7627
    const double G0_2_20 = det*w[0][20]*K_22*(1.0);
 
7628
    const double G0_2_21 = det*w[0][21]*K_22*(1.0);
 
7629
    const double G0_2_22 = det*w[0][22]*K_22*(1.0);
 
7630
    const double G0_2_23 = det*w[0][23]*K_22*(1.0);
 
7631
    const double G0_2_24 = det*w[0][24]*K_22*(1.0);
 
7632
    const double G0_2_25 = det*w[0][25]*K_22*(1.0);
 
7633
    const double G0_2_26 = det*w[0][26]*K_22*(1.0);
 
7634
    const double G0_2_27 = det*w[0][27]*K_22*(1.0);
 
7635
    const double G0_2_28 = det*w[0][28]*K_22*(1.0);
 
7636
    const double G0_2_29 = det*w[0][29]*K_22*(1.0);
 
7637
    const double G1_0_0 = det*w[0][0]*K_00*(1.0);
 
7638
    const double G1_0_1 = det*w[0][1]*K_00*(1.0);
 
7639
    const double G1_0_2 = det*w[0][2]*K_00*(1.0);
 
7640
    const double G1_0_3 = det*w[0][3]*K_00*(1.0);
 
7641
    const double G1_0_4 = det*w[0][4]*K_00*(1.0);
 
7642
    const double G1_0_5 = det*w[0][5]*K_00*(1.0);
 
7643
    const double G1_0_6 = det*w[0][6]*K_00*(1.0);
 
7644
    const double G1_0_7 = det*w[0][7]*K_00*(1.0);
 
7645
    const double G1_0_8 = det*w[0][8]*K_00*(1.0);
 
7646
    const double G1_0_9 = det*w[0][9]*K_00*(1.0);
 
7647
    const double G1_1_0 = det*w[0][0]*K_10*(1.0);
 
7648
    const double G1_1_1 = det*w[0][1]*K_10*(1.0);
 
7649
    const double G1_1_2 = det*w[0][2]*K_10*(1.0);
 
7650
    const double G1_1_3 = det*w[0][3]*K_10*(1.0);
 
7651
    const double G1_1_4 = det*w[0][4]*K_10*(1.0);
 
7652
    const double G1_1_5 = det*w[0][5]*K_10*(1.0);
 
7653
    const double G1_1_6 = det*w[0][6]*K_10*(1.0);
 
7654
    const double G1_1_7 = det*w[0][7]*K_10*(1.0);
 
7655
    const double G1_1_8 = det*w[0][8]*K_10*(1.0);
 
7656
    const double G1_1_9 = det*w[0][9]*K_10*(1.0);
 
7657
    const double G1_2_0 = det*w[0][0]*K_20*(1.0);
 
7658
    const double G1_2_1 = det*w[0][1]*K_20*(1.0);
 
7659
    const double G1_2_2 = det*w[0][2]*K_20*(1.0);
 
7660
    const double G1_2_3 = det*w[0][3]*K_20*(1.0);
 
7661
    const double G1_2_4 = det*w[0][4]*K_20*(1.0);
 
7662
    const double G1_2_5 = det*w[0][5]*K_20*(1.0);
 
7663
    const double G1_2_6 = det*w[0][6]*K_20*(1.0);
 
7664
    const double G1_2_7 = det*w[0][7]*K_20*(1.0);
 
7665
    const double G1_2_8 = det*w[0][8]*K_20*(1.0);
 
7666
    const double G1_2_9 = det*w[0][9]*K_20*(1.0);
 
7667
    const double G2_0_10 = det*w[0][10]*K_01*(1.0);
 
7668
    const double G2_0_11 = det*w[0][11]*K_01*(1.0);
 
7669
    const double G2_0_12 = det*w[0][12]*K_01*(1.0);
 
7670
    const double G2_0_13 = det*w[0][13]*K_01*(1.0);
 
7671
    const double G2_0_14 = det*w[0][14]*K_01*(1.0);
 
7672
    const double G2_0_15 = det*w[0][15]*K_01*(1.0);
 
7673
    const double G2_0_16 = det*w[0][16]*K_01*(1.0);
 
7674
    const double G2_0_17 = det*w[0][17]*K_01*(1.0);
 
7675
    const double G2_0_18 = det*w[0][18]*K_01*(1.0);
 
7676
    const double G2_0_19 = det*w[0][19]*K_01*(1.0);
 
7677
    const double G2_1_10 = det*w[0][10]*K_11*(1.0);
 
7678
    const double G2_1_11 = det*w[0][11]*K_11*(1.0);
 
7679
    const double G2_1_12 = det*w[0][12]*K_11*(1.0);
 
7680
    const double G2_1_13 = det*w[0][13]*K_11*(1.0);
 
7681
    const double G2_1_14 = det*w[0][14]*K_11*(1.0);
 
7682
    const double G2_1_15 = det*w[0][15]*K_11*(1.0);
 
7683
    const double G2_1_16 = det*w[0][16]*K_11*(1.0);
 
7684
    const double G2_1_17 = det*w[0][17]*K_11*(1.0);
 
7685
    const double G2_1_18 = det*w[0][18]*K_11*(1.0);
 
7686
    const double G2_1_19 = det*w[0][19]*K_11*(1.0);
 
7687
    const double G2_2_10 = det*w[0][10]*K_21*(1.0);
 
7688
    const double G2_2_11 = det*w[0][11]*K_21*(1.0);
 
7689
    const double G2_2_12 = det*w[0][12]*K_21*(1.0);
 
7690
    const double G2_2_13 = det*w[0][13]*K_21*(1.0);
 
7691
    const double G2_2_14 = det*w[0][14]*K_21*(1.0);
 
7692
    const double G2_2_15 = det*w[0][15]*K_21*(1.0);
 
7693
    const double G2_2_16 = det*w[0][16]*K_21*(1.0);
 
7694
    const double G2_2_17 = det*w[0][17]*K_21*(1.0);
 
7695
    const double G2_2_18 = det*w[0][18]*K_21*(1.0);
 
7696
    const double G2_2_19 = det*w[0][19]*K_21*(1.0);
 
7697
    
 
7698
    // Compute element tensor
 
7699
    A[0] = 0.00000000;
 
7700
    A[1] = 0.00000000;
 
7701
    A[2] = 0.00000000;
 
7702
    A[3] = 0.00000000;
 
7703
    A[4] = 0.00277778*G0_1_20 + 0.00277778*G0_1_21 + 0.00277778*G0_1_22 - 0.01111111*G0_1_24 - 0.01111111*G0_1_25 - 0.00555556*G0_1_26 - 0.01111111*G0_1_27 - 0.00555556*G0_1_28 - 0.00555556*G0_1_29 - 0.00277778*G0_2_20 - 0.00277778*G0_2_21 - 0.00277778*G0_2_23 + 0.01111111*G0_2_24 + 0.00555556*G0_2_25 + 0.01111111*G0_2_26 + 0.00555556*G0_2_27 + 0.01111111*G0_2_28 + 0.00555556*G0_2_29 + 0.00277778*G1_1_0 + 0.00277778*G1_1_1 + 0.00277778*G1_1_2 - 0.01111111*G1_1_4 - 0.01111111*G1_1_5 - 0.00555556*G1_1_6 - 0.01111111*G1_1_7 - 0.00555556*G1_1_8 - 0.00555556*G1_1_9 - 0.00277778*G1_2_0 - 0.00277778*G1_2_1 - 0.00277778*G1_2_3 + 0.01111111*G1_2_4 + 0.00555556*G1_2_5 + 0.01111111*G1_2_6 + 0.00555556*G1_2_7 + 0.01111111*G1_2_8 + 0.00555556*G1_2_9 + 0.00277778*G2_1_10 + 0.00277778*G2_1_11 + 0.00277778*G2_1_12 - 0.01111111*G2_1_14 - 0.01111111*G2_1_15 - 0.00555556*G2_1_16 - 0.01111111*G2_1_17 - 0.00555556*G2_1_18 - 0.00555556*G2_1_19 - 0.00277778*G2_2_10 - 0.00277778*G2_2_11 - 0.00277778*G2_2_13 + 0.01111111*G2_2_14 + 0.00555556*G2_2_15 + 0.01111111*G2_2_16 + 0.00555556*G2_2_17 + 0.01111111*G2_2_18 + 0.00555556*G2_2_19;
 
7704
    A[5] = 0.00277778*G0_0_20 + 0.00277778*G0_0_21 + 0.00277778*G0_0_22 - 0.01111111*G0_0_24 - 0.01111111*G0_0_25 - 0.00555556*G0_0_26 - 0.01111111*G0_0_27 - 0.00555556*G0_0_28 - 0.00555556*G0_0_29 - 0.00277778*G0_2_20 - 0.00277778*G0_2_22 - 0.00277778*G0_2_23 + 0.00555556*G0_2_24 + 0.01111111*G0_2_25 + 0.01111111*G0_2_26 + 0.00555556*G0_2_27 + 0.00555556*G0_2_28 + 0.01111111*G0_2_29 + 0.00277778*G1_0_0 + 0.00277778*G1_0_1 + 0.00277778*G1_0_2 - 0.01111111*G1_0_4 - 0.01111111*G1_0_5 - 0.00555556*G1_0_6 - 0.01111111*G1_0_7 - 0.00555556*G1_0_8 - 0.00555556*G1_0_9 - 0.00277778*G1_2_0 - 0.00277778*G1_2_2 - 0.00277778*G1_2_3 + 0.00555556*G1_2_4 + 0.01111111*G1_2_5 + 0.01111111*G1_2_6 + 0.00555556*G1_2_7 + 0.00555556*G1_2_8 + 0.01111111*G1_2_9 + 0.00277778*G2_0_10 + 0.00277778*G2_0_11 + 0.00277778*G2_0_12 - 0.01111111*G2_0_14 - 0.01111111*G2_0_15 - 0.00555556*G2_0_16 - 0.01111111*G2_0_17 - 0.00555556*G2_0_18 - 0.00555556*G2_0_19 - 0.00277778*G2_2_10 - 0.00277778*G2_2_12 - 0.00277778*G2_2_13 + 0.00555556*G2_2_14 + 0.01111111*G2_2_15 + 0.01111111*G2_2_16 + 0.00555556*G2_2_17 + 0.00555556*G2_2_18 + 0.01111111*G2_2_19;
 
7705
    A[6] = 0.00277778*G0_0_20 + 0.00277778*G0_0_21 + 0.00277778*G0_0_23 - 0.01111111*G0_0_24 - 0.00555556*G0_0_25 - 0.01111111*G0_0_26 - 0.00555556*G0_0_27 - 0.01111111*G0_0_28 - 0.00555556*G0_0_29 - 0.00277778*G0_1_20 - 0.00277778*G0_1_22 - 0.00277778*G0_1_23 + 0.00555556*G0_1_24 + 0.01111111*G0_1_25 + 0.01111111*G0_1_26 + 0.00555556*G0_1_27 + 0.00555556*G0_1_28 + 0.01111111*G0_1_29 + 0.00277778*G1_0_0 + 0.00277778*G1_0_1 + 0.00277778*G1_0_3 - 0.01111111*G1_0_4 - 0.00555556*G1_0_5 - 0.01111111*G1_0_6 - 0.00555556*G1_0_7 - 0.01111111*G1_0_8 - 0.00555556*G1_0_9 - 0.00277778*G1_1_0 - 0.00277778*G1_1_2 - 0.00277778*G1_1_3 + 0.00555556*G1_1_4 + 0.01111111*G1_1_5 + 0.01111111*G1_1_6 + 0.00555556*G1_1_7 + 0.00555556*G1_1_8 + 0.01111111*G1_1_9 + 0.00277778*G2_0_10 + 0.00277778*G2_0_11 + 0.00277778*G2_0_13 - 0.01111111*G2_0_14 - 0.00555556*G2_0_15 - 0.01111111*G2_0_16 - 0.00555556*G2_0_17 - 0.01111111*G2_0_18 - 0.00555556*G2_0_19 - 0.00277778*G2_1_10 - 0.00277778*G2_1_12 - 0.00277778*G2_1_13 + 0.00555556*G2_1_14 + 0.01111111*G2_1_15 + 0.01111111*G2_1_16 + 0.00555556*G2_1_17 + 0.00555556*G2_1_18 + 0.01111111*G2_1_19;
 
7706
    A[7] = (-0.00277778)*G0_0_20 - 0.00277778*G0_0_21 - 0.00277778*G0_0_22 + 0.01111111*G0_0_24 + 0.01111111*G0_0_25 + 0.00555556*G0_0_26 + 0.01111111*G0_0_27 + 0.00555556*G0_0_28 + 0.00555556*G0_0_29 - 0.00277778*G0_1_20 - 0.00277778*G0_1_21 - 0.00277778*G0_1_22 + 0.01111111*G0_1_24 + 0.01111111*G0_1_25 + 0.00555556*G0_1_26 + 0.01111111*G0_1_27 + 0.00555556*G0_1_28 + 0.00555556*G0_1_29 - 0.00277778*G0_2_20 - 0.00555556*G0_2_21 - 0.00555556*G0_2_22 - 0.00277778*G0_2_23 + 0.01666667*G0_2_24 + 0.01666667*G0_2_25 + 0.01111111*G0_2_26 + 0.02222222*G0_2_27 + 0.01666667*G0_2_28 + 0.01666667*G0_2_29 - 0.00277778*G1_0_0 - 0.00277778*G1_0_1 - 0.00277778*G1_0_2 + 0.01111111*G1_0_4 + 0.01111111*G1_0_5 + 0.00555556*G1_0_6 + 0.01111111*G1_0_7 + 0.00555556*G1_0_8 + 0.00555556*G1_0_9 - 0.00277778*G1_1_0 - 0.00277778*G1_1_1 - 0.00277778*G1_1_2 + 0.01111111*G1_1_4 + 0.01111111*G1_1_5 + 0.00555556*G1_1_6 + 0.01111111*G1_1_7 + 0.00555556*G1_1_8 + 0.00555556*G1_1_9 - 0.00277778*G1_2_0 - 0.00555556*G1_2_1 - 0.00555556*G1_2_2 - 0.00277778*G1_2_3 + 0.01666667*G1_2_4 + 0.01666667*G1_2_5 + 0.01111111*G1_2_6 + 0.02222222*G1_2_7 + 0.01666667*G1_2_8 + 0.01666667*G1_2_9 - 0.00277778*G2_0_10 - 0.00277778*G2_0_11 - 0.00277778*G2_0_12 + 0.01111111*G2_0_14 + 0.01111111*G2_0_15 + 0.00555556*G2_0_16 + 0.01111111*G2_0_17 + 0.00555556*G2_0_18 + 0.00555556*G2_0_19 - 0.00277778*G2_1_10 - 0.00277778*G2_1_11 - 0.00277778*G2_1_12 + 0.01111111*G2_1_14 + 0.01111111*G2_1_15 + 0.00555556*G2_1_16 + 0.01111111*G2_1_17 + 0.00555556*G2_1_18 + 0.00555556*G2_1_19 - 0.00277778*G2_2_10 - 0.00555556*G2_2_11 - 0.00555556*G2_2_12 - 0.00277778*G2_2_13 + 0.01666667*G2_2_14 + 0.01666667*G2_2_15 + 0.01111111*G2_2_16 + 0.02222222*G2_2_17 + 0.01666667*G2_2_18 + 0.01666667*G2_2_19;
 
7707
    A[8] = (-0.00277778)*G0_0_20 - 0.00277778*G0_0_21 - 0.00277778*G0_0_23 + 0.01111111*G0_0_24 + 0.00555556*G0_0_25 + 0.01111111*G0_0_26 + 0.00555556*G0_0_27 + 0.01111111*G0_0_28 + 0.00555556*G0_0_29 - 0.00277778*G0_1_20 - 0.00555556*G0_1_21 - 0.00277778*G0_1_22 - 0.00555556*G0_1_23 + 0.01666667*G0_1_24 + 0.01111111*G0_1_25 + 0.01666667*G0_1_26 + 0.01666667*G0_1_27 + 0.02222222*G0_1_28 + 0.01666667*G0_1_29 - 0.00277778*G0_2_20 - 0.00277778*G0_2_21 - 0.00277778*G0_2_23 + 0.01111111*G0_2_24 + 0.00555556*G0_2_25 + 0.01111111*G0_2_26 + 0.00555556*G0_2_27 + 0.01111111*G0_2_28 + 0.00555556*G0_2_29 - 0.00277778*G1_0_0 - 0.00277778*G1_0_1 - 0.00277778*G1_0_3 + 0.01111111*G1_0_4 + 0.00555556*G1_0_5 + 0.01111111*G1_0_6 + 0.00555556*G1_0_7 + 0.01111111*G1_0_8 + 0.00555556*G1_0_9 - 0.00277778*G1_1_0 - 0.00555556*G1_1_1 - 0.00277778*G1_1_2 - 0.00555556*G1_1_3 + 0.01666667*G1_1_4 + 0.01111111*G1_1_5 + 0.01666667*G1_1_6 + 0.01666667*G1_1_7 + 0.02222222*G1_1_8 + 0.01666667*G1_1_9 - 0.00277778*G1_2_0 - 0.00277778*G1_2_1 - 0.00277778*G1_2_3 + 0.01111111*G1_2_4 + 0.00555556*G1_2_5 + 0.01111111*G1_2_6 + 0.00555556*G1_2_7 + 0.01111111*G1_2_8 + 0.00555556*G1_2_9 - 0.00277778*G2_0_10 - 0.00277778*G2_0_11 - 0.00277778*G2_0_13 + 0.01111111*G2_0_14 + 0.00555556*G2_0_15 + 0.01111111*G2_0_16 + 0.00555556*G2_0_17 + 0.01111111*G2_0_18 + 0.00555556*G2_0_19 - 0.00277778*G2_1_10 - 0.00555556*G2_1_11 - 0.00277778*G2_1_12 - 0.00555556*G2_1_13 + 0.01666667*G2_1_14 + 0.01111111*G2_1_15 + 0.01666667*G2_1_16 + 0.01666667*G2_1_17 + 0.02222222*G2_1_18 + 0.01666667*G2_1_19 - 0.00277778*G2_2_10 - 0.00277778*G2_2_11 - 0.00277778*G2_2_13 + 0.01111111*G2_2_14 + 0.00555556*G2_2_15 + 0.01111111*G2_2_16 + 0.00555556*G2_2_17 + 0.01111111*G2_2_18 + 0.00555556*G2_2_19;
 
7708
    A[9] = (-0.00277778)*G0_0_20 - 0.00277778*G0_0_21 - 0.00555556*G0_0_22 - 0.00555556*G0_0_23 + 0.01111111*G0_0_24 + 0.01666667*G0_0_25 + 0.01666667*G0_0_26 + 0.01666667*G0_0_27 + 0.01666667*G0_0_28 + 0.02222222*G0_0_29 - 0.00277778*G0_1_20 - 0.00277778*G0_1_22 - 0.00277778*G0_1_23 + 0.00555556*G0_1_24 + 0.01111111*G0_1_25 + 0.01111111*G0_1_26 + 0.00555556*G0_1_27 + 0.00555556*G0_1_28 + 0.01111111*G0_1_29 - 0.00277778*G0_2_20 - 0.00277778*G0_2_22 - 0.00277778*G0_2_23 + 0.00555556*G0_2_24 + 0.01111111*G0_2_25 + 0.01111111*G0_2_26 + 0.00555556*G0_2_27 + 0.00555556*G0_2_28 + 0.01111111*G0_2_29 - 0.00277778*G1_0_0 - 0.00277778*G1_0_1 - 0.00555556*G1_0_2 - 0.00555556*G1_0_3 + 0.01111111*G1_0_4 + 0.01666667*G1_0_5 + 0.01666667*G1_0_6 + 0.01666667*G1_0_7 + 0.01666667*G1_0_8 + 0.02222222*G1_0_9 - 0.00277778*G1_1_0 - 0.00277778*G1_1_2 - 0.00277778*G1_1_3 + 0.00555556*G1_1_4 + 0.01111111*G1_1_5 + 0.01111111*G1_1_6 + 0.00555556*G1_1_7 + 0.00555556*G1_1_8 + 0.01111111*G1_1_9 - 0.00277778*G1_2_0 - 0.00277778*G1_2_2 - 0.00277778*G1_2_3 + 0.00555556*G1_2_4 + 0.01111111*G1_2_5 + 0.01111111*G1_2_6 + 0.00555556*G1_2_7 + 0.00555556*G1_2_8 + 0.01111111*G1_2_9 - 0.00277778*G2_0_10 - 0.00277778*G2_0_11 - 0.00555556*G2_0_12 - 0.00555556*G2_0_13 + 0.01111111*G2_0_14 + 0.01666667*G2_0_15 + 0.01666667*G2_0_16 + 0.01666667*G2_0_17 + 0.01666667*G2_0_18 + 0.02222222*G2_0_19 - 0.00277778*G2_1_10 - 0.00277778*G2_1_12 - 0.00277778*G2_1_13 + 0.00555556*G2_1_14 + 0.01111111*G2_1_15 + 0.01111111*G2_1_16 + 0.00555556*G2_1_17 + 0.00555556*G2_1_18 + 0.01111111*G2_1_19 - 0.00277778*G2_2_10 - 0.00277778*G2_2_12 - 0.00277778*G2_2_13 + 0.00555556*G2_2_14 + 0.01111111*G2_2_15 + 0.01111111*G2_2_16 + 0.00555556*G2_2_17 + 0.00555556*G2_2_18 + 0.01111111*G2_2_19;
 
7709
  }
 
7710
 
 
7711
};
 
7712
 
 
7713
/// This class defines the interface for the assembly of the global
 
7714
/// tensor corresponding to a form with r + n arguments, that is, a
 
7715
/// mapping
 
7716
///
 
7717
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
7718
///
 
7719
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
7720
/// global tensor A is defined by
 
7721
///
 
7722
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
7723
///
 
7724
/// where each argument Vj represents the application to the
 
7725
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
7726
/// fixed functions (coefficients).
 
7727
 
 
7728
class vectorlaplacegradcurl_form_0: public ufc::form
 
7729
{
 
7730
public:
 
7731
 
 
7732
  /// Constructor
 
7733
  vectorlaplacegradcurl_form_0() : ufc::form()
 
7734
  {
 
7735
    // Do nothing
 
7736
  }
 
7737
 
 
7738
  /// Destructor
 
7739
  virtual ~vectorlaplacegradcurl_form_0()
 
7740
  {
 
7741
    // Do nothing
 
7742
  }
 
7743
 
 
7744
  /// Return a string identifying the form
 
7745
  virtual const char* signature() const
 
7746
  {
 
7747
    return "Form([Integral(Sum(IndexSum(Product(Indexed(ListTensor(Sum(Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(1),), {FixedIndex(1): 3})), MultiIndex((FixedIndex(3),), {FixedIndex(3): 4})), Product(IntValue(-1, (), (), {}), Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(2),), {FixedIndex(2): 3})), MultiIndex((FixedIndex(2),), {FixedIndex(2): 4})))), Sum(Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(2),), {FixedIndex(2): 3})), MultiIndex((FixedIndex(1),), {FixedIndex(1): 4})), Product(IntValue(-1, (), (), {}), Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(0),), {FixedIndex(0): 3})), MultiIndex((FixedIndex(3),), {FixedIndex(3): 4})))), Sum(Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(0),), {FixedIndex(0): 3})), MultiIndex((FixedIndex(2),), {FixedIndex(2): 4})), Product(IntValue(-1, (), (), {}), Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(1),), {FixedIndex(1): 3})), MultiIndex((FixedIndex(1),), {FixedIndex(1): 4}))))), MultiIndex((Index(0),), {Index(0): 3})), Indexed(ListTensor(Sum(Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(1),), {FixedIndex(1): 3})), MultiIndex((FixedIndex(3),), {FixedIndex(3): 4})), Product(IntValue(-1, (), (), {}), Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(2),), {FixedIndex(2): 3})), MultiIndex((FixedIndex(2),), {FixedIndex(2): 4})))), Sum(Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(2),), {FixedIndex(2): 3})), MultiIndex((FixedIndex(1),), {FixedIndex(1): 4})), Product(IntValue(-1, (), (), {}), Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(0),), {FixedIndex(0): 3})), MultiIndex((FixedIndex(3),), {FixedIndex(3): 4})))), Sum(Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(0),), {FixedIndex(0): 3})), MultiIndex((FixedIndex(2),), {FixedIndex(2): 4})), Product(IntValue(-1, (), (), {}), Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(1),), {FixedIndex(1): 3})), MultiIndex((FixedIndex(1),), {FixedIndex(1): 4}))))), MultiIndex((Index(0),), {Index(0): 3}))), MultiIndex((Index(0),), {Index(0): 3})), Sum(IndexSum(Product(Indexed(ComponentTensor(Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((Index(1),), {Index(1): 3})), MultiIndex((FixedIndex(0),), {})), MultiIndex((Index(1),), {Index(1): 3})), MultiIndex((Index(2),), {Index(2): 3})), Indexed(ListTensor(Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(1),), {FixedIndex(1): 4})), Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(2),), {FixedIndex(2): 4})), Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(3),), {FixedIndex(3): 4}))), MultiIndex((Index(2),), {Index(2): 3}))), MultiIndex((Index(2),), {Index(2): 3})), Sum(Product(Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(0),), {FixedIndex(0): 4})), Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(0),), {FixedIndex(0): 4}))), Product(IntValue(-1, (), (), {}), IndexSum(Product(Indexed(ComponentTensor(Indexed(SpatialDerivative(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((Index(3),), {Index(3): 3})), MultiIndex((FixedIndex(0),), {})), MultiIndex((Index(3),), {Index(3): 3})), MultiIndex((Index(4),), {Index(4): 3})), Indexed(ListTensor(Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(1),), {FixedIndex(1): 4})), Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(2),), {FixedIndex(2): 4})), Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 1), MultiIndex((FixedIndex(3),), {FixedIndex(3): 4}))), MultiIndex((Index(4),), {Index(4): 3}))), MultiIndex((Index(4),), {Index(4): 3})))))), Measure('cell', 0, None))])";
 
7748
  }
 
7749
 
 
7750
  /// Return the rank of the global tensor (r)
 
7751
  virtual unsigned int rank() const
 
7752
  {
 
7753
    return 2;
 
7754
  }
 
7755
 
 
7756
  /// Return the number of coefficients (n)
 
7757
  virtual unsigned int num_coefficients() const
 
7758
  {
 
7759
    return 0;
 
7760
  }
 
7761
 
 
7762
  /// Return the number of cell integrals
 
7763
  virtual unsigned int num_cell_integrals() const
 
7764
  {
 
7765
    return 1;
 
7766
  }
 
7767
 
 
7768
  /// Return the number of exterior facet integrals
 
7769
  virtual unsigned int num_exterior_facet_integrals() const
 
7770
  {
 
7771
    return 0;
 
7772
  }
 
7773
 
 
7774
  /// Return the number of interior facet integrals
 
7775
  virtual unsigned int num_interior_facet_integrals() const
 
7776
  {
 
7777
    return 0;
 
7778
  }
 
7779
 
 
7780
  /// Create a new finite element for argument function i
 
7781
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
7782
  {
 
7783
    switch (i)
 
7784
    {
 
7785
    case 0:
 
7786
      {
 
7787
        return new vectorlaplacegradcurl_finite_element_4();
 
7788
        break;
 
7789
      }
 
7790
    case 1:
 
7791
      {
 
7792
        return new vectorlaplacegradcurl_finite_element_4();
 
7793
        break;
 
7794
      }
 
7795
    }
 
7796
    
 
7797
    return 0;
 
7798
  }
 
7799
 
 
7800
  /// Create a new dof map for argument function i
 
7801
  virtual ufc::dof_map* create_dof_map(unsigned int i) const
 
7802
  {
 
7803
    switch (i)
 
7804
    {
 
7805
    case 0:
 
7806
      {
 
7807
        return new vectorlaplacegradcurl_dof_map_4();
 
7808
        break;
 
7809
      }
 
7810
    case 1:
 
7811
      {
 
7812
        return new vectorlaplacegradcurl_dof_map_4();
 
7813
        break;
 
7814
      }
 
7815
    }
 
7816
    
 
7817
    return 0;
 
7818
  }
 
7819
 
 
7820
  /// Create a new cell integral on sub domain i
 
7821
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
7822
  {
 
7823
    switch (i)
 
7824
    {
 
7825
    case 0:
 
7826
      {
 
7827
        return new vectorlaplacegradcurl_cell_integral_0_0();
 
7828
        break;
 
7829
      }
 
7830
    }
 
7831
    
 
7832
    return 0;
 
7833
  }
 
7834
 
 
7835
  /// Create a new exterior facet integral on sub domain i
 
7836
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
7837
  {
 
7838
    return 0;
 
7839
  }
 
7840
 
 
7841
  /// Create a new interior facet integral on sub domain i
 
7842
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
7843
  {
 
7844
    return 0;
 
7845
  }
 
7846
 
 
7847
};
 
7848
 
 
7849
/// This class defines the interface for the assembly of the global
 
7850
/// tensor corresponding to a form with r + n arguments, that is, a
 
7851
/// mapping
 
7852
///
 
7853
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
7854
///
 
7855
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
7856
/// global tensor A is defined by
 
7857
///
 
7858
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
7859
///
 
7860
/// where each argument Vj represents the application to the
 
7861
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
7862
/// fixed functions (coefficients).
 
7863
 
 
7864
class vectorlaplacegradcurl_form_1: public ufc::form
 
7865
{
 
7866
public:
 
7867
 
 
7868
  /// Constructor
 
7869
  vectorlaplacegradcurl_form_1() : ufc::form()
 
7870
  {
 
7871
    // Do nothing
 
7872
  }
 
7873
 
 
7874
  /// Destructor
 
7875
  virtual ~vectorlaplacegradcurl_form_1()
 
7876
  {
 
7877
    // Do nothing
 
7878
  }
 
7879
 
 
7880
  /// Return a string identifying the form
 
7881
  virtual const char* signature() const
 
7882
  {
 
7883
    return "Form([Integral(IndexSum(Product(Indexed(Coefficient(VectorElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2, 3), 0), MultiIndex((Index(0),), {Index(0): 3})), Indexed(ListTensor(Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(1),), {FixedIndex(1): 4})), Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(2),), {FixedIndex(2): 4})), Indexed(Argument(MixedElement(*[FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 1), FiniteElement('Nedelec 1st kind H(curl)', Cell('tetrahedron', 1, Space(3)), 1)], **{'value_shape': (4,) }), 0), MultiIndex((FixedIndex(3),), {FixedIndex(3): 4}))), MultiIndex((Index(0),), {Index(0): 3}))), MultiIndex((Index(0),), {Index(0): 3})), Measure('cell', 0, None))])";
 
7884
  }
 
7885
 
 
7886
  /// Return the rank of the global tensor (r)
 
7887
  virtual unsigned int rank() const
 
7888
  {
 
7889
    return 1;
 
7890
  }
 
7891
 
 
7892
  /// Return the number of coefficients (n)
 
7893
  virtual unsigned int num_coefficients() const
 
7894
  {
 
7895
    return 1;
 
7896
  }
 
7897
 
 
7898
  /// Return the number of cell integrals
 
7899
  virtual unsigned int num_cell_integrals() const
 
7900
  {
 
7901
    return 1;
 
7902
  }
 
7903
 
 
7904
  /// Return the number of exterior facet integrals
 
7905
  virtual unsigned int num_exterior_facet_integrals() const
 
7906
  {
 
7907
    return 0;
 
7908
  }
 
7909
 
 
7910
  /// Return the number of interior facet integrals
 
7911
  virtual unsigned int num_interior_facet_integrals() const
 
7912
  {
 
7913
    return 0;
 
7914
  }
 
7915
 
 
7916
  /// Create a new finite element for argument function i
 
7917
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
7918
  {
 
7919
    switch (i)
 
7920
    {
 
7921
    case 0:
 
7922
      {
 
7923
        return new vectorlaplacegradcurl_finite_element_4();
 
7924
        break;
 
7925
      }
 
7926
    case 1:
 
7927
      {
 
7928
        return new vectorlaplacegradcurl_finite_element_1();
 
7929
        break;
 
7930
      }
 
7931
    }
 
7932
    
 
7933
    return 0;
 
7934
  }
 
7935
 
 
7936
  /// Create a new dof map for argument function i
 
7937
  virtual ufc::dof_map* create_dof_map(unsigned int i) const
 
7938
  {
 
7939
    switch (i)
 
7940
    {
 
7941
    case 0:
 
7942
      {
 
7943
        return new vectorlaplacegradcurl_dof_map_4();
 
7944
        break;
 
7945
      }
 
7946
    case 1:
 
7947
      {
 
7948
        return new vectorlaplacegradcurl_dof_map_1();
 
7949
        break;
 
7950
      }
 
7951
    }
 
7952
    
 
7953
    return 0;
 
7954
  }
 
7955
 
 
7956
  /// Create a new cell integral on sub domain i
 
7957
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
7958
  {
 
7959
    switch (i)
 
7960
    {
 
7961
    case 0:
 
7962
      {
 
7963
        return new vectorlaplacegradcurl_cell_integral_1_0();
 
7964
        break;
 
7965
      }
 
7966
    }
 
7967
    
 
7968
    return 0;
 
7969
  }
 
7970
 
 
7971
  /// Create a new exterior facet integral on sub domain i
 
7972
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
7973
  {
 
7974
    return 0;
 
7975
  }
 
7976
 
 
7977
  /// Create a new interior facet integral on sub domain i
 
7978
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
7979
  {
 
7980
    return 0;
 
7981
  }
 
7982
 
 
7983
};
 
7984
 
 
7985
#endif