~ubuntu-branches/ubuntu/maverick/dolfin/maverick

« back to all changes in this revision

Viewing changes to test/unit/function/cpp/Projection.h

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2009-10-12 14:13:18 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091012141318-hkbxl0sq555vqv7d
Tags: 0.9.4-1
* New upstream release. This version cleans up the design of the
  function class by adding a new abstraction for user-defined
  functions called Expression. A number of minor bugfixes and
  improvements have also been made.
* debian/watch: Update for new flat directory structure.
* Update debian/copyright.
* debian/rules: Use explicit paths to PETSc 3.0.0 and SLEPc 3.0.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// This code conforms with the UFC specification version 1.0
2
 
// and was automatically generated by FFC version 0.6.0.
 
2
// and was automatically generated by FFC version 0.7.0.
3
3
//
4
4
// Warning: This code was generated with the option '-l dolfin'
5
5
// and contains DOLFIN-specific wrappers that depend on DOLFIN.
11
11
#include <stdexcept>
12
12
#include <fstream>
13
13
#include <ufc.h>
14
 
 
15
 
/// This class defines the interface for a finite element.
16
 
 
17
 
class UFC_ProjectionBilinearForm_finite_element_0: public ufc::finite_element
18
 
{
19
 
public:
20
 
 
21
 
  /// Constructor
22
 
  UFC_ProjectionBilinearForm_finite_element_0() : ufc::finite_element()
23
 
  {
24
 
    // Do nothing
25
 
  }
26
 
 
27
 
  /// Destructor
28
 
  virtual ~UFC_ProjectionBilinearForm_finite_element_0()
29
 
  {
30
 
    // Do nothing
31
 
  }
32
 
 
33
 
  /// Return a string identifying the finite element
34
 
  virtual const char* signature() const
35
 
  {
36
 
    return "FiniteElement('Lagrange', 'tetrahedron', 2)";
37
 
  }
38
 
 
39
 
  /// Return the cell shape
40
 
  virtual ufc::shape cell_shape() const
41
 
  {
42
 
    return ufc::tetrahedron;
43
 
  }
44
 
 
45
 
  /// Return the dimension of the finite element function space
46
 
  virtual unsigned int space_dimension() const
47
 
  {
48
 
    return 10;
49
 
  }
50
 
 
51
 
  /// Return the rank of the value space
52
 
  virtual unsigned int value_rank() const
53
 
  {
54
 
    return 0;
55
 
  }
56
 
 
57
 
  /// Return the dimension of the value space for axis i
58
 
  virtual unsigned int value_dimension(unsigned int i) const
59
 
  {
60
 
    return 1;
61
 
  }
62
 
 
63
 
  /// Evaluate basis function i at given point in cell
64
 
  virtual void evaluate_basis(unsigned int i,
65
 
                              double* values,
66
 
                              const double* coordinates,
67
 
                              const ufc::cell& c) const
68
 
  {
69
 
    // Extract vertex coordinates
70
 
    const double * const * element_coordinates = c.coordinates;
71
 
    
72
 
    // Compute Jacobian of affine map from reference cell
73
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
74
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
75
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
76
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
77
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
78
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
79
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
80
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
81
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
82
 
      
83
 
    // Compute sub determinants
84
 
    const double d00 = J_11*J_22 - J_12*J_21;
85
 
    const double d01 = J_12*J_20 - J_10*J_22;
86
 
    const double d02 = J_10*J_21 - J_11*J_20;
87
 
    
88
 
    const double d10 = J_02*J_21 - J_01*J_22;
89
 
    const double d11 = J_00*J_22 - J_02*J_20;
90
 
    const double d12 = J_01*J_20 - J_00*J_21;
91
 
    
92
 
    const double d20 = J_01*J_12 - J_02*J_11;
93
 
    const double d21 = J_02*J_10 - J_00*J_12;
94
 
    const double d22 = J_00*J_11 - J_01*J_10;
95
 
      
96
 
    // Compute determinant of Jacobian
97
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
98
 
    
99
 
    // Compute inverse of Jacobian
100
 
    
101
 
    // Compute constants
102
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
103
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
104
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
105
 
    
106
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
107
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
108
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
109
 
    
110
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
111
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
112
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
113
 
    
114
 
    // Get coordinates and map to the UFC reference element
115
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
116
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
117
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
118
 
    
119
 
    // Map coordinates to the reference cube
120
 
    if (std::abs(y + z - 1.0) < 1e-14)
121
 
      x = 1.0;
122
 
    else
123
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
124
 
    if (std::abs(z - 1.0) < 1e-14)
125
 
      y = -1.0;
126
 
    else
127
 
      y = 2.0 * y/(1.0 - z) - 1.0;
128
 
    z = 2.0 * z - 1.0;
129
 
    
130
 
    // Reset values
131
 
    *values = 0;
132
 
    
133
 
    // Map degree of freedom to element degree of freedom
134
 
    const unsigned int dof = i;
135
 
    
136
 
    // Generate scalings
137
 
    const double scalings_y_0 = 1;
138
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
139
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
140
 
    const double scalings_z_0 = 1;
141
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
142
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
143
 
    
144
 
    // Compute psitilde_a
145
 
    const double psitilde_a_0 = 1;
146
 
    const double psitilde_a_1 = x;
147
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
148
 
    
149
 
    // Compute psitilde_bs
150
 
    const double psitilde_bs_0_0 = 1;
151
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
152
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
153
 
    const double psitilde_bs_1_0 = 1;
154
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
155
 
    const double psitilde_bs_2_0 = 1;
156
 
    
157
 
    // Compute psitilde_cs
158
 
    const double psitilde_cs_00_0 = 1;
159
 
    const double psitilde_cs_00_1 = 2*z + 1;
160
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
161
 
    const double psitilde_cs_01_0 = 1;
162
 
    const double psitilde_cs_01_1 = 3*z + 2;
163
 
    const double psitilde_cs_02_0 = 1;
164
 
    const double psitilde_cs_10_0 = 1;
165
 
    const double psitilde_cs_10_1 = 3*z + 2;
166
 
    const double psitilde_cs_11_0 = 1;
167
 
    const double psitilde_cs_20_0 = 1;
168
 
    
169
 
    // Compute basisvalues
170
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
171
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
172
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
173
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
174
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
175
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
176
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
177
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
178
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
179
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
180
 
    
181
 
    // Table(s) of coefficients
182
 
    const static double coefficients0[10][10] = \
183
 
    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
184
 
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
185
 
    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},
186
 
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
187
 
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
188
 
    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
189
 
    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
190
 
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
191
 
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
192
 
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
193
 
    
194
 
    // Extract relevant coefficients
195
 
    const double coeff0_0 = coefficients0[dof][0];
196
 
    const double coeff0_1 = coefficients0[dof][1];
197
 
    const double coeff0_2 = coefficients0[dof][2];
198
 
    const double coeff0_3 = coefficients0[dof][3];
199
 
    const double coeff0_4 = coefficients0[dof][4];
200
 
    const double coeff0_5 = coefficients0[dof][5];
201
 
    const double coeff0_6 = coefficients0[dof][6];
202
 
    const double coeff0_7 = coefficients0[dof][7];
203
 
    const double coeff0_8 = coefficients0[dof][8];
204
 
    const double coeff0_9 = coefficients0[dof][9];
205
 
    
206
 
    // Compute value(s)
207
 
    *values = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9;
208
 
  }
209
 
 
210
 
  /// Evaluate all basis functions at given point in cell
211
 
  virtual void evaluate_basis_all(double* values,
212
 
                                  const double* coordinates,
213
 
                                  const ufc::cell& c) const
214
 
  {
215
 
    throw std::runtime_error("The vectorised version of evaluate_basis() is not yet implemented.");
216
 
  }
217
 
 
218
 
  /// Evaluate order n derivatives of basis function i at given point in cell
219
 
  virtual void evaluate_basis_derivatives(unsigned int i,
220
 
                                          unsigned int n,
221
 
                                          double* values,
222
 
                                          const double* coordinates,
223
 
                                          const ufc::cell& c) const
224
 
  {
225
 
    // Extract vertex coordinates
226
 
    const double * const * element_coordinates = c.coordinates;
227
 
    
228
 
    // Compute Jacobian of affine map from reference cell
229
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
230
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
231
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
232
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
233
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
234
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
235
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
236
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
237
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
238
 
      
239
 
    // Compute sub determinants
240
 
    const double d00 = J_11*J_22 - J_12*J_21;
241
 
    const double d01 = J_12*J_20 - J_10*J_22;
242
 
    const double d02 = J_10*J_21 - J_11*J_20;
243
 
    
244
 
    const double d10 = J_02*J_21 - J_01*J_22;
245
 
    const double d11 = J_00*J_22 - J_02*J_20;
246
 
    const double d12 = J_01*J_20 - J_00*J_21;
247
 
    
248
 
    const double d20 = J_01*J_12 - J_02*J_11;
249
 
    const double d21 = J_02*J_10 - J_00*J_12;
250
 
    const double d22 = J_00*J_11 - J_01*J_10;
251
 
      
252
 
    // Compute determinant of Jacobian
253
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
254
 
    
255
 
    // Compute inverse of Jacobian
256
 
    
257
 
    // Compute constants
258
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
259
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
260
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
261
 
    
262
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
263
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
264
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
265
 
    
266
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
267
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
268
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
269
 
    
270
 
    // Get coordinates and map to the UFC reference element
271
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
272
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
273
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
274
 
    
275
 
    // Map coordinates to the reference cube
276
 
    if (std::abs(y + z - 1.0) < 1e-14)
277
 
      x = 1.0;
278
 
    else
279
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
280
 
    if (std::abs(z - 1.0) < 1e-14)
281
 
      y = -1.0;
282
 
    else
283
 
      y = 2.0 * y/(1.0 - z) - 1.0;
284
 
    z = 2.0 * z - 1.0;
285
 
    
286
 
    // Compute number of derivatives
287
 
    unsigned int num_derivatives = 1;
288
 
    
289
 
    for (unsigned int j = 0; j < n; j++)
290
 
      num_derivatives *= 3;
291
 
    
292
 
    
293
 
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
294
 
    unsigned int **combinations = new unsigned int *[num_derivatives];
295
 
        
296
 
    for (unsigned int j = 0; j < num_derivatives; j++)
297
 
    {
298
 
      combinations[j] = new unsigned int [n];
299
 
      for (unsigned int k = 0; k < n; k++)
300
 
        combinations[j][k] = 0;
301
 
    }
302
 
        
303
 
    // Generate combinations of derivatives
304
 
    for (unsigned int row = 1; row < num_derivatives; row++)
305
 
    {
306
 
      for (unsigned int num = 0; num < row; num++)
307
 
      {
308
 
        for (unsigned int col = n-1; col+1 > 0; col--)
309
 
        {
310
 
          if (combinations[row][col] + 1 > 2)
311
 
            combinations[row][col] = 0;
312
 
          else
313
 
          {
314
 
            combinations[row][col] += 1;
315
 
            break;
316
 
          }
317
 
        }
318
 
      }
319
 
    }
320
 
    
321
 
    // Compute inverse of Jacobian
322
 
    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};
323
 
    
324
 
    // Declare transformation matrix
325
 
    // Declare pointer to two dimensional array and initialise
326
 
    double **transform = new double *[num_derivatives];
327
 
        
328
 
    for (unsigned int j = 0; j < num_derivatives; j++)
329
 
    {
330
 
      transform[j] = new double [num_derivatives];
331
 
      for (unsigned int k = 0; k < num_derivatives; k++)
332
 
        transform[j][k] = 1;
333
 
    }
334
 
    
335
 
    // Construct transformation matrix
336
 
    for (unsigned int row = 0; row < num_derivatives; row++)
337
 
    {
338
 
      for (unsigned int col = 0; col < num_derivatives; col++)
339
 
      {
340
 
        for (unsigned int k = 0; k < n; k++)
341
 
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
342
 
      }
343
 
    }
344
 
    
345
 
    // Reset values
346
 
    for (unsigned int j = 0; j < 1*num_derivatives; j++)
347
 
      values[j] = 0;
348
 
    
349
 
    // Map degree of freedom to element degree of freedom
350
 
    const unsigned int dof = i;
351
 
    
352
 
    // Generate scalings
353
 
    const double scalings_y_0 = 1;
354
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
355
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
356
 
    const double scalings_z_0 = 1;
357
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
358
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
359
 
    
360
 
    // Compute psitilde_a
361
 
    const double psitilde_a_0 = 1;
362
 
    const double psitilde_a_1 = x;
363
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
364
 
    
365
 
    // Compute psitilde_bs
366
 
    const double psitilde_bs_0_0 = 1;
367
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
368
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
369
 
    const double psitilde_bs_1_0 = 1;
370
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
371
 
    const double psitilde_bs_2_0 = 1;
372
 
    
373
 
    // Compute psitilde_cs
374
 
    const double psitilde_cs_00_0 = 1;
375
 
    const double psitilde_cs_00_1 = 2*z + 1;
376
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
377
 
    const double psitilde_cs_01_0 = 1;
378
 
    const double psitilde_cs_01_1 = 3*z + 2;
379
 
    const double psitilde_cs_02_0 = 1;
380
 
    const double psitilde_cs_10_0 = 1;
381
 
    const double psitilde_cs_10_1 = 3*z + 2;
382
 
    const double psitilde_cs_11_0 = 1;
383
 
    const double psitilde_cs_20_0 = 1;
384
 
    
385
 
    // Compute basisvalues
386
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
387
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
388
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
389
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
390
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
391
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
392
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
393
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
394
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
395
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
396
 
    
397
 
    // Table(s) of coefficients
398
 
    const static double coefficients0[10][10] = \
399
 
    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
400
 
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
401
 
    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},
402
 
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
403
 
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
404
 
    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
405
 
    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
406
 
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
407
 
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
408
 
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
409
 
    
410
 
    // Interesting (new) part
411
 
    // Tables of derivatives of the polynomial base (transpose)
412
 
    const static double dmats0[10][10] = \
413
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
414
 
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0},
415
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
416
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
417
 
    {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0},
418
 
    {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0},
419
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
420
 
    {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0},
421
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
422
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
423
 
    
424
 
    const static double dmats1[10][10] = \
425
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
426
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
427
 
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0},
428
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
429
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825974, 0, 0, 0, 0, 0, 0},
430
 
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
431
 
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063974, 0, 0, 0, 0, 0, 0},
432
 
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
433
 
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0},
434
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
435
 
    
436
 
    const static double dmats2[10][10] = \
437
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
438
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
439
 
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0},
440
 
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0},
441
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
442
 
    {2.29128784747792, 1.44913767461894, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
443
 
    {1.32287565553229, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},
444
 
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
445
 
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960223, 0, 0, 0, 0, 0, 0},
446
 
    {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};
447
 
    
448
 
    // Compute reference derivatives
449
 
    // Declare pointer to array of derivatives on FIAT element
450
 
    double *derivatives = new double [num_derivatives];
451
 
    
452
 
    // Declare coefficients
453
 
    double coeff0_0 = 0;
454
 
    double coeff0_1 = 0;
455
 
    double coeff0_2 = 0;
456
 
    double coeff0_3 = 0;
457
 
    double coeff0_4 = 0;
458
 
    double coeff0_5 = 0;
459
 
    double coeff0_6 = 0;
460
 
    double coeff0_7 = 0;
461
 
    double coeff0_8 = 0;
462
 
    double coeff0_9 = 0;
463
 
    
464
 
    // Declare new coefficients
465
 
    double new_coeff0_0 = 0;
466
 
    double new_coeff0_1 = 0;
467
 
    double new_coeff0_2 = 0;
468
 
    double new_coeff0_3 = 0;
469
 
    double new_coeff0_4 = 0;
470
 
    double new_coeff0_5 = 0;
471
 
    double new_coeff0_6 = 0;
472
 
    double new_coeff0_7 = 0;
473
 
    double new_coeff0_8 = 0;
474
 
    double new_coeff0_9 = 0;
475
 
    
476
 
    // Loop possible derivatives
477
 
    for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
478
 
    {
479
 
      // Get values from coefficients array
480
 
      new_coeff0_0 = coefficients0[dof][0];
481
 
      new_coeff0_1 = coefficients0[dof][1];
482
 
      new_coeff0_2 = coefficients0[dof][2];
483
 
      new_coeff0_3 = coefficients0[dof][3];
484
 
      new_coeff0_4 = coefficients0[dof][4];
485
 
      new_coeff0_5 = coefficients0[dof][5];
486
 
      new_coeff0_6 = coefficients0[dof][6];
487
 
      new_coeff0_7 = coefficients0[dof][7];
488
 
      new_coeff0_8 = coefficients0[dof][8];
489
 
      new_coeff0_9 = coefficients0[dof][9];
490
 
    
491
 
      // Loop derivative order
492
 
      for (unsigned int j = 0; j < n; j++)
493
 
      {
494
 
        // Update old coefficients
495
 
        coeff0_0 = new_coeff0_0;
496
 
        coeff0_1 = new_coeff0_1;
497
 
        coeff0_2 = new_coeff0_2;
498
 
        coeff0_3 = new_coeff0_3;
499
 
        coeff0_4 = new_coeff0_4;
500
 
        coeff0_5 = new_coeff0_5;
501
 
        coeff0_6 = new_coeff0_6;
502
 
        coeff0_7 = new_coeff0_7;
503
 
        coeff0_8 = new_coeff0_8;
504
 
        coeff0_9 = new_coeff0_9;
505
 
    
506
 
        if(combinations[deriv_num][j] == 0)
507
 
        {
508
 
          new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0];
509
 
          new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1];
510
 
          new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2];
511
 
          new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3];
512
 
          new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4];
513
 
          new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5];
514
 
          new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6];
515
 
          new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7];
516
 
          new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8];
517
 
          new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9];
518
 
        }
519
 
        if(combinations[deriv_num][j] == 1)
520
 
        {
521
 
          new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0];
522
 
          new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1];
523
 
          new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2];
524
 
          new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3];
525
 
          new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4];
526
 
          new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5];
527
 
          new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6];
528
 
          new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7];
529
 
          new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8];
530
 
          new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9];
531
 
        }
532
 
        if(combinations[deriv_num][j] == 2)
533
 
        {
534
 
          new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0];
535
 
          new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1];
536
 
          new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2];
537
 
          new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3];
538
 
          new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4];
539
 
          new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5];
540
 
          new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6];
541
 
          new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7];
542
 
          new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8];
543
 
          new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9];
544
 
        }
545
 
    
546
 
      }
547
 
      // Compute derivatives on reference element as dot product of coefficients and basisvalues
548
 
      derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9;
549
 
    }
550
 
    
551
 
    // Transform derivatives back to physical element
552
 
    for (unsigned int row = 0; row < num_derivatives; row++)
553
 
    {
554
 
      for (unsigned int col = 0; col < num_derivatives; col++)
555
 
      {
556
 
        values[row] += transform[row][col]*derivatives[col];
557
 
      }
558
 
    }
559
 
    // Delete pointer to array of derivatives on FIAT element
560
 
    delete [] derivatives;
561
 
    
562
 
    // Delete pointer to array of combinations of derivatives and transform
563
 
    for (unsigned int row = 0; row < num_derivatives; row++)
564
 
    {
565
 
      delete [] combinations[row];
566
 
      delete [] transform[row];
567
 
    }
568
 
    
569
 
    delete [] combinations;
570
 
    delete [] transform;
571
 
  }
572
 
 
573
 
  /// Evaluate order n derivatives of all basis functions at given point in cell
574
 
  virtual void evaluate_basis_derivatives_all(unsigned int n,
575
 
                                              double* values,
576
 
                                              const double* coordinates,
577
 
                                              const ufc::cell& c) const
578
 
  {
579
 
    throw std::runtime_error("The vectorised version of evaluate_basis_derivatives() is not yet implemented.");
580
 
  }
581
 
 
582
 
  /// Evaluate linear functional for dof i on the function f
583
 
  virtual double evaluate_dof(unsigned int i,
584
 
                              const ufc::function& f,
585
 
                              const ufc::cell& c) const
586
 
  {
587
 
    // The reference points, direction and weights:
588
 
    const static double X[10][1][3] = {{{0, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0.5, 0.5}}, {{0.5, 0, 0.5}}, {{0.5, 0.5, 0}}, {{0, 0, 0.5}}, {{0, 0.5, 0}}, {{0.5, 0, 0}}};
589
 
    const static double W[10][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
590
 
    const static double D[10][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
591
 
    
592
 
    const double * const * x = c.coordinates;
593
 
    double result = 0.0;
594
 
    // Iterate over the points:
595
 
    // Evaluate basis functions for affine mapping
596
 
    const double w0 = 1.0 - X[i][0][0] - X[i][0][1] - X[i][0][2];
597
 
    const double w1 = X[i][0][0];
598
 
    const double w2 = X[i][0][1];
599
 
    const double w3 = X[i][0][2];
600
 
    
601
 
    // Compute affine mapping y = F(X)
602
 
    double y[3];
603
 
    y[0] = w0*x[0][0] + w1*x[1][0] + w2*x[2][0] + w3*x[3][0];
604
 
    y[1] = w0*x[0][1] + w1*x[1][1] + w2*x[2][1] + w3*x[3][1];
605
 
    y[2] = w0*x[0][2] + w1*x[1][2] + w2*x[2][2] + w3*x[3][2];
606
 
    
607
 
    // Evaluate function at physical points
608
 
    double values[1];
609
 
    f.evaluate(values, y, c);
610
 
    
611
 
    // Map function values using appropriate mapping
612
 
    // Affine map: Do nothing
613
 
    
614
 
    // Note that we do not map the weights (yet).
615
 
    
616
 
    // Take directional components
617
 
    for(int k = 0; k < 1; k++)
618
 
      result += values[k]*D[i][0][k];
619
 
    // Multiply by weights 
620
 
    result *= W[i][0];
621
 
    
622
 
    return result;
623
 
  }
624
 
 
625
 
  /// Evaluate linear functionals for all dofs on the function f
626
 
  virtual void evaluate_dofs(double* values,
627
 
                             const ufc::function& f,
628
 
                             const ufc::cell& c) const
629
 
  {
630
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
631
 
  }
632
 
 
633
 
  /// Interpolate vertex values from dof values
634
 
  virtual void interpolate_vertex_values(double* vertex_values,
635
 
                                         const double* dof_values,
636
 
                                         const ufc::cell& c) const
637
 
  {
638
 
    // Evaluate at vertices and use affine mapping
639
 
    vertex_values[0] = dof_values[0];
640
 
    vertex_values[1] = dof_values[1];
641
 
    vertex_values[2] = dof_values[2];
642
 
    vertex_values[3] = dof_values[3];
643
 
  }
644
 
 
645
 
  /// Return the number of sub elements (for a mixed element)
646
 
  virtual unsigned int num_sub_elements() const
647
 
  {
648
 
    return 1;
649
 
  }
650
 
 
651
 
  /// Create a new finite element for sub element i (for a mixed element)
652
 
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
653
 
  {
654
 
    return new UFC_ProjectionBilinearForm_finite_element_0();
655
 
  }
656
 
 
657
 
};
658
 
 
659
 
/// This class defines the interface for a finite element.
660
 
 
661
 
class UFC_ProjectionBilinearForm_finite_element_1: public ufc::finite_element
662
 
{
663
 
public:
664
 
 
665
 
  /// Constructor
666
 
  UFC_ProjectionBilinearForm_finite_element_1() : ufc::finite_element()
667
 
  {
668
 
    // Do nothing
669
 
  }
670
 
 
671
 
  /// Destructor
672
 
  virtual ~UFC_ProjectionBilinearForm_finite_element_1()
673
 
  {
674
 
    // Do nothing
675
 
  }
676
 
 
677
 
  /// Return a string identifying the finite element
678
 
  virtual const char* signature() const
679
 
  {
680
 
    return "FiniteElement('Lagrange', 'tetrahedron', 2)";
681
 
  }
682
 
 
683
 
  /// Return the cell shape
684
 
  virtual ufc::shape cell_shape() const
685
 
  {
686
 
    return ufc::tetrahedron;
687
 
  }
688
 
 
689
 
  /// Return the dimension of the finite element function space
690
 
  virtual unsigned int space_dimension() const
691
 
  {
692
 
    return 10;
693
 
  }
694
 
 
695
 
  /// Return the rank of the value space
696
 
  virtual unsigned int value_rank() const
697
 
  {
698
 
    return 0;
699
 
  }
700
 
 
701
 
  /// Return the dimension of the value space for axis i
702
 
  virtual unsigned int value_dimension(unsigned int i) const
703
 
  {
704
 
    return 1;
705
 
  }
706
 
 
707
 
  /// Evaluate basis function i at given point in cell
708
 
  virtual void evaluate_basis(unsigned int i,
709
 
                              double* values,
710
 
                              const double* coordinates,
711
 
                              const ufc::cell& c) const
712
 
  {
713
 
    // Extract vertex coordinates
714
 
    const double * const * element_coordinates = c.coordinates;
715
 
    
716
 
    // Compute Jacobian of affine map from reference cell
717
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
718
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
719
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
720
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
721
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
722
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
723
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
724
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
725
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
726
 
      
727
 
    // Compute sub determinants
728
 
    const double d00 = J_11*J_22 - J_12*J_21;
729
 
    const double d01 = J_12*J_20 - J_10*J_22;
730
 
    const double d02 = J_10*J_21 - J_11*J_20;
731
 
    
732
 
    const double d10 = J_02*J_21 - J_01*J_22;
733
 
    const double d11 = J_00*J_22 - J_02*J_20;
734
 
    const double d12 = J_01*J_20 - J_00*J_21;
735
 
    
736
 
    const double d20 = J_01*J_12 - J_02*J_11;
737
 
    const double d21 = J_02*J_10 - J_00*J_12;
738
 
    const double d22 = J_00*J_11 - J_01*J_10;
739
 
      
740
 
    // Compute determinant of Jacobian
741
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
742
 
    
743
 
    // Compute inverse of Jacobian
744
 
    
745
 
    // Compute constants
746
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
747
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
748
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
749
 
    
750
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
751
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
752
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
753
 
    
754
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
755
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
756
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
757
 
    
758
 
    // Get coordinates and map to the UFC reference element
759
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
760
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
761
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
762
 
    
763
 
    // Map coordinates to the reference cube
764
 
    if (std::abs(y + z - 1.0) < 1e-14)
765
 
      x = 1.0;
766
 
    else
767
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
768
 
    if (std::abs(z - 1.0) < 1e-14)
769
 
      y = -1.0;
770
 
    else
771
 
      y = 2.0 * y/(1.0 - z) - 1.0;
772
 
    z = 2.0 * z - 1.0;
773
 
    
774
 
    // Reset values
775
 
    *values = 0;
776
 
    
777
 
    // Map degree of freedom to element degree of freedom
778
 
    const unsigned int dof = i;
779
 
    
780
 
    // Generate scalings
781
 
    const double scalings_y_0 = 1;
782
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
783
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
784
 
    const double scalings_z_0 = 1;
785
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
786
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
787
 
    
788
 
    // Compute psitilde_a
789
 
    const double psitilde_a_0 = 1;
790
 
    const double psitilde_a_1 = x;
791
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
792
 
    
793
 
    // Compute psitilde_bs
794
 
    const double psitilde_bs_0_0 = 1;
795
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
796
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
797
 
    const double psitilde_bs_1_0 = 1;
798
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
799
 
    const double psitilde_bs_2_0 = 1;
800
 
    
801
 
    // Compute psitilde_cs
802
 
    const double psitilde_cs_00_0 = 1;
803
 
    const double psitilde_cs_00_1 = 2*z + 1;
804
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
805
 
    const double psitilde_cs_01_0 = 1;
806
 
    const double psitilde_cs_01_1 = 3*z + 2;
807
 
    const double psitilde_cs_02_0 = 1;
808
 
    const double psitilde_cs_10_0 = 1;
809
 
    const double psitilde_cs_10_1 = 3*z + 2;
810
 
    const double psitilde_cs_11_0 = 1;
811
 
    const double psitilde_cs_20_0 = 1;
812
 
    
813
 
    // Compute basisvalues
814
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
815
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
816
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
817
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
818
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
819
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
820
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
821
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
822
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
823
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
824
 
    
825
 
    // Table(s) of coefficients
826
 
    const static double coefficients0[10][10] = \
827
 
    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
828
 
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
829
 
    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},
830
 
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
831
 
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
832
 
    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
833
 
    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
834
 
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
835
 
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
836
 
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
837
 
    
838
 
    // Extract relevant coefficients
839
 
    const double coeff0_0 = coefficients0[dof][0];
840
 
    const double coeff0_1 = coefficients0[dof][1];
841
 
    const double coeff0_2 = coefficients0[dof][2];
842
 
    const double coeff0_3 = coefficients0[dof][3];
843
 
    const double coeff0_4 = coefficients0[dof][4];
844
 
    const double coeff0_5 = coefficients0[dof][5];
845
 
    const double coeff0_6 = coefficients0[dof][6];
846
 
    const double coeff0_7 = coefficients0[dof][7];
847
 
    const double coeff0_8 = coefficients0[dof][8];
848
 
    const double coeff0_9 = coefficients0[dof][9];
849
 
    
850
 
    // Compute value(s)
851
 
    *values = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9;
852
 
  }
853
 
 
854
 
  /// Evaluate all basis functions at given point in cell
855
 
  virtual void evaluate_basis_all(double* values,
856
 
                                  const double* coordinates,
857
 
                                  const ufc::cell& c) const
858
 
  {
859
 
    throw std::runtime_error("The vectorised version of evaluate_basis() is not yet implemented.");
860
 
  }
861
 
 
862
 
  /// Evaluate order n derivatives of basis function i at given point in cell
863
 
  virtual void evaluate_basis_derivatives(unsigned int i,
864
 
                                          unsigned int n,
865
 
                                          double* values,
866
 
                                          const double* coordinates,
867
 
                                          const ufc::cell& c) const
868
 
  {
869
 
    // Extract vertex coordinates
870
 
    const double * const * element_coordinates = c.coordinates;
871
 
    
872
 
    // Compute Jacobian of affine map from reference cell
873
 
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
874
 
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
875
 
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
876
 
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
877
 
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
878
 
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
879
 
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
880
 
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
881
 
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
882
 
      
883
 
    // Compute sub determinants
884
 
    const double d00 = J_11*J_22 - J_12*J_21;
885
 
    const double d01 = J_12*J_20 - J_10*J_22;
886
 
    const double d02 = J_10*J_21 - J_11*J_20;
887
 
    
888
 
    const double d10 = J_02*J_21 - J_01*J_22;
889
 
    const double d11 = J_00*J_22 - J_02*J_20;
890
 
    const double d12 = J_01*J_20 - J_00*J_21;
891
 
    
892
 
    const double d20 = J_01*J_12 - J_02*J_11;
893
 
    const double d21 = J_02*J_10 - J_00*J_12;
894
 
    const double d22 = J_00*J_11 - J_01*J_10;
895
 
      
896
 
    // Compute determinant of Jacobian
897
 
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
898
 
    
899
 
    // Compute inverse of Jacobian
900
 
    
901
 
    // Compute constants
902
 
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
903
 
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
904
 
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
905
 
    
906
 
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
907
 
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
908
 
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
909
 
    
910
 
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
911
 
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
912
 
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
913
 
    
914
 
    // Get coordinates and map to the UFC reference element
915
 
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
916
 
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
917
 
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
918
 
    
919
 
    // Map coordinates to the reference cube
920
 
    if (std::abs(y + z - 1.0) < 1e-14)
921
 
      x = 1.0;
922
 
    else
923
 
      x = -2.0 * x/(y + z - 1.0) - 1.0;
924
 
    if (std::abs(z - 1.0) < 1e-14)
925
 
      y = -1.0;
926
 
    else
927
 
      y = 2.0 * y/(1.0 - z) - 1.0;
928
 
    z = 2.0 * z - 1.0;
929
 
    
930
 
    // Compute number of derivatives
931
 
    unsigned int num_derivatives = 1;
932
 
    
933
 
    for (unsigned int j = 0; j < n; j++)
934
 
      num_derivatives *= 3;
935
 
    
936
 
    
937
 
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
938
 
    unsigned int **combinations = new unsigned int *[num_derivatives];
939
 
        
940
 
    for (unsigned int j = 0; j < num_derivatives; j++)
941
 
    {
942
 
      combinations[j] = new unsigned int [n];
943
 
      for (unsigned int k = 0; k < n; k++)
944
 
        combinations[j][k] = 0;
945
 
    }
946
 
        
947
 
    // Generate combinations of derivatives
948
 
    for (unsigned int row = 1; row < num_derivatives; row++)
949
 
    {
950
 
      for (unsigned int num = 0; num < row; num++)
951
 
      {
952
 
        for (unsigned int col = n-1; col+1 > 0; col--)
953
 
        {
954
 
          if (combinations[row][col] + 1 > 2)
955
 
            combinations[row][col] = 0;
956
 
          else
957
 
          {
958
 
            combinations[row][col] += 1;
959
 
            break;
960
 
          }
961
 
        }
962
 
      }
963
 
    }
964
 
    
965
 
    // Compute inverse of Jacobian
966
 
    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};
967
 
    
968
 
    // Declare transformation matrix
969
 
    // Declare pointer to two dimensional array and initialise
970
 
    double **transform = new double *[num_derivatives];
971
 
        
972
 
    for (unsigned int j = 0; j < num_derivatives; j++)
973
 
    {
974
 
      transform[j] = new double [num_derivatives];
975
 
      for (unsigned int k = 0; k < num_derivatives; k++)
976
 
        transform[j][k] = 1;
977
 
    }
978
 
    
979
 
    // Construct transformation matrix
980
 
    for (unsigned int row = 0; row < num_derivatives; row++)
981
 
    {
982
 
      for (unsigned int col = 0; col < num_derivatives; col++)
983
 
      {
984
 
        for (unsigned int k = 0; k < n; k++)
985
 
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
986
 
      }
987
 
    }
988
 
    
989
 
    // Reset values
990
 
    for (unsigned int j = 0; j < 1*num_derivatives; j++)
991
 
      values[j] = 0;
992
 
    
993
 
    // Map degree of freedom to element degree of freedom
994
 
    const unsigned int dof = i;
995
 
    
996
 
    // Generate scalings
997
 
    const double scalings_y_0 = 1;
998
 
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
999
 
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
1000
 
    const double scalings_z_0 = 1;
1001
 
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
1002
 
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
1003
 
    
1004
 
    // Compute psitilde_a
1005
 
    const double psitilde_a_0 = 1;
1006
 
    const double psitilde_a_1 = x;
1007
 
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
1008
 
    
1009
 
    // Compute psitilde_bs
1010
 
    const double psitilde_bs_0_0 = 1;
1011
 
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
1012
 
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
1013
 
    const double psitilde_bs_1_0 = 1;
1014
 
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
1015
 
    const double psitilde_bs_2_0 = 1;
1016
 
    
1017
 
    // Compute psitilde_cs
1018
 
    const double psitilde_cs_00_0 = 1;
1019
 
    const double psitilde_cs_00_1 = 2*z + 1;
1020
 
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
1021
 
    const double psitilde_cs_01_0 = 1;
1022
 
    const double psitilde_cs_01_1 = 3*z + 2;
1023
 
    const double psitilde_cs_02_0 = 1;
1024
 
    const double psitilde_cs_10_0 = 1;
1025
 
    const double psitilde_cs_10_1 = 3*z + 2;
1026
 
    const double psitilde_cs_11_0 = 1;
1027
 
    const double psitilde_cs_20_0 = 1;
1028
 
    
1029
 
    // Compute basisvalues
1030
 
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
1031
 
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
1032
 
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
1033
 
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
1034
 
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
1035
 
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
1036
 
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
1037
 
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
1038
 
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
1039
 
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
1040
 
    
1041
 
    // Table(s) of coefficients
1042
 
    const static double coefficients0[10][10] = \
1043
 
    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
1044
 
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
1045
 
    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},
1046
 
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
1047
 
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
1048
 
    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
1049
 
    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
1050
 
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
1051
 
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
1052
 
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
1053
 
    
1054
 
    // Interesting (new) part
1055
 
    // Tables of derivatives of the polynomial base (transpose)
1056
 
    const static double dmats0[10][10] = \
1057
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1058
 
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1059
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1060
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1061
 
    {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0},
1062
 
    {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0},
1063
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1064
 
    {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0},
1065
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1066
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
1067
 
    
1068
 
    const static double dmats1[10][10] = \
1069
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1070
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1071
 
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1072
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1073
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825974, 0, 0, 0, 0, 0, 0},
1074
 
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
1075
 
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063974, 0, 0, 0, 0, 0, 0},
1076
 
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
1077
 
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0},
1078
 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
1079
 
    
1080
 
    const static double dmats2[10][10] = \
1081
 
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1082
 
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1083
 
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1084
 
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1085
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
1086
 
    {2.29128784747792, 1.44913767461894, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
1087
 
    {1.32287565553229, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},
1088
 
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
1089
 
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960223, 0, 0, 0, 0, 0, 0},
1090
 
    {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};
1091
 
    
1092
 
    // Compute reference derivatives
1093
 
    // Declare pointer to array of derivatives on FIAT element
1094
 
    double *derivatives = new double [num_derivatives];
1095
 
    
1096
 
    // Declare coefficients
1097
 
    double coeff0_0 = 0;
1098
 
    double coeff0_1 = 0;
1099
 
    double coeff0_2 = 0;
1100
 
    double coeff0_3 = 0;
1101
 
    double coeff0_4 = 0;
1102
 
    double coeff0_5 = 0;
1103
 
    double coeff0_6 = 0;
1104
 
    double coeff0_7 = 0;
1105
 
    double coeff0_8 = 0;
1106
 
    double coeff0_9 = 0;
1107
 
    
1108
 
    // Declare new coefficients
1109
 
    double new_coeff0_0 = 0;
1110
 
    double new_coeff0_1 = 0;
1111
 
    double new_coeff0_2 = 0;
1112
 
    double new_coeff0_3 = 0;
1113
 
    double new_coeff0_4 = 0;
1114
 
    double new_coeff0_5 = 0;
1115
 
    double new_coeff0_6 = 0;
1116
 
    double new_coeff0_7 = 0;
1117
 
    double new_coeff0_8 = 0;
1118
 
    double new_coeff0_9 = 0;
1119
 
    
1120
 
    // Loop possible derivatives
1121
 
    for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
1122
 
    {
1123
 
      // Get values from coefficients array
1124
 
      new_coeff0_0 = coefficients0[dof][0];
1125
 
      new_coeff0_1 = coefficients0[dof][1];
1126
 
      new_coeff0_2 = coefficients0[dof][2];
1127
 
      new_coeff0_3 = coefficients0[dof][3];
1128
 
      new_coeff0_4 = coefficients0[dof][4];
1129
 
      new_coeff0_5 = coefficients0[dof][5];
1130
 
      new_coeff0_6 = coefficients0[dof][6];
1131
 
      new_coeff0_7 = coefficients0[dof][7];
1132
 
      new_coeff0_8 = coefficients0[dof][8];
1133
 
      new_coeff0_9 = coefficients0[dof][9];
1134
 
    
1135
 
      // Loop derivative order
1136
 
      for (unsigned int j = 0; j < n; j++)
1137
 
      {
1138
 
        // Update old coefficients
1139
 
        coeff0_0 = new_coeff0_0;
1140
 
        coeff0_1 = new_coeff0_1;
1141
 
        coeff0_2 = new_coeff0_2;
1142
 
        coeff0_3 = new_coeff0_3;
1143
 
        coeff0_4 = new_coeff0_4;
1144
 
        coeff0_5 = new_coeff0_5;
1145
 
        coeff0_6 = new_coeff0_6;
1146
 
        coeff0_7 = new_coeff0_7;
1147
 
        coeff0_8 = new_coeff0_8;
1148
 
        coeff0_9 = new_coeff0_9;
1149
 
    
1150
 
        if(combinations[deriv_num][j] == 0)
1151
 
        {
1152
 
          new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0];
1153
 
          new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1];
1154
 
          new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2];
1155
 
          new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3];
1156
 
          new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4];
1157
 
          new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5];
1158
 
          new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6];
1159
 
          new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7];
1160
 
          new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8];
1161
 
          new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9];
1162
 
        }
1163
 
        if(combinations[deriv_num][j] == 1)
1164
 
        {
1165
 
          new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0];
1166
 
          new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1];
1167
 
          new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2];
1168
 
          new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3];
1169
 
          new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4];
1170
 
          new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5];
1171
 
          new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6];
1172
 
          new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7];
1173
 
          new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8];
1174
 
          new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9];
1175
 
        }
1176
 
        if(combinations[deriv_num][j] == 2)
1177
 
        {
1178
 
          new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0];
1179
 
          new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1];
1180
 
          new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2];
1181
 
          new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3];
1182
 
          new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4];
1183
 
          new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5];
1184
 
          new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6];
1185
 
          new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7];
1186
 
          new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8];
1187
 
          new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9];
1188
 
        }
1189
 
    
1190
 
      }
1191
 
      // Compute derivatives on reference element as dot product of coefficients and basisvalues
1192
 
      derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9;
1193
 
    }
1194
 
    
1195
 
    // Transform derivatives back to physical element
1196
 
    for (unsigned int row = 0; row < num_derivatives; row++)
1197
 
    {
1198
 
      for (unsigned int col = 0; col < num_derivatives; col++)
1199
 
      {
1200
 
        values[row] += transform[row][col]*derivatives[col];
1201
 
      }
1202
 
    }
1203
 
    // Delete pointer to array of derivatives on FIAT element
1204
 
    delete [] derivatives;
1205
 
    
1206
 
    // Delete pointer to array of combinations of derivatives and transform
1207
 
    for (unsigned int row = 0; row < num_derivatives; row++)
1208
 
    {
1209
 
      delete [] combinations[row];
1210
 
      delete [] transform[row];
1211
 
    }
1212
 
    
1213
 
    delete [] combinations;
1214
 
    delete [] transform;
1215
 
  }
1216
 
 
1217
 
  /// Evaluate order n derivatives of all basis functions at given point in cell
1218
 
  virtual void evaluate_basis_derivatives_all(unsigned int n,
1219
 
                                              double* values,
1220
 
                                              const double* coordinates,
1221
 
                                              const ufc::cell& c) const
1222
 
  {
1223
 
    throw std::runtime_error("The vectorised version of evaluate_basis_derivatives() is not yet implemented.");
1224
 
  }
1225
 
 
1226
 
  /// Evaluate linear functional for dof i on the function f
1227
 
  virtual double evaluate_dof(unsigned int i,
1228
 
                              const ufc::function& f,
1229
 
                              const ufc::cell& c) const
1230
 
  {
1231
 
    // The reference points, direction and weights:
1232
 
    const static double X[10][1][3] = {{{0, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0.5, 0.5}}, {{0.5, 0, 0.5}}, {{0.5, 0.5, 0}}, {{0, 0, 0.5}}, {{0, 0.5, 0}}, {{0.5, 0, 0}}};
1233
 
    const static double W[10][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
1234
 
    const static double D[10][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
1235
 
    
1236
 
    const double * const * x = c.coordinates;
1237
 
    double result = 0.0;
1238
 
    // Iterate over the points:
1239
 
    // Evaluate basis functions for affine mapping
1240
 
    const double w0 = 1.0 - X[i][0][0] - X[i][0][1] - X[i][0][2];
1241
 
    const double w1 = X[i][0][0];
1242
 
    const double w2 = X[i][0][1];
1243
 
    const double w3 = X[i][0][2];
1244
 
    
1245
 
    // Compute affine mapping y = F(X)
1246
 
    double y[3];
1247
 
    y[0] = w0*x[0][0] + w1*x[1][0] + w2*x[2][0] + w3*x[3][0];
1248
 
    y[1] = w0*x[0][1] + w1*x[1][1] + w2*x[2][1] + w3*x[3][1];
1249
 
    y[2] = w0*x[0][2] + w1*x[1][2] + w2*x[2][2] + w3*x[3][2];
1250
 
    
1251
 
    // Evaluate function at physical points
1252
 
    double values[1];
1253
 
    f.evaluate(values, y, c);
1254
 
    
1255
 
    // Map function values using appropriate mapping
1256
 
    // Affine map: Do nothing
1257
 
    
1258
 
    // Note that we do not map the weights (yet).
1259
 
    
1260
 
    // Take directional components
1261
 
    for(int k = 0; k < 1; k++)
1262
 
      result += values[k]*D[i][0][k];
1263
 
    // Multiply by weights 
1264
 
    result *= W[i][0];
1265
 
    
1266
 
    return result;
1267
 
  }
1268
 
 
1269
 
  /// Evaluate linear functionals for all dofs on the function f
1270
 
  virtual void evaluate_dofs(double* values,
1271
 
                             const ufc::function& f,
1272
 
                             const ufc::cell& c) const
1273
 
  {
1274
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
1275
 
  }
1276
 
 
1277
 
  /// Interpolate vertex values from dof values
1278
 
  virtual void interpolate_vertex_values(double* vertex_values,
1279
 
                                         const double* dof_values,
1280
 
                                         const ufc::cell& c) const
1281
 
  {
1282
 
    // Evaluate at vertices and use affine mapping
1283
 
    vertex_values[0] = dof_values[0];
1284
 
    vertex_values[1] = dof_values[1];
1285
 
    vertex_values[2] = dof_values[2];
1286
 
    vertex_values[3] = dof_values[3];
1287
 
  }
1288
 
 
1289
 
  /// Return the number of sub elements (for a mixed element)
1290
 
  virtual unsigned int num_sub_elements() const
1291
 
  {
1292
 
    return 1;
1293
 
  }
1294
 
 
1295
 
  /// Create a new finite element for sub element i (for a mixed element)
1296
 
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
1297
 
  {
1298
 
    return new UFC_ProjectionBilinearForm_finite_element_1();
1299
 
  }
1300
 
 
1301
 
};
1302
 
 
1303
 
/// This class defines the interface for a local-to-global mapping of
1304
 
/// degrees of freedom (dofs).
1305
 
 
1306
 
class UFC_ProjectionBilinearForm_dof_map_0: public ufc::dof_map
1307
 
{
1308
 
private:
1309
 
 
1310
 
  unsigned int __global_dimension;
1311
 
 
1312
 
public:
1313
 
 
1314
 
  /// Constructor
1315
 
  UFC_ProjectionBilinearForm_dof_map_0() : ufc::dof_map()
1316
 
  {
1317
 
    __global_dimension = 0;
1318
 
  }
1319
 
 
1320
 
  /// Destructor
1321
 
  virtual ~UFC_ProjectionBilinearForm_dof_map_0()
1322
 
  {
1323
 
    // Do nothing
1324
 
  }
1325
 
 
1326
 
  /// Return a string identifying the dof map
1327
 
  virtual const char* signature() const
1328
 
  {
1329
 
    return "FFC dof map for FiniteElement('Lagrange', 'tetrahedron', 2)";
1330
 
  }
1331
 
 
1332
 
  /// Return true iff mesh entities of topological dimension d are needed
1333
 
  virtual bool needs_mesh_entities(unsigned int d) const
1334
 
  {
1335
 
    switch ( d )
1336
 
    {
1337
 
    case 0:
1338
 
      return true;
1339
 
      break;
1340
 
    case 1:
1341
 
      return true;
1342
 
      break;
1343
 
    case 2:
1344
 
      return false;
1345
 
      break;
1346
 
    case 3:
1347
 
      return false;
1348
 
      break;
1349
 
    }
1350
 
    return false;
1351
 
  }
1352
 
 
1353
 
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
1354
 
  virtual bool init_mesh(const ufc::mesh& m)
1355
 
  {
1356
 
    __global_dimension = m.num_entities[0] + m.num_entities[1];
1357
 
    return false;
1358
 
  }
1359
 
 
1360
 
  /// Initialize dof map for given cell
1361
 
  virtual void init_cell(const ufc::mesh& m,
1362
 
                         const ufc::cell& c)
1363
 
  {
1364
 
    // Do nothing
1365
 
  }
1366
 
 
1367
 
  /// Finish initialization of dof map for cells
1368
 
  virtual void init_cell_finalize()
1369
 
  {
1370
 
    // Do nothing
1371
 
  }
1372
 
 
1373
 
  /// Return the dimension of the global finite element function space
1374
 
  virtual unsigned int global_dimension() const
1375
 
  {
1376
 
    return __global_dimension;
1377
 
  }
1378
 
 
1379
 
  /// Return the dimension of the local finite element function space
1380
 
  virtual unsigned int local_dimension() const
1381
 
  {
1382
 
    return 10;
1383
 
  }
1384
 
 
1385
 
  // Return the geometric dimension of the coordinates this dof map provides
1386
 
  virtual unsigned int geometric_dimension() const
1387
 
  {
1388
 
    return 3;
1389
 
  }
1390
 
 
1391
 
  /// Return the number of dofs on each cell facet
1392
 
  virtual unsigned int num_facet_dofs() const
1393
 
  {
1394
 
    return 6;
1395
 
  }
1396
 
 
1397
 
  /// Return the number of dofs associated with each cell entity of dimension d
1398
 
  virtual unsigned int num_entity_dofs(unsigned int d) const
1399
 
  {
1400
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
1401
 
  }
1402
 
 
1403
 
  /// Tabulate the local-to-global mapping of dofs on a cell
1404
 
  virtual void tabulate_dofs(unsigned int* dofs,
1405
 
                             const ufc::mesh& m,
1406
 
                             const ufc::cell& c) const
1407
 
  {
1408
 
    dofs[0] = c.entity_indices[0][0];
1409
 
    dofs[1] = c.entity_indices[0][1];
1410
 
    dofs[2] = c.entity_indices[0][2];
1411
 
    dofs[3] = c.entity_indices[0][3];
1412
 
    unsigned int offset = m.num_entities[0];
1413
 
    dofs[4] = offset + c.entity_indices[1][0];
1414
 
    dofs[5] = offset + c.entity_indices[1][1];
1415
 
    dofs[6] = offset + c.entity_indices[1][2];
1416
 
    dofs[7] = offset + c.entity_indices[1][3];
1417
 
    dofs[8] = offset + c.entity_indices[1][4];
1418
 
    dofs[9] = offset + c.entity_indices[1][5];
1419
 
  }
1420
 
 
1421
 
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
1422
 
  virtual void tabulate_facet_dofs(unsigned int* dofs,
1423
 
                                   unsigned int facet) const
1424
 
  {
1425
 
    switch ( facet )
1426
 
    {
1427
 
    case 0:
1428
 
      dofs[0] = 1;
1429
 
      dofs[1] = 2;
1430
 
      dofs[2] = 3;
1431
 
      dofs[3] = 4;
1432
 
      dofs[4] = 5;
1433
 
      dofs[5] = 6;
1434
 
      break;
1435
 
    case 1:
1436
 
      dofs[0] = 0;
1437
 
      dofs[1] = 2;
1438
 
      dofs[2] = 3;
1439
 
      dofs[3] = 4;
1440
 
      dofs[4] = 7;
1441
 
      dofs[5] = 8;
1442
 
      break;
1443
 
    case 2:
1444
 
      dofs[0] = 0;
1445
 
      dofs[1] = 1;
1446
 
      dofs[2] = 3;
1447
 
      dofs[3] = 5;
1448
 
      dofs[4] = 7;
1449
 
      dofs[5] = 9;
1450
 
      break;
1451
 
    case 3:
1452
 
      dofs[0] = 0;
1453
 
      dofs[1] = 1;
1454
 
      dofs[2] = 2;
1455
 
      dofs[3] = 6;
1456
 
      dofs[4] = 8;
1457
 
      dofs[5] = 9;
1458
 
      break;
1459
 
    }
1460
 
  }
1461
 
 
1462
 
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
1463
 
  virtual void tabulate_entity_dofs(unsigned int* dofs,
1464
 
                                    unsigned int d, unsigned int i) const
1465
 
  {
1466
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
1467
 
  }
1468
 
 
1469
 
  /// Tabulate the coordinates of all dofs on a cell
1470
 
  virtual void tabulate_coordinates(double** coordinates,
1471
 
                                    const ufc::cell& c) const
1472
 
  {
1473
 
    const double * const * x = c.coordinates;
1474
 
    coordinates[0][0] = x[0][0];
1475
 
    coordinates[0][1] = x[0][1];
1476
 
    coordinates[0][2] = x[0][2];
1477
 
    coordinates[1][0] = x[1][0];
1478
 
    coordinates[1][1] = x[1][1];
1479
 
    coordinates[1][2] = x[1][2];
1480
 
    coordinates[2][0] = x[2][0];
1481
 
    coordinates[2][1] = x[2][1];
1482
 
    coordinates[2][2] = x[2][2];
1483
 
    coordinates[3][0] = x[3][0];
1484
 
    coordinates[3][1] = x[3][1];
1485
 
    coordinates[3][2] = x[3][2];
1486
 
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
1487
 
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
1488
 
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
1489
 
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
1490
 
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
1491
 
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
1492
 
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
1493
 
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
1494
 
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
1495
 
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
1496
 
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
1497
 
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
1498
 
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
1499
 
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
1500
 
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
1501
 
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
1502
 
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
1503
 
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
1504
 
  }
1505
 
 
1506
 
  /// Return the number of sub dof maps (for a mixed element)
1507
 
  virtual unsigned int num_sub_dof_maps() const
1508
 
  {
1509
 
    return 1;
1510
 
  }
1511
 
 
1512
 
  /// Create a new dof_map for sub dof map i (for a mixed element)
1513
 
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
1514
 
  {
1515
 
    return new UFC_ProjectionBilinearForm_dof_map_0();
1516
 
  }
1517
 
 
1518
 
};
1519
 
 
1520
 
/// This class defines the interface for a local-to-global mapping of
1521
 
/// degrees of freedom (dofs).
1522
 
 
1523
 
class UFC_ProjectionBilinearForm_dof_map_1: public ufc::dof_map
1524
 
{
1525
 
private:
1526
 
 
1527
 
  unsigned int __global_dimension;
1528
 
 
1529
 
public:
1530
 
 
1531
 
  /// Constructor
1532
 
  UFC_ProjectionBilinearForm_dof_map_1() : ufc::dof_map()
1533
 
  {
1534
 
    __global_dimension = 0;
1535
 
  }
1536
 
 
1537
 
  /// Destructor
1538
 
  virtual ~UFC_ProjectionBilinearForm_dof_map_1()
1539
 
  {
1540
 
    // Do nothing
1541
 
  }
1542
 
 
1543
 
  /// Return a string identifying the dof map
1544
 
  virtual const char* signature() const
1545
 
  {
1546
 
    return "FFC dof map for FiniteElement('Lagrange', 'tetrahedron', 2)";
1547
 
  }
1548
 
 
1549
 
  /// Return true iff mesh entities of topological dimension d are needed
1550
 
  virtual bool needs_mesh_entities(unsigned int d) const
1551
 
  {
1552
 
    switch ( d )
1553
 
    {
1554
 
    case 0:
1555
 
      return true;
1556
 
      break;
1557
 
    case 1:
1558
 
      return true;
1559
 
      break;
1560
 
    case 2:
1561
 
      return false;
1562
 
      break;
1563
 
    case 3:
1564
 
      return false;
1565
 
      break;
1566
 
    }
1567
 
    return false;
1568
 
  }
1569
 
 
1570
 
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
1571
 
  virtual bool init_mesh(const ufc::mesh& m)
1572
 
  {
1573
 
    __global_dimension = m.num_entities[0] + m.num_entities[1];
1574
 
    return false;
1575
 
  }
1576
 
 
1577
 
  /// Initialize dof map for given cell
1578
 
  virtual void init_cell(const ufc::mesh& m,
1579
 
                         const ufc::cell& c)
1580
 
  {
1581
 
    // Do nothing
1582
 
  }
1583
 
 
1584
 
  /// Finish initialization of dof map for cells
1585
 
  virtual void init_cell_finalize()
1586
 
  {
1587
 
    // Do nothing
1588
 
  }
1589
 
 
1590
 
  /// Return the dimension of the global finite element function space
1591
 
  virtual unsigned int global_dimension() const
1592
 
  {
1593
 
    return __global_dimension;
1594
 
  }
1595
 
 
1596
 
  /// Return the dimension of the local finite element function space
1597
 
  virtual unsigned int local_dimension() const
1598
 
  {
1599
 
    return 10;
1600
 
  }
1601
 
 
1602
 
  // Return the geometric dimension of the coordinates this dof map provides
1603
 
  virtual unsigned int geometric_dimension() const
1604
 
  {
1605
 
    return 3;
1606
 
  }
1607
 
 
1608
 
  /// Return the number of dofs on each cell facet
1609
 
  virtual unsigned int num_facet_dofs() const
1610
 
  {
1611
 
    return 6;
1612
 
  }
1613
 
 
1614
 
  /// Return the number of dofs associated with each cell entity of dimension d
1615
 
  virtual unsigned int num_entity_dofs(unsigned int d) const
1616
 
  {
1617
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
1618
 
  }
1619
 
 
1620
 
  /// Tabulate the local-to-global mapping of dofs on a cell
1621
 
  virtual void tabulate_dofs(unsigned int* dofs,
1622
 
                             const ufc::mesh& m,
1623
 
                             const ufc::cell& c) const
1624
 
  {
1625
 
    dofs[0] = c.entity_indices[0][0];
1626
 
    dofs[1] = c.entity_indices[0][1];
1627
 
    dofs[2] = c.entity_indices[0][2];
1628
 
    dofs[3] = c.entity_indices[0][3];
1629
 
    unsigned int offset = m.num_entities[0];
1630
 
    dofs[4] = offset + c.entity_indices[1][0];
1631
 
    dofs[5] = offset + c.entity_indices[1][1];
1632
 
    dofs[6] = offset + c.entity_indices[1][2];
1633
 
    dofs[7] = offset + c.entity_indices[1][3];
1634
 
    dofs[8] = offset + c.entity_indices[1][4];
1635
 
    dofs[9] = offset + c.entity_indices[1][5];
1636
 
  }
1637
 
 
1638
 
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
1639
 
  virtual void tabulate_facet_dofs(unsigned int* dofs,
1640
 
                                   unsigned int facet) const
1641
 
  {
1642
 
    switch ( facet )
1643
 
    {
1644
 
    case 0:
1645
 
      dofs[0] = 1;
1646
 
      dofs[1] = 2;
1647
 
      dofs[2] = 3;
1648
 
      dofs[3] = 4;
1649
 
      dofs[4] = 5;
1650
 
      dofs[5] = 6;
1651
 
      break;
1652
 
    case 1:
1653
 
      dofs[0] = 0;
1654
 
      dofs[1] = 2;
1655
 
      dofs[2] = 3;
1656
 
      dofs[3] = 4;
1657
 
      dofs[4] = 7;
1658
 
      dofs[5] = 8;
1659
 
      break;
1660
 
    case 2:
1661
 
      dofs[0] = 0;
1662
 
      dofs[1] = 1;
1663
 
      dofs[2] = 3;
1664
 
      dofs[3] = 5;
1665
 
      dofs[4] = 7;
1666
 
      dofs[5] = 9;
1667
 
      break;
1668
 
    case 3:
1669
 
      dofs[0] = 0;
1670
 
      dofs[1] = 1;
1671
 
      dofs[2] = 2;
1672
 
      dofs[3] = 6;
1673
 
      dofs[4] = 8;
1674
 
      dofs[5] = 9;
1675
 
      break;
1676
 
    }
1677
 
  }
1678
 
 
1679
 
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
1680
 
  virtual void tabulate_entity_dofs(unsigned int* dofs,
1681
 
                                    unsigned int d, unsigned int i) const
1682
 
  {
1683
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
1684
 
  }
1685
 
 
1686
 
  /// Tabulate the coordinates of all dofs on a cell
1687
 
  virtual void tabulate_coordinates(double** coordinates,
1688
 
                                    const ufc::cell& c) const
1689
 
  {
1690
 
    const double * const * x = c.coordinates;
1691
 
    coordinates[0][0] = x[0][0];
1692
 
    coordinates[0][1] = x[0][1];
1693
 
    coordinates[0][2] = x[0][2];
1694
 
    coordinates[1][0] = x[1][0];
1695
 
    coordinates[1][1] = x[1][1];
1696
 
    coordinates[1][2] = x[1][2];
1697
 
    coordinates[2][0] = x[2][0];
1698
 
    coordinates[2][1] = x[2][1];
1699
 
    coordinates[2][2] = x[2][2];
1700
 
    coordinates[3][0] = x[3][0];
1701
 
    coordinates[3][1] = x[3][1];
1702
 
    coordinates[3][2] = x[3][2];
1703
 
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
1704
 
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
1705
 
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
1706
 
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
1707
 
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
1708
 
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
1709
 
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
1710
 
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
1711
 
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
1712
 
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
1713
 
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
1714
 
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
1715
 
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
1716
 
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
1717
 
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
1718
 
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
1719
 
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
1720
 
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
1721
 
  }
1722
 
 
1723
 
  /// Return the number of sub dof maps (for a mixed element)
1724
 
  virtual unsigned int num_sub_dof_maps() const
1725
 
  {
1726
 
    return 1;
1727
 
  }
1728
 
 
1729
 
  /// Create a new dof_map for sub dof map i (for a mixed element)
1730
 
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
1731
 
  {
1732
 
    return new UFC_ProjectionBilinearForm_dof_map_1();
 
14
    
 
15
/// This class defines the interface for a finite element.
 
16
 
 
17
class projection_0_finite_element_0: public ufc::finite_element
 
18
{
 
19
public:
 
20
 
 
21
  /// Constructor
 
22
  projection_0_finite_element_0() : ufc::finite_element()
 
23
  {
 
24
    // Do nothing
 
25
  }
 
26
 
 
27
  /// Destructor
 
28
  virtual ~projection_0_finite_element_0()
 
29
  {
 
30
    // Do nothing
 
31
  }
 
32
 
 
33
  /// Return a string identifying the finite element
 
34
  virtual const char* signature() const
 
35
  {
 
36
    return "FiniteElement('Lagrange', 'tetrahedron', 2)";
 
37
  }
 
38
 
 
39
  /// Return the cell shape
 
40
  virtual ufc::shape cell_shape() const
 
41
  {
 
42
    return ufc::tetrahedron;
 
43
  }
 
44
 
 
45
  /// Return the dimension of the finite element function space
 
46
  virtual unsigned int space_dimension() const
 
47
  {
 
48
    return 10;
 
49
  }
 
50
 
 
51
  /// Return the rank of the value space
 
52
  virtual unsigned int value_rank() const
 
53
  {
 
54
    return 0;
 
55
  }
 
56
 
 
57
  /// Return the dimension of the value space for axis i
 
58
  virtual unsigned int value_dimension(unsigned int i) const
 
59
  {
 
60
    return 1;
 
61
  }
 
62
 
 
63
  /// Evaluate basis function i at given point in cell
 
64
  virtual void evaluate_basis(unsigned int i,
 
65
                              double* values,
 
66
                              const double* coordinates,
 
67
                              const ufc::cell& c) const
 
68
  {
 
69
    // Extract vertex coordinates
 
70
    const double * const * element_coordinates = c.coordinates;
 
71
    
 
72
    // Compute Jacobian of affine map from reference cell
 
73
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
 
74
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
 
75
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
 
76
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
 
77
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
 
78
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
 
79
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
 
80
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
 
81
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
 
82
    
 
83
    // Compute sub determinants
 
84
    const double d00 = J_11*J_22 - J_12*J_21;
 
85
    const double d01 = J_12*J_20 - J_10*J_22;
 
86
    const double d02 = J_10*J_21 - J_11*J_20;
 
87
    
 
88
    const double d10 = J_02*J_21 - J_01*J_22;
 
89
    const double d11 = J_00*J_22 - J_02*J_20;
 
90
    const double d12 = J_01*J_20 - J_00*J_21;
 
91
    
 
92
    const double d20 = J_01*J_12 - J_02*J_11;
 
93
    const double d21 = J_02*J_10 - J_00*J_12;
 
94
    const double d22 = J_00*J_11 - J_01*J_10;
 
95
    
 
96
    // Compute determinant of Jacobian
 
97
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
 
98
    
 
99
    // Compute inverse of Jacobian
 
100
    
 
101
    // Compute constants
 
102
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
 
103
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
 
104
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
 
105
    
 
106
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
 
107
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
 
108
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
 
109
    
 
110
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
 
111
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
 
112
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
 
113
    
 
114
    // Get coordinates and map to the UFC reference element
 
115
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
 
116
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
 
117
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
 
118
    
 
119
    // Map coordinates to the reference cube
 
120
    if (std::abs(y + z - 1.0) < 1e-14)
 
121
      x = 1.0;
 
122
    else
 
123
      x = -2.0 * x/(y + z - 1.0) - 1.0;
 
124
    if (std::abs(z - 1.0) < 1e-14)
 
125
      y = -1.0;
 
126
    else
 
127
      y = 2.0 * y/(1.0 - z) - 1.0;
 
128
    z = 2.0 * z - 1.0;
 
129
    
 
130
    // Reset values
 
131
    *values = 0;
 
132
    
 
133
    // Map degree of freedom to element degree of freedom
 
134
    const unsigned int dof = i;
 
135
    
 
136
    // Generate scalings
 
137
    const double scalings_y_0 = 1;
 
138
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
 
139
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
 
140
    const double scalings_z_0 = 1;
 
141
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
 
142
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
 
143
    
 
144
    // Compute psitilde_a
 
145
    const double psitilde_a_0 = 1;
 
146
    const double psitilde_a_1 = x;
 
147
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
 
148
    
 
149
    // Compute psitilde_bs
 
150
    const double psitilde_bs_0_0 = 1;
 
151
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
 
152
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
 
153
    const double psitilde_bs_1_0 = 1;
 
154
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
 
155
    const double psitilde_bs_2_0 = 1;
 
156
    
 
157
    // Compute psitilde_cs
 
158
    const double psitilde_cs_00_0 = 1;
 
159
    const double psitilde_cs_00_1 = 2*z + 1;
 
160
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
 
161
    const double psitilde_cs_01_0 = 1;
 
162
    const double psitilde_cs_01_1 = 3*z + 2;
 
163
    const double psitilde_cs_02_0 = 1;
 
164
    const double psitilde_cs_10_0 = 1;
 
165
    const double psitilde_cs_10_1 = 3*z + 2;
 
166
    const double psitilde_cs_11_0 = 1;
 
167
    const double psitilde_cs_20_0 = 1;
 
168
    
 
169
    // Compute basisvalues
 
170
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
 
171
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
 
172
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
 
173
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
 
174
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
 
175
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
 
176
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
 
177
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
 
178
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
 
179
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
 
180
    
 
181
    // Table(s) of coefficients
 
182
    static const double coefficients0[10][10] = \
 
183
    {{-0.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.0503952630678969, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
184
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
185
    {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323},
 
186
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
 
187
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
 
188
    {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
189
    {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
190
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
191
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
192
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
 
193
    
 
194
    // Extract relevant coefficients
 
195
    const double coeff0_0 = coefficients0[dof][0];
 
196
    const double coeff0_1 = coefficients0[dof][1];
 
197
    const double coeff0_2 = coefficients0[dof][2];
 
198
    const double coeff0_3 = coefficients0[dof][3];
 
199
    const double coeff0_4 = coefficients0[dof][4];
 
200
    const double coeff0_5 = coefficients0[dof][5];
 
201
    const double coeff0_6 = coefficients0[dof][6];
 
202
    const double coeff0_7 = coefficients0[dof][7];
 
203
    const double coeff0_8 = coefficients0[dof][8];
 
204
    const double coeff0_9 = coefficients0[dof][9];
 
205
    
 
206
    // Compute value(s)
 
207
    *values = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9;
 
208
  }
 
209
 
 
210
  /// Evaluate all basis functions at given point in cell
 
211
  virtual void evaluate_basis_all(double* values,
 
212
                                  const double* coordinates,
 
213
                                  const ufc::cell& c) const
 
214
  {
 
215
    throw std::runtime_error("The vectorised version of evaluate_basis() is not yet implemented.");
 
216
  }
 
217
 
 
218
  /// Evaluate order n derivatives of basis function i at given point in cell
 
219
  virtual void evaluate_basis_derivatives(unsigned int i,
 
220
                                          unsigned int n,
 
221
                                          double* values,
 
222
                                          const double* coordinates,
 
223
                                          const ufc::cell& c) const
 
224
  {
 
225
    // Extract vertex coordinates
 
226
    const double * const * element_coordinates = c.coordinates;
 
227
    
 
228
    // Compute Jacobian of affine map from reference cell
 
229
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
 
230
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
 
231
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
 
232
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
 
233
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
 
234
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
 
235
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
 
236
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
 
237
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
 
238
    
 
239
    // Compute sub determinants
 
240
    const double d00 = J_11*J_22 - J_12*J_21;
 
241
    const double d01 = J_12*J_20 - J_10*J_22;
 
242
    const double d02 = J_10*J_21 - J_11*J_20;
 
243
    
 
244
    const double d10 = J_02*J_21 - J_01*J_22;
 
245
    const double d11 = J_00*J_22 - J_02*J_20;
 
246
    const double d12 = J_01*J_20 - J_00*J_21;
 
247
    
 
248
    const double d20 = J_01*J_12 - J_02*J_11;
 
249
    const double d21 = J_02*J_10 - J_00*J_12;
 
250
    const double d22 = J_00*J_11 - J_01*J_10;
 
251
    
 
252
    // Compute determinant of Jacobian
 
253
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
 
254
    
 
255
    // Compute inverse of Jacobian
 
256
    
 
257
    // Compute constants
 
258
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
 
259
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
 
260
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
 
261
    
 
262
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
 
263
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
 
264
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
 
265
    
 
266
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
 
267
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
 
268
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
 
269
    
 
270
    // Get coordinates and map to the UFC reference element
 
271
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
 
272
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
 
273
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
 
274
    
 
275
    // Map coordinates to the reference cube
 
276
    if (std::abs(y + z - 1.0) < 1e-14)
 
277
      x = 1.0;
 
278
    else
 
279
      x = -2.0 * x/(y + z - 1.0) - 1.0;
 
280
    if (std::abs(z - 1.0) < 1e-14)
 
281
      y = -1.0;
 
282
    else
 
283
      y = 2.0 * y/(1.0 - z) - 1.0;
 
284
    z = 2.0 * z - 1.0;
 
285
    
 
286
    // Compute number of derivatives
 
287
    unsigned int num_derivatives = 1;
 
288
    
 
289
    for (unsigned int j = 0; j < n; j++)
 
290
      num_derivatives *= 3;
 
291
    
 
292
    
 
293
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
294
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
295
    
 
296
    for (unsigned int j = 0; j < num_derivatives; j++)
 
297
    {
 
298
      combinations[j] = new unsigned int [n];
 
299
      for (unsigned int k = 0; k < n; k++)
 
300
        combinations[j][k] = 0;
 
301
    }
 
302
    
 
303
    // Generate combinations of derivatives
 
304
    for (unsigned int row = 1; row < num_derivatives; row++)
 
305
    {
 
306
      for (unsigned int num = 0; num < row; num++)
 
307
      {
 
308
        for (unsigned int col = n-1; col+1 > 0; col--)
 
309
        {
 
310
          if (combinations[row][col] + 1 > 2)
 
311
            combinations[row][col] = 0;
 
312
          else
 
313
          {
 
314
            combinations[row][col] += 1;
 
315
            break;
 
316
          }
 
317
        }
 
318
      }
 
319
    }
 
320
    
 
321
    // Compute inverse of Jacobian
 
322
    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};
 
323
    
 
324
    // Declare transformation matrix
 
325
    // Declare pointer to two dimensional array and initialise
 
326
    double **transform = new double *[num_derivatives];
 
327
    
 
328
    for (unsigned int j = 0; j < num_derivatives; j++)
 
329
    {
 
330
      transform[j] = new double [num_derivatives];
 
331
      for (unsigned int k = 0; k < num_derivatives; k++)
 
332
        transform[j][k] = 1;
 
333
    }
 
334
    
 
335
    // Construct transformation matrix
 
336
    for (unsigned int row = 0; row < num_derivatives; row++)
 
337
    {
 
338
      for (unsigned int col = 0; col < num_derivatives; col++)
 
339
      {
 
340
        for (unsigned int k = 0; k < n; k++)
 
341
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
342
      }
 
343
    }
 
344
    
 
345
    // Reset values
 
346
    for (unsigned int j = 0; j < 1*num_derivatives; j++)
 
347
      values[j] = 0;
 
348
    
 
349
    // Map degree of freedom to element degree of freedom
 
350
    const unsigned int dof = i;
 
351
    
 
352
    // Generate scalings
 
353
    const double scalings_y_0 = 1;
 
354
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
 
355
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
 
356
    const double scalings_z_0 = 1;
 
357
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
 
358
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
 
359
    
 
360
    // Compute psitilde_a
 
361
    const double psitilde_a_0 = 1;
 
362
    const double psitilde_a_1 = x;
 
363
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
 
364
    
 
365
    // Compute psitilde_bs
 
366
    const double psitilde_bs_0_0 = 1;
 
367
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
 
368
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
 
369
    const double psitilde_bs_1_0 = 1;
 
370
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
 
371
    const double psitilde_bs_2_0 = 1;
 
372
    
 
373
    // Compute psitilde_cs
 
374
    const double psitilde_cs_00_0 = 1;
 
375
    const double psitilde_cs_00_1 = 2*z + 1;
 
376
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
 
377
    const double psitilde_cs_01_0 = 1;
 
378
    const double psitilde_cs_01_1 = 3*z + 2;
 
379
    const double psitilde_cs_02_0 = 1;
 
380
    const double psitilde_cs_10_0 = 1;
 
381
    const double psitilde_cs_10_1 = 3*z + 2;
 
382
    const double psitilde_cs_11_0 = 1;
 
383
    const double psitilde_cs_20_0 = 1;
 
384
    
 
385
    // Compute basisvalues
 
386
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
 
387
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
 
388
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
 
389
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
 
390
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
 
391
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
 
392
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
 
393
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
 
394
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
 
395
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
 
396
    
 
397
    // Table(s) of coefficients
 
398
    static const double coefficients0[10][10] = \
 
399
    {{-0.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.0503952630678969, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
400
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
401
    {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323},
 
402
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
 
403
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
 
404
    {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
405
    {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
406
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
407
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
408
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
 
409
    
 
410
    // Interesting (new) part
 
411
    // Tables of derivatives of the polynomial base (transpose)
 
412
    static const double dmats0[10][10] = \
 
413
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
414
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
415
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
416
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
417
    {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0},
 
418
    {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0},
 
419
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
420
    {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0},
 
421
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
422
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
 
423
    
 
424
    static const double dmats1[10][10] = \
 
425
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
426
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
427
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
428
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
429
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
 
430
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
 
431
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0},
 
432
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
 
433
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0},
 
434
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
 
435
    
 
436
    static const double dmats2[10][10] = \
 
437
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
438
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
439
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
440
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
441
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
 
442
    {2.29128784747792, 1.44913767461894, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
 
443
    {1.3228756555323, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},
 
444
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
 
445
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960223, 0, 0, 0, 0, 0, 0},
 
446
    {-3.81881307912987, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};
 
447
    
 
448
    // Compute reference derivatives
 
449
    // Declare pointer to array of derivatives on FIAT element
 
450
    double *derivatives = new double [num_derivatives];
 
451
    
 
452
    // Declare coefficients
 
453
    double coeff0_0 = 0;
 
454
    double coeff0_1 = 0;
 
455
    double coeff0_2 = 0;
 
456
    double coeff0_3 = 0;
 
457
    double coeff0_4 = 0;
 
458
    double coeff0_5 = 0;
 
459
    double coeff0_6 = 0;
 
460
    double coeff0_7 = 0;
 
461
    double coeff0_8 = 0;
 
462
    double coeff0_9 = 0;
 
463
    
 
464
    // Declare new coefficients
 
465
    double new_coeff0_0 = 0;
 
466
    double new_coeff0_1 = 0;
 
467
    double new_coeff0_2 = 0;
 
468
    double new_coeff0_3 = 0;
 
469
    double new_coeff0_4 = 0;
 
470
    double new_coeff0_5 = 0;
 
471
    double new_coeff0_6 = 0;
 
472
    double new_coeff0_7 = 0;
 
473
    double new_coeff0_8 = 0;
 
474
    double new_coeff0_9 = 0;
 
475
    
 
476
    // Loop possible derivatives
 
477
    for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
 
478
    {
 
479
      // Get values from coefficients array
 
480
      new_coeff0_0 = coefficients0[dof][0];
 
481
      new_coeff0_1 = coefficients0[dof][1];
 
482
      new_coeff0_2 = coefficients0[dof][2];
 
483
      new_coeff0_3 = coefficients0[dof][3];
 
484
      new_coeff0_4 = coefficients0[dof][4];
 
485
      new_coeff0_5 = coefficients0[dof][5];
 
486
      new_coeff0_6 = coefficients0[dof][6];
 
487
      new_coeff0_7 = coefficients0[dof][7];
 
488
      new_coeff0_8 = coefficients0[dof][8];
 
489
      new_coeff0_9 = coefficients0[dof][9];
 
490
    
 
491
      // Loop derivative order
 
492
      for (unsigned int j = 0; j < n; j++)
 
493
      {
 
494
        // Update old coefficients
 
495
        coeff0_0 = new_coeff0_0;
 
496
        coeff0_1 = new_coeff0_1;
 
497
        coeff0_2 = new_coeff0_2;
 
498
        coeff0_3 = new_coeff0_3;
 
499
        coeff0_4 = new_coeff0_4;
 
500
        coeff0_5 = new_coeff0_5;
 
501
        coeff0_6 = new_coeff0_6;
 
502
        coeff0_7 = new_coeff0_7;
 
503
        coeff0_8 = new_coeff0_8;
 
504
        coeff0_9 = new_coeff0_9;
 
505
    
 
506
        if(combinations[deriv_num][j] == 0)
 
507
        {
 
508
          new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0];
 
509
          new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1];
 
510
          new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2];
 
511
          new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3];
 
512
          new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4];
 
513
          new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5];
 
514
          new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6];
 
515
          new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7];
 
516
          new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8];
 
517
          new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9];
 
518
        }
 
519
        if(combinations[deriv_num][j] == 1)
 
520
        {
 
521
          new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0];
 
522
          new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1];
 
523
          new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2];
 
524
          new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3];
 
525
          new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4];
 
526
          new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5];
 
527
          new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6];
 
528
          new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7];
 
529
          new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8];
 
530
          new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9];
 
531
        }
 
532
        if(combinations[deriv_num][j] == 2)
 
533
        {
 
534
          new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0];
 
535
          new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1];
 
536
          new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2];
 
537
          new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3];
 
538
          new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4];
 
539
          new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5];
 
540
          new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6];
 
541
          new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7];
 
542
          new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8];
 
543
          new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9];
 
544
        }
 
545
    
 
546
      }
 
547
      // Compute derivatives on reference element as dot product of coefficients and basisvalues
 
548
      derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9;
 
549
    }
 
550
    
 
551
    // Transform derivatives back to physical element
 
552
    for (unsigned int row = 0; row < num_derivatives; row++)
 
553
    {
 
554
      for (unsigned int col = 0; col < num_derivatives; col++)
 
555
      {
 
556
        values[row] += transform[row][col]*derivatives[col];
 
557
      }
 
558
    }
 
559
    // Delete pointer to array of derivatives on FIAT element
 
560
    delete [] derivatives;
 
561
    
 
562
    // Delete pointer to array of combinations of derivatives and transform
 
563
    for (unsigned int row = 0; row < num_derivatives; row++)
 
564
    {
 
565
      delete [] combinations[row];
 
566
      delete [] transform[row];
 
567
    }
 
568
    
 
569
    delete [] combinations;
 
570
    delete [] transform;
 
571
  }
 
572
 
 
573
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
574
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
575
                                              double* values,
 
576
                                              const double* coordinates,
 
577
                                              const ufc::cell& c) const
 
578
  {
 
579
    throw std::runtime_error("The vectorised version of evaluate_basis_derivatives() is not yet implemented.");
 
580
  }
 
581
 
 
582
  /// Evaluate linear functional for dof i on the function f
 
583
  virtual double evaluate_dof(unsigned int i,
 
584
                              const ufc::function& f,
 
585
                              const ufc::cell& c) const
 
586
  {
 
587
    // The reference points, direction and weights:
 
588
    static const double X[10][1][3] = {{{0, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0.5, 0.5}}, {{0.5, 0, 0.5}}, {{0.5, 0.5, 0}}, {{0, 0, 0.5}}, {{0, 0.5, 0}}, {{0.5, 0, 0}}};
 
589
    static const double W[10][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
 
590
    static const double D[10][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
 
591
    
 
592
    const double * const * x = c.coordinates;
 
593
    double result = 0.0;
 
594
    // Iterate over the points:
 
595
    // Evaluate basis functions for affine mapping
 
596
    const double w0 = 1.0 - X[i][0][0] - X[i][0][1] - X[i][0][2];
 
597
    const double w1 = X[i][0][0];
 
598
    const double w2 = X[i][0][1];
 
599
    const double w3 = X[i][0][2];
 
600
    
 
601
    // Compute affine mapping y = F(X)
 
602
    double y[3];
 
603
    y[0] = w0*x[0][0] + w1*x[1][0] + w2*x[2][0] + w3*x[3][0];
 
604
    y[1] = w0*x[0][1] + w1*x[1][1] + w2*x[2][1] + w3*x[3][1];
 
605
    y[2] = w0*x[0][2] + w1*x[1][2] + w2*x[2][2] + w3*x[3][2];
 
606
    
 
607
    // Evaluate function at physical points
 
608
    double values[1];
 
609
    f.evaluate(values, y, c);
 
610
    
 
611
    // Map function values using appropriate mapping
 
612
    // Affine map: Do nothing
 
613
    
 
614
    // Note that we do not map the weights (yet).
 
615
    
 
616
    // Take directional components
 
617
    for(int k = 0; k < 1; k++)
 
618
      result += values[k]*D[i][0][k];
 
619
    // Multiply by weights
 
620
    result *= W[i][0];
 
621
    
 
622
    return result;
 
623
  }
 
624
 
 
625
  /// Evaluate linear functionals for all dofs on the function f
 
626
  virtual void evaluate_dofs(double* values,
 
627
                             const ufc::function& f,
 
628
                             const ufc::cell& c) const
 
629
  {
 
630
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
631
  }
 
632
 
 
633
  /// Interpolate vertex values from dof values
 
634
  virtual void interpolate_vertex_values(double* vertex_values,
 
635
                                         const double* dof_values,
 
636
                                         const ufc::cell& c) const
 
637
  {
 
638
    // Evaluate at vertices and use affine mapping
 
639
    vertex_values[0] = dof_values[0];
 
640
    vertex_values[1] = dof_values[1];
 
641
    vertex_values[2] = dof_values[2];
 
642
    vertex_values[3] = dof_values[3];
 
643
  }
 
644
 
 
645
  /// Return the number of sub elements (for a mixed element)
 
646
  virtual unsigned int num_sub_elements() const
 
647
  {
 
648
    return 1;
 
649
  }
 
650
 
 
651
  /// Create a new finite element for sub element i (for a mixed element)
 
652
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
653
  {
 
654
    return new projection_0_finite_element_0();
 
655
  }
 
656
 
 
657
};
 
658
 
 
659
/// This class defines the interface for a finite element.
 
660
 
 
661
class projection_0_finite_element_1: public ufc::finite_element
 
662
{
 
663
public:
 
664
 
 
665
  /// Constructor
 
666
  projection_0_finite_element_1() : ufc::finite_element()
 
667
  {
 
668
    // Do nothing
 
669
  }
 
670
 
 
671
  /// Destructor
 
672
  virtual ~projection_0_finite_element_1()
 
673
  {
 
674
    // Do nothing
 
675
  }
 
676
 
 
677
  /// Return a string identifying the finite element
 
678
  virtual const char* signature() const
 
679
  {
 
680
    return "FiniteElement('Lagrange', 'tetrahedron', 2)";
 
681
  }
 
682
 
 
683
  /// Return the cell shape
 
684
  virtual ufc::shape cell_shape() const
 
685
  {
 
686
    return ufc::tetrahedron;
 
687
  }
 
688
 
 
689
  /// Return the dimension of the finite element function space
 
690
  virtual unsigned int space_dimension() const
 
691
  {
 
692
    return 10;
 
693
  }
 
694
 
 
695
  /// Return the rank of the value space
 
696
  virtual unsigned int value_rank() const
 
697
  {
 
698
    return 0;
 
699
  }
 
700
 
 
701
  /// Return the dimension of the value space for axis i
 
702
  virtual unsigned int value_dimension(unsigned int i) const
 
703
  {
 
704
    return 1;
 
705
  }
 
706
 
 
707
  /// Evaluate basis function i at given point in cell
 
708
  virtual void evaluate_basis(unsigned int i,
 
709
                              double* values,
 
710
                              const double* coordinates,
 
711
                              const ufc::cell& c) const
 
712
  {
 
713
    // Extract vertex coordinates
 
714
    const double * const * element_coordinates = c.coordinates;
 
715
    
 
716
    // Compute Jacobian of affine map from reference cell
 
717
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
 
718
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
 
719
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
 
720
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
 
721
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
 
722
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
 
723
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
 
724
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
 
725
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
 
726
    
 
727
    // Compute sub determinants
 
728
    const double d00 = J_11*J_22 - J_12*J_21;
 
729
    const double d01 = J_12*J_20 - J_10*J_22;
 
730
    const double d02 = J_10*J_21 - J_11*J_20;
 
731
    
 
732
    const double d10 = J_02*J_21 - J_01*J_22;
 
733
    const double d11 = J_00*J_22 - J_02*J_20;
 
734
    const double d12 = J_01*J_20 - J_00*J_21;
 
735
    
 
736
    const double d20 = J_01*J_12 - J_02*J_11;
 
737
    const double d21 = J_02*J_10 - J_00*J_12;
 
738
    const double d22 = J_00*J_11 - J_01*J_10;
 
739
    
 
740
    // Compute determinant of Jacobian
 
741
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
 
742
    
 
743
    // Compute inverse of Jacobian
 
744
    
 
745
    // Compute constants
 
746
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
 
747
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
 
748
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
 
749
    
 
750
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
 
751
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
 
752
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
 
753
    
 
754
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
 
755
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
 
756
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
 
757
    
 
758
    // Get coordinates and map to the UFC reference element
 
759
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
 
760
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
 
761
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
 
762
    
 
763
    // Map coordinates to the reference cube
 
764
    if (std::abs(y + z - 1.0) < 1e-14)
 
765
      x = 1.0;
 
766
    else
 
767
      x = -2.0 * x/(y + z - 1.0) - 1.0;
 
768
    if (std::abs(z - 1.0) < 1e-14)
 
769
      y = -1.0;
 
770
    else
 
771
      y = 2.0 * y/(1.0 - z) - 1.0;
 
772
    z = 2.0 * z - 1.0;
 
773
    
 
774
    // Reset values
 
775
    *values = 0;
 
776
    
 
777
    // Map degree of freedom to element degree of freedom
 
778
    const unsigned int dof = i;
 
779
    
 
780
    // Generate scalings
 
781
    const double scalings_y_0 = 1;
 
782
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
 
783
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
 
784
    const double scalings_z_0 = 1;
 
785
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
 
786
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
 
787
    
 
788
    // Compute psitilde_a
 
789
    const double psitilde_a_0 = 1;
 
790
    const double psitilde_a_1 = x;
 
791
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
 
792
    
 
793
    // Compute psitilde_bs
 
794
    const double psitilde_bs_0_0 = 1;
 
795
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
 
796
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
 
797
    const double psitilde_bs_1_0 = 1;
 
798
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
 
799
    const double psitilde_bs_2_0 = 1;
 
800
    
 
801
    // Compute psitilde_cs
 
802
    const double psitilde_cs_00_0 = 1;
 
803
    const double psitilde_cs_00_1 = 2*z + 1;
 
804
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
 
805
    const double psitilde_cs_01_0 = 1;
 
806
    const double psitilde_cs_01_1 = 3*z + 2;
 
807
    const double psitilde_cs_02_0 = 1;
 
808
    const double psitilde_cs_10_0 = 1;
 
809
    const double psitilde_cs_10_1 = 3*z + 2;
 
810
    const double psitilde_cs_11_0 = 1;
 
811
    const double psitilde_cs_20_0 = 1;
 
812
    
 
813
    // Compute basisvalues
 
814
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
 
815
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
 
816
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
 
817
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
 
818
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
 
819
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
 
820
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
 
821
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
 
822
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
 
823
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
 
824
    
 
825
    // Table(s) of coefficients
 
826
    static const double coefficients0[10][10] = \
 
827
    {{-0.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.0503952630678969, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
828
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
829
    {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323},
 
830
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
 
831
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
 
832
    {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
833
    {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
834
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
835
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
836
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
 
837
    
 
838
    // Extract relevant coefficients
 
839
    const double coeff0_0 = coefficients0[dof][0];
 
840
    const double coeff0_1 = coefficients0[dof][1];
 
841
    const double coeff0_2 = coefficients0[dof][2];
 
842
    const double coeff0_3 = coefficients0[dof][3];
 
843
    const double coeff0_4 = coefficients0[dof][4];
 
844
    const double coeff0_5 = coefficients0[dof][5];
 
845
    const double coeff0_6 = coefficients0[dof][6];
 
846
    const double coeff0_7 = coefficients0[dof][7];
 
847
    const double coeff0_8 = coefficients0[dof][8];
 
848
    const double coeff0_9 = coefficients0[dof][9];
 
849
    
 
850
    // Compute value(s)
 
851
    *values = coeff0_0*basisvalue0 + coeff0_1*basisvalue1 + coeff0_2*basisvalue2 + coeff0_3*basisvalue3 + coeff0_4*basisvalue4 + coeff0_5*basisvalue5 + coeff0_6*basisvalue6 + coeff0_7*basisvalue7 + coeff0_8*basisvalue8 + coeff0_9*basisvalue9;
 
852
  }
 
853
 
 
854
  /// Evaluate all basis functions at given point in cell
 
855
  virtual void evaluate_basis_all(double* values,
 
856
                                  const double* coordinates,
 
857
                                  const ufc::cell& c) const
 
858
  {
 
859
    throw std::runtime_error("The vectorised version of evaluate_basis() is not yet implemented.");
 
860
  }
 
861
 
 
862
  /// Evaluate order n derivatives of basis function i at given point in cell
 
863
  virtual void evaluate_basis_derivatives(unsigned int i,
 
864
                                          unsigned int n,
 
865
                                          double* values,
 
866
                                          const double* coordinates,
 
867
                                          const ufc::cell& c) const
 
868
  {
 
869
    // Extract vertex coordinates
 
870
    const double * const * element_coordinates = c.coordinates;
 
871
    
 
872
    // Compute Jacobian of affine map from reference cell
 
873
    const double J_00 = element_coordinates[1][0] - element_coordinates[0][0];
 
874
    const double J_01 = element_coordinates[2][0] - element_coordinates[0][0];
 
875
    const double J_02 = element_coordinates[3][0] - element_coordinates[0][0];
 
876
    const double J_10 = element_coordinates[1][1] - element_coordinates[0][1];
 
877
    const double J_11 = element_coordinates[2][1] - element_coordinates[0][1];
 
878
    const double J_12 = element_coordinates[3][1] - element_coordinates[0][1];
 
879
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
 
880
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
 
881
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
 
882
    
 
883
    // Compute sub determinants
 
884
    const double d00 = J_11*J_22 - J_12*J_21;
 
885
    const double d01 = J_12*J_20 - J_10*J_22;
 
886
    const double d02 = J_10*J_21 - J_11*J_20;
 
887
    
 
888
    const double d10 = J_02*J_21 - J_01*J_22;
 
889
    const double d11 = J_00*J_22 - J_02*J_20;
 
890
    const double d12 = J_01*J_20 - J_00*J_21;
 
891
    
 
892
    const double d20 = J_01*J_12 - J_02*J_11;
 
893
    const double d21 = J_02*J_10 - J_00*J_12;
 
894
    const double d22 = J_00*J_11 - J_01*J_10;
 
895
    
 
896
    // Compute determinant of Jacobian
 
897
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
 
898
    
 
899
    // Compute inverse of Jacobian
 
900
    
 
901
    // Compute constants
 
902
    const double C0 = d00*(element_coordinates[0][0] - element_coordinates[2][0] - element_coordinates[3][0]) \
 
903
                    + d10*(element_coordinates[0][1] - element_coordinates[2][1] - element_coordinates[3][1]) \
 
904
                    + d20*(element_coordinates[0][2] - element_coordinates[2][2] - element_coordinates[3][2]);
 
905
    
 
906
    const double C1 = d01*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[3][0]) \
 
907
                    + d11*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[3][1]) \
 
908
                    + d21*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[3][2]);
 
909
    
 
910
    const double C2 = d02*(element_coordinates[0][0] - element_coordinates[1][0] - element_coordinates[2][0]) \
 
911
                    + d12*(element_coordinates[0][1] - element_coordinates[1][1] - element_coordinates[2][1]) \
 
912
                    + d22*(element_coordinates[0][2] - element_coordinates[1][2] - element_coordinates[2][2]);
 
913
    
 
914
    // Get coordinates and map to the UFC reference element
 
915
    double x = (C0 + d00*coordinates[0] + d10*coordinates[1] + d20*coordinates[2]) / detJ;
 
916
    double y = (C1 + d01*coordinates[0] + d11*coordinates[1] + d21*coordinates[2]) / detJ;
 
917
    double z = (C2 + d02*coordinates[0] + d12*coordinates[1] + d22*coordinates[2]) / detJ;
 
918
    
 
919
    // Map coordinates to the reference cube
 
920
    if (std::abs(y + z - 1.0) < 1e-14)
 
921
      x = 1.0;
 
922
    else
 
923
      x = -2.0 * x/(y + z - 1.0) - 1.0;
 
924
    if (std::abs(z - 1.0) < 1e-14)
 
925
      y = -1.0;
 
926
    else
 
927
      y = 2.0 * y/(1.0 - z) - 1.0;
 
928
    z = 2.0 * z - 1.0;
 
929
    
 
930
    // Compute number of derivatives
 
931
    unsigned int num_derivatives = 1;
 
932
    
 
933
    for (unsigned int j = 0; j < n; j++)
 
934
      num_derivatives *= 3;
 
935
    
 
936
    
 
937
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
938
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
939
    
 
940
    for (unsigned int j = 0; j < num_derivatives; j++)
 
941
    {
 
942
      combinations[j] = new unsigned int [n];
 
943
      for (unsigned int k = 0; k < n; k++)
 
944
        combinations[j][k] = 0;
 
945
    }
 
946
    
 
947
    // Generate combinations of derivatives
 
948
    for (unsigned int row = 1; row < num_derivatives; row++)
 
949
    {
 
950
      for (unsigned int num = 0; num < row; num++)
 
951
      {
 
952
        for (unsigned int col = n-1; col+1 > 0; col--)
 
953
        {
 
954
          if (combinations[row][col] + 1 > 2)
 
955
            combinations[row][col] = 0;
 
956
          else
 
957
          {
 
958
            combinations[row][col] += 1;
 
959
            break;
 
960
          }
 
961
        }
 
962
      }
 
963
    }
 
964
    
 
965
    // Compute inverse of Jacobian
 
966
    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};
 
967
    
 
968
    // Declare transformation matrix
 
969
    // Declare pointer to two dimensional array and initialise
 
970
    double **transform = new double *[num_derivatives];
 
971
    
 
972
    for (unsigned int j = 0; j < num_derivatives; j++)
 
973
    {
 
974
      transform[j] = new double [num_derivatives];
 
975
      for (unsigned int k = 0; k < num_derivatives; k++)
 
976
        transform[j][k] = 1;
 
977
    }
 
978
    
 
979
    // Construct transformation matrix
 
980
    for (unsigned int row = 0; row < num_derivatives; row++)
 
981
    {
 
982
      for (unsigned int col = 0; col < num_derivatives; col++)
 
983
      {
 
984
        for (unsigned int k = 0; k < n; k++)
 
985
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
986
      }
 
987
    }
 
988
    
 
989
    // Reset values
 
990
    for (unsigned int j = 0; j < 1*num_derivatives; j++)
 
991
      values[j] = 0;
 
992
    
 
993
    // Map degree of freedom to element degree of freedom
 
994
    const unsigned int dof = i;
 
995
    
 
996
    // Generate scalings
 
997
    const double scalings_y_0 = 1;
 
998
    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);
 
999
    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);
 
1000
    const double scalings_z_0 = 1;
 
1001
    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);
 
1002
    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);
 
1003
    
 
1004
    // Compute psitilde_a
 
1005
    const double psitilde_a_0 = 1;
 
1006
    const double psitilde_a_1 = x;
 
1007
    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;
 
1008
    
 
1009
    // Compute psitilde_bs
 
1010
    const double psitilde_bs_0_0 = 1;
 
1011
    const double psitilde_bs_0_1 = 1.5*y + 0.5;
 
1012
    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;
 
1013
    const double psitilde_bs_1_0 = 1;
 
1014
    const double psitilde_bs_1_1 = 2.5*y + 1.5;
 
1015
    const double psitilde_bs_2_0 = 1;
 
1016
    
 
1017
    // Compute psitilde_cs
 
1018
    const double psitilde_cs_00_0 = 1;
 
1019
    const double psitilde_cs_00_1 = 2*z + 1;
 
1020
    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;
 
1021
    const double psitilde_cs_01_0 = 1;
 
1022
    const double psitilde_cs_01_1 = 3*z + 2;
 
1023
    const double psitilde_cs_02_0 = 1;
 
1024
    const double psitilde_cs_10_0 = 1;
 
1025
    const double psitilde_cs_10_1 = 3*z + 2;
 
1026
    const double psitilde_cs_11_0 = 1;
 
1027
    const double psitilde_cs_20_0 = 1;
 
1028
    
 
1029
    // Compute basisvalues
 
1030
    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;
 
1031
    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;
 
1032
    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;
 
1033
    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;
 
1034
    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;
 
1035
    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;
 
1036
    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;
 
1037
    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;
 
1038
    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;
 
1039
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
 
1040
    
 
1041
    // Table(s) of coefficients
 
1042
    static const double coefficients0[10][10] = \
 
1043
    {{-0.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.0503952630678969, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
1044
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
1045
    {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323},
 
1046
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
 
1047
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
 
1048
    {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
1049
    {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
1050
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
1051
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
1052
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
 
1053
    
 
1054
    // Interesting (new) part
 
1055
    // Tables of derivatives of the polynomial base (transpose)
 
1056
    static const double dmats0[10][10] = \
 
1057
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1058
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1059
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1060
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1061
    {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0},
 
1062
    {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0},
 
1063
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1064
    {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0},
 
1065
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1066
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
 
1067
    
 
1068
    static const double dmats1[10][10] = \
 
1069
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1070
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1071
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1072
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1073
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
 
1074
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
 
1075
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0},
 
1076
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
 
1077
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0},
 
1078
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
 
1079
    
 
1080
    static const double dmats2[10][10] = \
 
1081
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1082
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1083
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1084
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 
1085
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
 
1086
    {2.29128784747792, 1.44913767461894, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
 
1087
    {1.3228756555323, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},
 
1088
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
 
1089
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960223, 0, 0, 0, 0, 0, 0},
 
1090
    {-3.81881307912987, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};
 
1091
    
 
1092
    // Compute reference derivatives
 
1093
    // Declare pointer to array of derivatives on FIAT element
 
1094
    double *derivatives = new double [num_derivatives];
 
1095
    
 
1096
    // Declare coefficients
 
1097
    double coeff0_0 = 0;
 
1098
    double coeff0_1 = 0;
 
1099
    double coeff0_2 = 0;
 
1100
    double coeff0_3 = 0;
 
1101
    double coeff0_4 = 0;
 
1102
    double coeff0_5 = 0;
 
1103
    double coeff0_6 = 0;
 
1104
    double coeff0_7 = 0;
 
1105
    double coeff0_8 = 0;
 
1106
    double coeff0_9 = 0;
 
1107
    
 
1108
    // Declare new coefficients
 
1109
    double new_coeff0_0 = 0;
 
1110
    double new_coeff0_1 = 0;
 
1111
    double new_coeff0_2 = 0;
 
1112
    double new_coeff0_3 = 0;
 
1113
    double new_coeff0_4 = 0;
 
1114
    double new_coeff0_5 = 0;
 
1115
    double new_coeff0_6 = 0;
 
1116
    double new_coeff0_7 = 0;
 
1117
    double new_coeff0_8 = 0;
 
1118
    double new_coeff0_9 = 0;
 
1119
    
 
1120
    // Loop possible derivatives
 
1121
    for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)
 
1122
    {
 
1123
      // Get values from coefficients array
 
1124
      new_coeff0_0 = coefficients0[dof][0];
 
1125
      new_coeff0_1 = coefficients0[dof][1];
 
1126
      new_coeff0_2 = coefficients0[dof][2];
 
1127
      new_coeff0_3 = coefficients0[dof][3];
 
1128
      new_coeff0_4 = coefficients0[dof][4];
 
1129
      new_coeff0_5 = coefficients0[dof][5];
 
1130
      new_coeff0_6 = coefficients0[dof][6];
 
1131
      new_coeff0_7 = coefficients0[dof][7];
 
1132
      new_coeff0_8 = coefficients0[dof][8];
 
1133
      new_coeff0_9 = coefficients0[dof][9];
 
1134
    
 
1135
      // Loop derivative order
 
1136
      for (unsigned int j = 0; j < n; j++)
 
1137
      {
 
1138
        // Update old coefficients
 
1139
        coeff0_0 = new_coeff0_0;
 
1140
        coeff0_1 = new_coeff0_1;
 
1141
        coeff0_2 = new_coeff0_2;
 
1142
        coeff0_3 = new_coeff0_3;
 
1143
        coeff0_4 = new_coeff0_4;
 
1144
        coeff0_5 = new_coeff0_5;
 
1145
        coeff0_6 = new_coeff0_6;
 
1146
        coeff0_7 = new_coeff0_7;
 
1147
        coeff0_8 = new_coeff0_8;
 
1148
        coeff0_9 = new_coeff0_9;
 
1149
    
 
1150
        if(combinations[deriv_num][j] == 0)
 
1151
        {
 
1152
          new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0];
 
1153
          new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1];
 
1154
          new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2];
 
1155
          new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3];
 
1156
          new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4];
 
1157
          new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5];
 
1158
          new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6];
 
1159
          new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7];
 
1160
          new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8];
 
1161
          new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9];
 
1162
        }
 
1163
        if(combinations[deriv_num][j] == 1)
 
1164
        {
 
1165
          new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0];
 
1166
          new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1];
 
1167
          new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2];
 
1168
          new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3];
 
1169
          new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4];
 
1170
          new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5];
 
1171
          new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6];
 
1172
          new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7];
 
1173
          new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*dmats1[6][8] + coeff0_7*dmats1[7][8] + coeff0_8*dmats1[8][8] + coeff0_9*dmats1[9][8];
 
1174
          new_coeff0_9 = coeff0_0*dmats1[0][9] + coeff0_1*dmats1[1][9] + coeff0_2*dmats1[2][9] + coeff0_3*dmats1[3][9] + coeff0_4*dmats1[4][9] + coeff0_5*dmats1[5][9] + coeff0_6*dmats1[6][9] + coeff0_7*dmats1[7][9] + coeff0_8*dmats1[8][9] + coeff0_9*dmats1[9][9];
 
1175
        }
 
1176
        if(combinations[deriv_num][j] == 2)
 
1177
        {
 
1178
          new_coeff0_0 = coeff0_0*dmats2[0][0] + coeff0_1*dmats2[1][0] + coeff0_2*dmats2[2][0] + coeff0_3*dmats2[3][0] + coeff0_4*dmats2[4][0] + coeff0_5*dmats2[5][0] + coeff0_6*dmats2[6][0] + coeff0_7*dmats2[7][0] + coeff0_8*dmats2[8][0] + coeff0_9*dmats2[9][0];
 
1179
          new_coeff0_1 = coeff0_0*dmats2[0][1] + coeff0_1*dmats2[1][1] + coeff0_2*dmats2[2][1] + coeff0_3*dmats2[3][1] + coeff0_4*dmats2[4][1] + coeff0_5*dmats2[5][1] + coeff0_6*dmats2[6][1] + coeff0_7*dmats2[7][1] + coeff0_8*dmats2[8][1] + coeff0_9*dmats2[9][1];
 
1180
          new_coeff0_2 = coeff0_0*dmats2[0][2] + coeff0_1*dmats2[1][2] + coeff0_2*dmats2[2][2] + coeff0_3*dmats2[3][2] + coeff0_4*dmats2[4][2] + coeff0_5*dmats2[5][2] + coeff0_6*dmats2[6][2] + coeff0_7*dmats2[7][2] + coeff0_8*dmats2[8][2] + coeff0_9*dmats2[9][2];
 
1181
          new_coeff0_3 = coeff0_0*dmats2[0][3] + coeff0_1*dmats2[1][3] + coeff0_2*dmats2[2][3] + coeff0_3*dmats2[3][3] + coeff0_4*dmats2[4][3] + coeff0_5*dmats2[5][3] + coeff0_6*dmats2[6][3] + coeff0_7*dmats2[7][3] + coeff0_8*dmats2[8][3] + coeff0_9*dmats2[9][3];
 
1182
          new_coeff0_4 = coeff0_0*dmats2[0][4] + coeff0_1*dmats2[1][4] + coeff0_2*dmats2[2][4] + coeff0_3*dmats2[3][4] + coeff0_4*dmats2[4][4] + coeff0_5*dmats2[5][4] + coeff0_6*dmats2[6][4] + coeff0_7*dmats2[7][4] + coeff0_8*dmats2[8][4] + coeff0_9*dmats2[9][4];
 
1183
          new_coeff0_5 = coeff0_0*dmats2[0][5] + coeff0_1*dmats2[1][5] + coeff0_2*dmats2[2][5] + coeff0_3*dmats2[3][5] + coeff0_4*dmats2[4][5] + coeff0_5*dmats2[5][5] + coeff0_6*dmats2[6][5] + coeff0_7*dmats2[7][5] + coeff0_8*dmats2[8][5] + coeff0_9*dmats2[9][5];
 
1184
          new_coeff0_6 = coeff0_0*dmats2[0][6] + coeff0_1*dmats2[1][6] + coeff0_2*dmats2[2][6] + coeff0_3*dmats2[3][6] + coeff0_4*dmats2[4][6] + coeff0_5*dmats2[5][6] + coeff0_6*dmats2[6][6] + coeff0_7*dmats2[7][6] + coeff0_8*dmats2[8][6] + coeff0_9*dmats2[9][6];
 
1185
          new_coeff0_7 = coeff0_0*dmats2[0][7] + coeff0_1*dmats2[1][7] + coeff0_2*dmats2[2][7] + coeff0_3*dmats2[3][7] + coeff0_4*dmats2[4][7] + coeff0_5*dmats2[5][7] + coeff0_6*dmats2[6][7] + coeff0_7*dmats2[7][7] + coeff0_8*dmats2[8][7] + coeff0_9*dmats2[9][7];
 
1186
          new_coeff0_8 = coeff0_0*dmats2[0][8] + coeff0_1*dmats2[1][8] + coeff0_2*dmats2[2][8] + coeff0_3*dmats2[3][8] + coeff0_4*dmats2[4][8] + coeff0_5*dmats2[5][8] + coeff0_6*dmats2[6][8] + coeff0_7*dmats2[7][8] + coeff0_8*dmats2[8][8] + coeff0_9*dmats2[9][8];
 
1187
          new_coeff0_9 = coeff0_0*dmats2[0][9] + coeff0_1*dmats2[1][9] + coeff0_2*dmats2[2][9] + coeff0_3*dmats2[3][9] + coeff0_4*dmats2[4][9] + coeff0_5*dmats2[5][9] + coeff0_6*dmats2[6][9] + coeff0_7*dmats2[7][9] + coeff0_8*dmats2[8][9] + coeff0_9*dmats2[9][9];
 
1188
        }
 
1189
    
 
1190
      }
 
1191
      // Compute derivatives on reference element as dot product of coefficients and basisvalues
 
1192
      derivatives[deriv_num] = new_coeff0_0*basisvalue0 + new_coeff0_1*basisvalue1 + new_coeff0_2*basisvalue2 + new_coeff0_3*basisvalue3 + new_coeff0_4*basisvalue4 + new_coeff0_5*basisvalue5 + new_coeff0_6*basisvalue6 + new_coeff0_7*basisvalue7 + new_coeff0_8*basisvalue8 + new_coeff0_9*basisvalue9;
 
1193
    }
 
1194
    
 
1195
    // Transform derivatives back to physical element
 
1196
    for (unsigned int row = 0; row < num_derivatives; row++)
 
1197
    {
 
1198
      for (unsigned int col = 0; col < num_derivatives; col++)
 
1199
      {
 
1200
        values[row] += transform[row][col]*derivatives[col];
 
1201
      }
 
1202
    }
 
1203
    // Delete pointer to array of derivatives on FIAT element
 
1204
    delete [] derivatives;
 
1205
    
 
1206
    // Delete pointer to array of combinations of derivatives and transform
 
1207
    for (unsigned int row = 0; row < num_derivatives; row++)
 
1208
    {
 
1209
      delete [] combinations[row];
 
1210
      delete [] transform[row];
 
1211
    }
 
1212
    
 
1213
    delete [] combinations;
 
1214
    delete [] transform;
 
1215
  }
 
1216
 
 
1217
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
1218
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
1219
                                              double* values,
 
1220
                                              const double* coordinates,
 
1221
                                              const ufc::cell& c) const
 
1222
  {
 
1223
    throw std::runtime_error("The vectorised version of evaluate_basis_derivatives() is not yet implemented.");
 
1224
  }
 
1225
 
 
1226
  /// Evaluate linear functional for dof i on the function f
 
1227
  virtual double evaluate_dof(unsigned int i,
 
1228
                              const ufc::function& f,
 
1229
                              const ufc::cell& c) const
 
1230
  {
 
1231
    // The reference points, direction and weights:
 
1232
    static const double X[10][1][3] = {{{0, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0.5, 0.5}}, {{0.5, 0, 0.5}}, {{0.5, 0.5, 0}}, {{0, 0, 0.5}}, {{0, 0.5, 0}}, {{0.5, 0, 0}}};
 
1233
    static const double W[10][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
 
1234
    static const double D[10][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
 
1235
    
 
1236
    const double * const * x = c.coordinates;
 
1237
    double result = 0.0;
 
1238
    // Iterate over the points:
 
1239
    // Evaluate basis functions for affine mapping
 
1240
    const double w0 = 1.0 - X[i][0][0] - X[i][0][1] - X[i][0][2];
 
1241
    const double w1 = X[i][0][0];
 
1242
    const double w2 = X[i][0][1];
 
1243
    const double w3 = X[i][0][2];
 
1244
    
 
1245
    // Compute affine mapping y = F(X)
 
1246
    double y[3];
 
1247
    y[0] = w0*x[0][0] + w1*x[1][0] + w2*x[2][0] + w3*x[3][0];
 
1248
    y[1] = w0*x[0][1] + w1*x[1][1] + w2*x[2][1] + w3*x[3][1];
 
1249
    y[2] = w0*x[0][2] + w1*x[1][2] + w2*x[2][2] + w3*x[3][2];
 
1250
    
 
1251
    // Evaluate function at physical points
 
1252
    double values[1];
 
1253
    f.evaluate(values, y, c);
 
1254
    
 
1255
    // Map function values using appropriate mapping
 
1256
    // Affine map: Do nothing
 
1257
    
 
1258
    // Note that we do not map the weights (yet).
 
1259
    
 
1260
    // Take directional components
 
1261
    for(int k = 0; k < 1; k++)
 
1262
      result += values[k]*D[i][0][k];
 
1263
    // Multiply by weights
 
1264
    result *= W[i][0];
 
1265
    
 
1266
    return result;
 
1267
  }
 
1268
 
 
1269
  /// Evaluate linear functionals for all dofs on the function f
 
1270
  virtual void evaluate_dofs(double* values,
 
1271
                             const ufc::function& f,
 
1272
                             const ufc::cell& c) const
 
1273
  {
 
1274
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
1275
  }
 
1276
 
 
1277
  /// Interpolate vertex values from dof values
 
1278
  virtual void interpolate_vertex_values(double* vertex_values,
 
1279
                                         const double* dof_values,
 
1280
                                         const ufc::cell& c) const
 
1281
  {
 
1282
    // Evaluate at vertices and use affine mapping
 
1283
    vertex_values[0] = dof_values[0];
 
1284
    vertex_values[1] = dof_values[1];
 
1285
    vertex_values[2] = dof_values[2];
 
1286
    vertex_values[3] = dof_values[3];
 
1287
  }
 
1288
 
 
1289
  /// Return the number of sub elements (for a mixed element)
 
1290
  virtual unsigned int num_sub_elements() const
 
1291
  {
 
1292
    return 1;
 
1293
  }
 
1294
 
 
1295
  /// Create a new finite element for sub element i (for a mixed element)
 
1296
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
1297
  {
 
1298
    return new projection_0_finite_element_1();
 
1299
  }
 
1300
 
 
1301
};
 
1302
 
 
1303
/// This class defines the interface for a local-to-global mapping of
 
1304
/// degrees of freedom (dofs).
 
1305
 
 
1306
class projection_0_dof_map_0: public ufc::dof_map
 
1307
{
 
1308
private:
 
1309
 
 
1310
  unsigned int __global_dimension;
 
1311
 
 
1312
public:
 
1313
 
 
1314
  /// Constructor
 
1315
  projection_0_dof_map_0() : ufc::dof_map()
 
1316
  {
 
1317
    __global_dimension = 0;
 
1318
  }
 
1319
 
 
1320
  /// Destructor
 
1321
  virtual ~projection_0_dof_map_0()
 
1322
  {
 
1323
    // Do nothing
 
1324
  }
 
1325
 
 
1326
  /// Return a string identifying the dof map
 
1327
  virtual const char* signature() const
 
1328
  {
 
1329
    return "FFC dof map for FiniteElement('Lagrange', 'tetrahedron', 2)";
 
1330
  }
 
1331
 
 
1332
  /// Return true iff mesh entities of topological dimension d are needed
 
1333
  virtual bool needs_mesh_entities(unsigned int d) const
 
1334
  {
 
1335
    switch ( d )
 
1336
    {
 
1337
    case 0:
 
1338
      return true;
 
1339
      break;
 
1340
    case 1:
 
1341
      return true;
 
1342
      break;
 
1343
    case 2:
 
1344
      return false;
 
1345
      break;
 
1346
    case 3:
 
1347
      return false;
 
1348
      break;
 
1349
    }
 
1350
    return false;
 
1351
  }
 
1352
 
 
1353
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
1354
  virtual bool init_mesh(const ufc::mesh& m)
 
1355
  {
 
1356
    __global_dimension = m.num_entities[0] + m.num_entities[1];
 
1357
    return false;
 
1358
  }
 
1359
 
 
1360
  /// Initialize dof map for given cell
 
1361
  virtual void init_cell(const ufc::mesh& m,
 
1362
                         const ufc::cell& c)
 
1363
  {
 
1364
    // Do nothing
 
1365
  }
 
1366
 
 
1367
  /// Finish initialization of dof map for cells
 
1368
  virtual void init_cell_finalize()
 
1369
  {
 
1370
    // Do nothing
 
1371
  }
 
1372
 
 
1373
  /// Return the dimension of the global finite element function space
 
1374
  virtual unsigned int global_dimension() const
 
1375
  {
 
1376
    return __global_dimension;
 
1377
  }
 
1378
 
 
1379
  /// Return the dimension of the local finite element function space for a cell
 
1380
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
1381
  {
 
1382
    return 10;
 
1383
  }
 
1384
 
 
1385
  /// Return the maximum dimension of the local finite element function space
 
1386
  virtual unsigned int max_local_dimension() const
 
1387
  {
 
1388
    return 10;
 
1389
  }
 
1390
 
 
1391
  // Return the geometric dimension of the coordinates this dof map provides
 
1392
  virtual unsigned int geometric_dimension() const
 
1393
  {
 
1394
    return 3;
 
1395
  }
 
1396
 
 
1397
  /// Return the number of dofs on each cell facet
 
1398
  virtual unsigned int num_facet_dofs() const
 
1399
  {
 
1400
    return 6;
 
1401
  }
 
1402
 
 
1403
  /// Return the number of dofs associated with each cell entity of dimension d
 
1404
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
1405
  {
 
1406
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
1407
  }
 
1408
 
 
1409
  /// Tabulate the local-to-global mapping of dofs on a cell
 
1410
  virtual void tabulate_dofs(unsigned int* dofs,
 
1411
                             const ufc::mesh& m,
 
1412
                             const ufc::cell& c) const
 
1413
  {
 
1414
    dofs[0] = c.entity_indices[0][0];
 
1415
    dofs[1] = c.entity_indices[0][1];
 
1416
    dofs[2] = c.entity_indices[0][2];
 
1417
    dofs[3] = c.entity_indices[0][3];
 
1418
    unsigned int offset = m.num_entities[0];
 
1419
    dofs[4] = offset + c.entity_indices[1][0];
 
1420
    dofs[5] = offset + c.entity_indices[1][1];
 
1421
    dofs[6] = offset + c.entity_indices[1][2];
 
1422
    dofs[7] = offset + c.entity_indices[1][3];
 
1423
    dofs[8] = offset + c.entity_indices[1][4];
 
1424
    dofs[9] = offset + c.entity_indices[1][5];
 
1425
  }
 
1426
 
 
1427
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
1428
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
1429
                                   unsigned int facet) const
 
1430
  {
 
1431
    switch ( facet )
 
1432
    {
 
1433
    case 0:
 
1434
      dofs[0] = 1;
 
1435
      dofs[1] = 2;
 
1436
      dofs[2] = 3;
 
1437
      dofs[3] = 4;
 
1438
      dofs[4] = 5;
 
1439
      dofs[5] = 6;
 
1440
      break;
 
1441
    case 1:
 
1442
      dofs[0] = 0;
 
1443
      dofs[1] = 2;
 
1444
      dofs[2] = 3;
 
1445
      dofs[3] = 4;
 
1446
      dofs[4] = 7;
 
1447
      dofs[5] = 8;
 
1448
      break;
 
1449
    case 2:
 
1450
      dofs[0] = 0;
 
1451
      dofs[1] = 1;
 
1452
      dofs[2] = 3;
 
1453
      dofs[3] = 5;
 
1454
      dofs[4] = 7;
 
1455
      dofs[5] = 9;
 
1456
      break;
 
1457
    case 3:
 
1458
      dofs[0] = 0;
 
1459
      dofs[1] = 1;
 
1460
      dofs[2] = 2;
 
1461
      dofs[3] = 6;
 
1462
      dofs[4] = 8;
 
1463
      dofs[5] = 9;
 
1464
      break;
 
1465
    }
 
1466
  }
 
1467
 
 
1468
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
1469
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
1470
                                    unsigned int d, unsigned int i) const
 
1471
  {
 
1472
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
1473
  }
 
1474
 
 
1475
  /// Tabulate the coordinates of all dofs on a cell
 
1476
  virtual void tabulate_coordinates(double** coordinates,
 
1477
                                    const ufc::cell& c) const
 
1478
  {
 
1479
    const double * const * x = c.coordinates;
 
1480
    coordinates[0][0] = x[0][0];
 
1481
    coordinates[0][1] = x[0][1];
 
1482
    coordinates[0][2] = x[0][2];
 
1483
    coordinates[1][0] = x[1][0];
 
1484
    coordinates[1][1] = x[1][1];
 
1485
    coordinates[1][2] = x[1][2];
 
1486
    coordinates[2][0] = x[2][0];
 
1487
    coordinates[2][1] = x[2][1];
 
1488
    coordinates[2][2] = x[2][2];
 
1489
    coordinates[3][0] = x[3][0];
 
1490
    coordinates[3][1] = x[3][1];
 
1491
    coordinates[3][2] = x[3][2];
 
1492
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
1493
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
1494
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
1495
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
1496
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
1497
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
1498
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
1499
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
1500
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
1501
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
1502
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
1503
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
1504
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
1505
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
1506
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
1507
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
1508
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
1509
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
1510
  }
 
1511
 
 
1512
  /// Return the number of sub dof maps (for a mixed element)
 
1513
  virtual unsigned int num_sub_dof_maps() const
 
1514
  {
 
1515
    return 1;
 
1516
  }
 
1517
 
 
1518
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
1519
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
1520
  {
 
1521
    return new projection_0_dof_map_0();
 
1522
  }
 
1523
 
 
1524
};
 
1525
 
 
1526
/// This class defines the interface for a local-to-global mapping of
 
1527
/// degrees of freedom (dofs).
 
1528
 
 
1529
class projection_0_dof_map_1: public ufc::dof_map
 
1530
{
 
1531
private:
 
1532
 
 
1533
  unsigned int __global_dimension;
 
1534
 
 
1535
public:
 
1536
 
 
1537
  /// Constructor
 
1538
  projection_0_dof_map_1() : ufc::dof_map()
 
1539
  {
 
1540
    __global_dimension = 0;
 
1541
  }
 
1542
 
 
1543
  /// Destructor
 
1544
  virtual ~projection_0_dof_map_1()
 
1545
  {
 
1546
    // Do nothing
 
1547
  }
 
1548
 
 
1549
  /// Return a string identifying the dof map
 
1550
  virtual const char* signature() const
 
1551
  {
 
1552
    return "FFC dof map for FiniteElement('Lagrange', 'tetrahedron', 2)";
 
1553
  }
 
1554
 
 
1555
  /// Return true iff mesh entities of topological dimension d are needed
 
1556
  virtual bool needs_mesh_entities(unsigned int d) const
 
1557
  {
 
1558
    switch ( d )
 
1559
    {
 
1560
    case 0:
 
1561
      return true;
 
1562
      break;
 
1563
    case 1:
 
1564
      return true;
 
1565
      break;
 
1566
    case 2:
 
1567
      return false;
 
1568
      break;
 
1569
    case 3:
 
1570
      return false;
 
1571
      break;
 
1572
    }
 
1573
    return false;
 
1574
  }
 
1575
 
 
1576
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
1577
  virtual bool init_mesh(const ufc::mesh& m)
 
1578
  {
 
1579
    __global_dimension = m.num_entities[0] + m.num_entities[1];
 
1580
    return false;
 
1581
  }
 
1582
 
 
1583
  /// Initialize dof map for given cell
 
1584
  virtual void init_cell(const ufc::mesh& m,
 
1585
                         const ufc::cell& c)
 
1586
  {
 
1587
    // Do nothing
 
1588
  }
 
1589
 
 
1590
  /// Finish initialization of dof map for cells
 
1591
  virtual void init_cell_finalize()
 
1592
  {
 
1593
    // Do nothing
 
1594
  }
 
1595
 
 
1596
  /// Return the dimension of the global finite element function space
 
1597
  virtual unsigned int global_dimension() const
 
1598
  {
 
1599
    return __global_dimension;
 
1600
  }
 
1601
 
 
1602
  /// Return the dimension of the local finite element function space for a cell
 
1603
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
1604
  {
 
1605
    return 10;
 
1606
  }
 
1607
 
 
1608
  /// Return the maximum dimension of the local finite element function space
 
1609
  virtual unsigned int max_local_dimension() const
 
1610
  {
 
1611
    return 10;
 
1612
  }
 
1613
 
 
1614
  // Return the geometric dimension of the coordinates this dof map provides
 
1615
  virtual unsigned int geometric_dimension() const
 
1616
  {
 
1617
    return 3;
 
1618
  }
 
1619
 
 
1620
  /// Return the number of dofs on each cell facet
 
1621
  virtual unsigned int num_facet_dofs() const
 
1622
  {
 
1623
    return 6;
 
1624
  }
 
1625
 
 
1626
  /// Return the number of dofs associated with each cell entity of dimension d
 
1627
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
1628
  {
 
1629
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
1630
  }
 
1631
 
 
1632
  /// Tabulate the local-to-global mapping of dofs on a cell
 
1633
  virtual void tabulate_dofs(unsigned int* dofs,
 
1634
                             const ufc::mesh& m,
 
1635
                             const ufc::cell& c) const
 
1636
  {
 
1637
    dofs[0] = c.entity_indices[0][0];
 
1638
    dofs[1] = c.entity_indices[0][1];
 
1639
    dofs[2] = c.entity_indices[0][2];
 
1640
    dofs[3] = c.entity_indices[0][3];
 
1641
    unsigned int offset = m.num_entities[0];
 
1642
    dofs[4] = offset + c.entity_indices[1][0];
 
1643
    dofs[5] = offset + c.entity_indices[1][1];
 
1644
    dofs[6] = offset + c.entity_indices[1][2];
 
1645
    dofs[7] = offset + c.entity_indices[1][3];
 
1646
    dofs[8] = offset + c.entity_indices[1][4];
 
1647
    dofs[9] = offset + c.entity_indices[1][5];
 
1648
  }
 
1649
 
 
1650
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
1651
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
1652
                                   unsigned int facet) const
 
1653
  {
 
1654
    switch ( facet )
 
1655
    {
 
1656
    case 0:
 
1657
      dofs[0] = 1;
 
1658
      dofs[1] = 2;
 
1659
      dofs[2] = 3;
 
1660
      dofs[3] = 4;
 
1661
      dofs[4] = 5;
 
1662
      dofs[5] = 6;
 
1663
      break;
 
1664
    case 1:
 
1665
      dofs[0] = 0;
 
1666
      dofs[1] = 2;
 
1667
      dofs[2] = 3;
 
1668
      dofs[3] = 4;
 
1669
      dofs[4] = 7;
 
1670
      dofs[5] = 8;
 
1671
      break;
 
1672
    case 2:
 
1673
      dofs[0] = 0;
 
1674
      dofs[1] = 1;
 
1675
      dofs[2] = 3;
 
1676
      dofs[3] = 5;
 
1677
      dofs[4] = 7;
 
1678
      dofs[5] = 9;
 
1679
      break;
 
1680
    case 3:
 
1681
      dofs[0] = 0;
 
1682
      dofs[1] = 1;
 
1683
      dofs[2] = 2;
 
1684
      dofs[3] = 6;
 
1685
      dofs[4] = 8;
 
1686
      dofs[5] = 9;
 
1687
      break;
 
1688
    }
 
1689
  }
 
1690
 
 
1691
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
1692
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
1693
                                    unsigned int d, unsigned int i) const
 
1694
  {
 
1695
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
1696
  }
 
1697
 
 
1698
  /// Tabulate the coordinates of all dofs on a cell
 
1699
  virtual void tabulate_coordinates(double** coordinates,
 
1700
                                    const ufc::cell& c) const
 
1701
  {
 
1702
    const double * const * x = c.coordinates;
 
1703
    coordinates[0][0] = x[0][0];
 
1704
    coordinates[0][1] = x[0][1];
 
1705
    coordinates[0][2] = x[0][2];
 
1706
    coordinates[1][0] = x[1][0];
 
1707
    coordinates[1][1] = x[1][1];
 
1708
    coordinates[1][2] = x[1][2];
 
1709
    coordinates[2][0] = x[2][0];
 
1710
    coordinates[2][1] = x[2][1];
 
1711
    coordinates[2][2] = x[2][2];
 
1712
    coordinates[3][0] = x[3][0];
 
1713
    coordinates[3][1] = x[3][1];
 
1714
    coordinates[3][2] = x[3][2];
 
1715
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
1716
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
1717
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
1718
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
1719
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
1720
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
1721
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
1722
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
1723
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
1724
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
1725
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
1726
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
1727
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
1728
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
1729
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
1730
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
1731
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
1732
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
1733
  }
 
1734
 
 
1735
  /// Return the number of sub dof maps (for a mixed element)
 
1736
  virtual unsigned int num_sub_dof_maps() const
 
1737
  {
 
1738
    return 1;
 
1739
  }
 
1740
 
 
1741
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
1742
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
1743
  {
 
1744
    return new projection_0_dof_map_1();
1733
1745
  }
1734
1746
 
1735
1747
};
1738
1750
/// tensor corresponding to the local contribution to a form from
1739
1751
/// the integral over a cell.
1740
1752
 
1741
 
class UFC_ProjectionBilinearForm_cell_integral_0: public ufc::cell_integral
 
1753
class projection_0_cell_integral_0_quadrature: public ufc::cell_integral
1742
1754
{
1743
1755
public:
1744
1756
 
1745
1757
  /// Constructor
1746
 
  UFC_ProjectionBilinearForm_cell_integral_0() : ufc::cell_integral()
 
1758
  projection_0_cell_integral_0_quadrature() : ufc::cell_integral()
1747
1759
  {
1748
1760
    // Do nothing
1749
1761
  }
1750
1762
 
1751
1763
  /// Destructor
1752
 
  virtual ~UFC_ProjectionBilinearForm_cell_integral_0()
 
1764
  virtual ~projection_0_cell_integral_0_quadrature()
1753
1765
  {
1754
1766
    // Do nothing
1755
1767
  }
1772
1784
    const double J_20 = x[1][2] - x[0][2];
1773
1785
    const double J_21 = x[2][2] - x[0][2];
1774
1786
    const double J_22 = x[3][2] - x[0][2];
1775
 
      
 
1787
    
1776
1788
    // Compute sub determinants
1777
1789
    const double d_00 = J_11*J_22 - J_12*J_21;
1778
1790
    
1779
1791
    const double d_10 = J_02*J_21 - J_01*J_22;
1780
1792
    
1781
1793
    const double d_20 = J_01*J_12 - J_02*J_11;
1782
 
      
 
1794
    
1783
1795
    // Compute determinant of Jacobian
1784
1796
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
1785
 
      
 
1797
    
1786
1798
    // Compute inverse of Jacobian
1787
1799
    
1788
1800
    // Set scale factor
1789
1801
    const double det = std::abs(detJ);
1790
1802
    
1791
 
    // Number of operations to compute element tensor = 101
1792
 
    // Compute geometry tensors
1793
 
    // Number of operations to compute decalrations = 1
1794
 
    const double G0_ = det;
1795
 
    
1796
 
    // Compute element tensor
1797
 
    // Number of operations to compute tensor = 100
1798
 
    A[0] = 0.00238095238095237*G0_;
1799
 
    A[1] = 0.000396825396825395*G0_;
1800
 
    A[2] = 0.000396825396825396*G0_;
1801
 
    A[3] = 0.000396825396825396*G0_;
1802
 
    A[4] = -0.00238095238095238*G0_;
1803
 
    A[5] = -0.00238095238095238*G0_;
1804
 
    A[6] = -0.00238095238095238*G0_;
1805
 
    A[7] = -0.00158730158730158*G0_;
1806
 
    A[8] = -0.00158730158730158*G0_;
1807
 
    A[9] = -0.00158730158730158*G0_;
1808
 
    A[10] = 0.000396825396825395*G0_;
1809
 
    A[11] = 0.00238095238095238*G0_;
1810
 
    A[12] = 0.000396825396825396*G0_;
1811
 
    A[13] = 0.000396825396825396*G0_;
1812
 
    A[14] = -0.00238095238095238*G0_;
1813
 
    A[15] = -0.00158730158730158*G0_;
1814
 
    A[16] = -0.00158730158730158*G0_;
1815
 
    A[17] = -0.00238095238095237*G0_;
1816
 
    A[18] = -0.00238095238095237*G0_;
1817
 
    A[19] = -0.00158730158730158*G0_;
1818
 
    A[20] = 0.000396825396825396*G0_;
1819
 
    A[21] = 0.000396825396825396*G0_;
1820
 
    A[22] = 0.00238095238095238*G0_;
1821
 
    A[23] = 0.000396825396825398*G0_;
1822
 
    A[24] = -0.00158730158730159*G0_;
1823
 
    A[25] = -0.00238095238095238*G0_;
1824
 
    A[26] = -0.00158730158730159*G0_;
1825
 
    A[27] = -0.00238095238095238*G0_;
1826
 
    A[28] = -0.00158730158730159*G0_;
1827
 
    A[29] = -0.00238095238095238*G0_;
1828
 
    A[30] = 0.000396825396825397*G0_;
1829
 
    A[31] = 0.000396825396825396*G0_;
1830
 
    A[32] = 0.000396825396825398*G0_;
1831
 
    A[33] = 0.00238095238095238*G0_;
1832
 
    A[34] = -0.00158730158730159*G0_;
1833
 
    A[35] = -0.00158730158730159*G0_;
1834
 
    A[36] = -0.00238095238095238*G0_;
1835
 
    A[37] = -0.00158730158730159*G0_;
1836
 
    A[38] = -0.00238095238095238*G0_;
1837
 
    A[39] = -0.00238095238095238*G0_;
1838
 
    A[40] = -0.00238095238095238*G0_;
1839
 
    A[41] = -0.00238095238095237*G0_;
1840
 
    A[42] = -0.00158730158730159*G0_;
1841
 
    A[43] = -0.00158730158730159*G0_;
1842
 
    A[44] = 0.0126984126984127*G0_;
1843
 
    A[45] = 0.00634920634920634*G0_;
1844
 
    A[46] = 0.00634920634920635*G0_;
1845
 
    A[47] = 0.00634920634920634*G0_;
1846
 
    A[48] = 0.00634920634920634*G0_;
1847
 
    A[49] = 0.00317460317460317*G0_;
1848
 
    A[50] = -0.00238095238095238*G0_;
1849
 
    A[51] = -0.00158730158730158*G0_;
1850
 
    A[52] = -0.00238095238095238*G0_;
1851
 
    A[53] = -0.00158730158730159*G0_;
1852
 
    A[54] = 0.00634920634920634*G0_;
1853
 
    A[55] = 0.0126984126984127*G0_;
1854
 
    A[56] = 0.00634920634920635*G0_;
1855
 
    A[57] = 0.00634920634920634*G0_;
1856
 
    A[58] = 0.00317460317460317*G0_;
1857
 
    A[59] = 0.00634920634920634*G0_;
1858
 
    A[60] = -0.00238095238095238*G0_;
1859
 
    A[61] = -0.00158730158730158*G0_;
1860
 
    A[62] = -0.00158730158730159*G0_;
1861
 
    A[63] = -0.00238095238095238*G0_;
1862
 
    A[64] = 0.00634920634920635*G0_;
1863
 
    A[65] = 0.00634920634920635*G0_;
1864
 
    A[66] = 0.0126984126984127*G0_;
1865
 
    A[67] = 0.00317460317460317*G0_;
1866
 
    A[68] = 0.00634920634920634*G0_;
1867
 
    A[69] = 0.00634920634920634*G0_;
1868
 
    A[70] = -0.00158730158730158*G0_;
1869
 
    A[71] = -0.00238095238095237*G0_;
1870
 
    A[72] = -0.00238095238095238*G0_;
1871
 
    A[73] = -0.00158730158730159*G0_;
1872
 
    A[74] = 0.00634920634920634*G0_;
1873
 
    A[75] = 0.00634920634920634*G0_;
1874
 
    A[76] = 0.00317460317460317*G0_;
1875
 
    A[77] = 0.0126984126984127*G0_;
1876
 
    A[78] = 0.00634920634920634*G0_;
1877
 
    A[79] = 0.00634920634920633*G0_;
1878
 
    A[80] = -0.00158730158730158*G0_;
1879
 
    A[81] = -0.00238095238095237*G0_;
1880
 
    A[82] = -0.00158730158730159*G0_;
1881
 
    A[83] = -0.00238095238095238*G0_;
1882
 
    A[84] = 0.00634920634920634*G0_;
1883
 
    A[85] = 0.00317460317460317*G0_;
1884
 
    A[86] = 0.00634920634920634*G0_;
1885
 
    A[87] = 0.00634920634920634*G0_;
1886
 
    A[88] = 0.0126984126984127*G0_;
1887
 
    A[89] = 0.00634920634920634*G0_;
1888
 
    A[90] = -0.00158730158730158*G0_;
1889
 
    A[91] = -0.00158730158730158*G0_;
1890
 
    A[92] = -0.00238095238095238*G0_;
1891
 
    A[93] = -0.00238095238095238*G0_;
1892
 
    A[94] = 0.00317460317460317*G0_;
1893
 
    A[95] = 0.00634920634920634*G0_;
1894
 
    A[96] = 0.00634920634920634*G0_;
1895
 
    A[97] = 0.00634920634920633*G0_;
1896
 
    A[98] = 0.00634920634920634*G0_;
1897
 
    A[99] = 0.0126984126984127*G0_;
 
1803
    
 
1804
    // Array of quadrature weights
 
1805
    static const double W27[27] = {0.00877047492965105, 0.00816265076654668, 0.0016716811314837, 0.0100061425721761, 0.00931268237947044, 0.00190720341498178, 0.00304787709051818, 0.00283664869563092, 0.000580935315837384, 0.0140327598874417, 0.0130602412264747, 0.00267468981037392, 0.0160098281154818, 0.0149002918071527, 0.00305152546397085, 0.0048766033448291, 0.00453863791300947, 0.000929496505339815, 0.00877047492965105, 0.00816265076654668, 0.0016716811314837, 0.0100061425721761, 0.00931268237947044, 0.00190720341498178, 0.00304787709051818, 0.00283664869563092, 0.000580935315837384};
 
1806
    // Quadrature points on the UFC reference element: (0.0952198798417149, 0.0821215678634425, 0.0729940240731498), (0.0670742417520586, 0.0578476039361427, 0.347003766038352), (0.0303014811742758, 0.0261332522867349, 0.705002209888498), (0.0616960186091465, 0.379578230280591, 0.0729940240731498), (0.0434595556538024, 0.267380320411884, 0.347003766038352), (0.0196333029354845, 0.120791820133903, 0.705002209888498), (0.0221843026408197, 0.730165028047632, 0.0729940240731498), (0.0156269392579017, 0.514338662174092, 0.347003766038352), (0.00705963113955477, 0.232357800579865, 0.705002209888498), (0.422442204031704, 0.0821215678634425, 0.0729940240731498), (0.297574315012753, 0.0578476039361427, 0.347003766038352), (0.134432268912383, 0.0261332522867349, 0.705002209888498), (0.27371387282313, 0.379578230280591, 0.0729940240731498), (0.192807956774882, 0.267380320411884, 0.347003766038352), (0.0871029849887995, 0.120791820133903, 0.705002209888498), (0.0984204739396093, 0.730165028047632, 0.0729940240731498), (0.0693287858937781, 0.514338662174092, 0.347003766038352), (0.0313199947658185, 0.232357800579865, 0.705002209888498), (0.749664528221693, 0.0821215678634425, 0.0729940240731498), (0.528074388273447, 0.0578476039361427, 0.347003766038352), (0.238563056650491, 0.0261332522867349, 0.705002209888498), (0.485731727037113, 0.379578230280591, 0.0729940240731498), (0.342156357895961, 0.267380320411884, 0.347003766038352), (0.154572667042115, 0.120791820133903, 0.705002209888498), (0.174656645238399, 0.730165028047632, 0.0729940240731498), (0.123030632529655, 0.514338662174092, 0.347003766038352), (0.0555803583920821, 0.232357800579865, 0.705002209888498)
 
1807
    
 
1808
    // Value of basis functions at quadrature points.
 
1809
    static const double FE0[27][10] = \
 
1810
    {{0.374329281526014, -0.0770862288075737, -0.0686336640467425, -0.0623377689723666, 0.0239775348061957, 0.0278019288056343, 0.031278423297481, 0.218884122479203, 0.246254505716693, 0.285531865195462},
 
1811
    {0.0296507308273033, -0.0580763339388314, -0.051154913373837, -0.106180538748753, 0.0802933456885461, 0.0931000579685248, 0.0155203366847607, 0.73297520591714, 0.122191352246653, 0.141680756728494},
 
1812
    {-0.12473839265364, -0.0284651216515658, -0.0247673585365706, 0.289054022006834, 0.073696002454887, 0.0854504447630366, 0.00316750500875638, 0.672749928545405, 0.0249377141829676, 0.0289152558798901},
 
1813
    {-0.0138611057361999, -0.0540832211847061, -0.0914189644747004, -0.0623377689723666, 0.11082776991498, 0.0180137626702941, 0.0936738622360728, 0.141822053505759, 0.737492757359529, 0.119870854681338},
 
1814
    {-0.108014411398703, -0.0396820896985505, -0.12439584892476, -0.106180538748753, 0.37112791258986, 0.0603225179288912, 0.0464809196626873, 0.474918179055459, 0.365943506420742, 0.0594798531131275},
 
1815
    {-0.10678724824909, -0.0188623697671714, -0.0916104925113804, 0.289054022006834, 0.340634000523421, 0.0553660878277077, 0.00948616958726985, 0.435896287412199, 0.0746844551798748, 0.0121390879903345},
 
1816
    {-0.113646757786535, -0.0212000160735007, 0.336116908319966, -0.0623377689723666, 0.213190734538724, 0.00647728608404013, 0.0647928078398051, 0.050995565468269, 0.510112697076803, 0.0154985435047957},
 
1817
    {-0.0927575594483608, -0.0151385367967613, 0.0147498566399773, -0.106180538748753, 0.71390981117415, 0.0216904270965778, 0.0321501561271397, 0.170768371303483, 0.253117643766939, 0.00769036888560855},
 
1818
    {-0.0494020059140976, -0.0069599543559016, -0.12437750559924, 0.289054022006834, 0.655251051574542, 0.0199082222175352, 0.00656144145796827, 0.156737101971251, 0.0516581193256993, 0.00156950731540946},
 
1819
    {-0.0655273725373765, -0.0655273725373763, -0.0686336640467425, -0.0623377689723666, 0.0239775348061957, 0.123343025642419, 0.138766464507087, 0.123343025642418, 0.138766464507087, 0.713829662988655},
 
1820
    {-0.120473369102135, -0.120473369102135, -0.051154913373837, -0.106180538748753, 0.080293345688546, 0.413037631942832, 0.0688558444657068, 0.413037631942832, 0.0688558444657067, 0.354201891821236},
 
1821
    {-0.0982881990625207, -0.0982881990625206, -0.0247673585365706, 0.289054022006834, 0.073696002454887, 0.379100186654221, 0.014052609595862, 0.379100186654221, 0.014052609595862, 0.0722881396997254},
 
1822
    {-0.123875304471457, -0.123875304471457, -0.0914189644747004, -0.0623377689723666, 0.11082776991498, 0.0799179080880264, 0.415583309797801, 0.0799179080880263, 0.415583309797801, 0.299677136703346},
 
1823
    {-0.118458140383472, -0.118458140383472, -0.12439584892476, -0.106180538748753, 0.37112791258986, 0.267620348492175, 0.206212213041715, 0.267620348492175, 0.206212213041715, 0.148699632782819},
 
1824
    {-0.0719291250008815, -0.0719291250008814, -0.0916104925113804, 0.289054022006834, 0.340634000523421, 0.245631187619954, 0.0420853123835723, 0.245631187619953, 0.0420853123835723, 0.0303477199758362},
 
1825
    {-0.0790472945586147, -0.0790472945586147, 0.336116908319966, -0.0623377689723666, 0.213190734538724, 0.0287364257761546, 0.287452752458304, 0.0287364257761545, 0.287452752458304, 0.0387463587619893},
 
1826
    {-0.0597158247867675, -0.0597158247867675, 0.0147498566399773, -0.106180538748753, 0.71390981117415, 0.0962293992000304, 0.14263389994704, 0.0962293992000302, 0.142633899947039, 0.0192259222140213},
 
1827
    {-0.0293581106215567, -0.0293581106215567, -0.12437750559924, 0.289054022006834, 0.655251051574542, 0.088322662094393, 0.0291097803918338, 0.088322662094393, 0.0291097803918338, 0.00392376828852362},
 
1828
    {-0.0770862288075737, 0.374329281526014, -0.0686336640467425, -0.0623377689723666, 0.0239775348061957, 0.218884122479203, 0.246254505716693, 0.0278019288056342, 0.031278423297481, 0.285531865195462},
 
1829
    {-0.0580763339388313, 0.0296507308273035, -0.0511549133738371, -0.106180538748753, 0.080293345688546, 0.73297520591714, 0.122191352246653, 0.0931000579685245, 0.0155203366847607, 0.141680756728494},
 
1830
    {-0.0284651216515658, -0.12473839265364, -0.0247673585365706, 0.289054022006834, 0.0736960024548869, 0.672749928545405, 0.0249377141829676, 0.0854504447630365, 0.00316750500875635, 0.0289152558798901},
 
1831
    {-0.0540832211847061, -0.0138611057361997, -0.0914189644747005, -0.0623377689723666, 0.11082776991498, 0.141822053505759, 0.737492757359529, 0.018013762670294, 0.0936738622360726, 0.119870854681338},
 
1832
    {-0.0396820896985505, -0.108014411398703, -0.12439584892476, -0.106180538748753, 0.37112791258986, 0.474918179055459, 0.365943506420742, 0.060322517928891, 0.0464809196626872, 0.0594798531131274},
 
1833
    {-0.0188623697671715, -0.10678724824909, -0.0916104925113804, 0.289054022006834, 0.340634000523421, 0.435896287412199, 0.0746844551798748, 0.0553660878277076, 0.00948616958726982, 0.0121390879903345},
 
1834
    {-0.0212000160735008, -0.113646757786535, 0.336116908319966, -0.0623377689723666, 0.213190734538724, 0.0509955654682691, 0.510112697076803, 0.00647728608404003, 0.064792807839805, 0.0154985435047956},
 
1835
    {-0.0151385367967614, -0.0927575594483608, 0.0147498566399773, -0.106180538748753, 0.71390981117415, 0.170768371303483, 0.25311764376694, 0.0216904270965776, 0.0321501561271396, 0.00769036888560852},
 
1836
    {-0.00695995435590172, -0.0494020059140975, -0.12437750559924, 0.289054022006834, 0.655251051574542, 0.156737101971251, 0.0516581193256993, 0.0199082222175353, 0.00656144145796829, 0.00156950731540947}};
 
1837
    
 
1838
    
 
1839
    // Compute element tensor using UFL quadrature representation
 
1840
    // Optimisations: ('simplify expressions', True), ('ignore zero tables', True), ('non zero columns', True), ('remove zero terms', True), ('ignore ones', True)
 
1841
    // Total number of operations to compute element tensor: 8127
 
1842
    
 
1843
    // Loop quadrature points for integral
 
1844
    // Number of operations to compute element tensor for following IP loop = 8127
 
1845
    for (unsigned int ip = 0; ip < 27; ip++)
 
1846
    {
 
1847
      
 
1848
      // Number of operations to compute ip constants: 1
 
1849
      // Number of operations: 1
 
1850
      const double Gip0 = W27[ip]*det;
 
1851
      
 
1852
      
 
1853
      // Number of operations for primary indices = 300
 
1854
      for (unsigned int j = 0; j < 10; j++)
 
1855
      {
 
1856
        for (unsigned int k = 0; k < 10; k++)
 
1857
        {
 
1858
          // Number of operations to compute entry = 3
 
1859
          A[j*10 + k] += FE0[ip][j]*FE0[ip][k]*Gip0;
 
1860
        }// end loop over 'k'
 
1861
      }// end loop over 'j'
 
1862
    }// end loop over 'ip'
 
1863
  }
 
1864
 
 
1865
};
 
1866
 
 
1867
/// This class defines the interface for the tabulation of the cell
 
1868
/// tensor corresponding to the local contribution to a form from
 
1869
/// the integral over a cell.
 
1870
 
 
1871
class projection_0_cell_integral_0: public ufc::cell_integral
 
1872
{
 
1873
private:
 
1874
 
 
1875
  projection_0_cell_integral_0_quadrature integral_0_quadrature;
 
1876
 
 
1877
public:
 
1878
 
 
1879
  /// Constructor
 
1880
  projection_0_cell_integral_0() : ufc::cell_integral()
 
1881
  {
 
1882
    // Do nothing
 
1883
  }
 
1884
 
 
1885
  /// Destructor
 
1886
  virtual ~projection_0_cell_integral_0()
 
1887
  {
 
1888
    // Do nothing
 
1889
  }
 
1890
 
 
1891
  /// Tabulate the tensor for the contribution from a local cell
 
1892
  virtual void tabulate_tensor(double* A,
 
1893
                               const double * const * w,
 
1894
                               const ufc::cell& c) const
 
1895
  {
 
1896
    // Reset values of the element tensor block
 
1897
    for (unsigned int j = 0; j < 100; j++)
 
1898
      A[j] = 0;
 
1899
    
 
1900
    // Add all contributions to element tensor
 
1901
    integral_0_quadrature.tabulate_tensor(A, w, c);
1898
1902
  }
1899
1903
 
1900
1904
};
1914
1918
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
1915
1919
/// fixed functions (coefficients).
1916
1920
 
1917
 
class UFC_ProjectionBilinearForm: public ufc::form
 
1921
class projection_form_0: public ufc::form
1918
1922
{
1919
1923
public:
1920
1924
 
1921
1925
  /// Constructor
1922
 
  UFC_ProjectionBilinearForm() : ufc::form()
 
1926
  projection_form_0() : ufc::form()
1923
1927
  {
1924
1928
    // Do nothing
1925
1929
  }
1926
1930
 
1927
1931
  /// Destructor
1928
 
  virtual ~UFC_ProjectionBilinearForm()
 
1932
  virtual ~projection_form_0()
1929
1933
  {
1930
1934
    // Do nothing
1931
1935
  }
1933
1937
  /// Return a string identifying the form
1934
1938
  virtual const char* signature() const
1935
1939
  {
1936
 
    return " | vi0[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]*vi1[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]*dX(0)";
 
1940
    return "Form([Integral(Product(BasisFunction(FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2), 0), BasisFunction(FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2), 1)), Measure('cell', 0, None))])";
1937
1941
  }
1938
1942
 
1939
1943
  /// Return the rank of the global tensor (r)
1953
1957
  {
1954
1958
    return 1;
1955
1959
  }
1956
 
  
 
1960
 
1957
1961
  /// Return the number of exterior facet integrals
1958
1962
  virtual unsigned int num_exterior_facet_integrals() const
1959
1963
  {
1960
1964
    return 0;
1961
1965
  }
1962
 
  
 
1966
 
1963
1967
  /// Return the number of interior facet integrals
1964
1968
  virtual unsigned int num_interior_facet_integrals() const
1965
1969
  {
1966
1970
    return 0;
1967
1971
  }
1968
 
    
 
1972
 
1969
1973
  /// Create a new finite element for argument function i
1970
1974
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
1971
1975
  {
1972
1976
    switch ( i )
1973
1977
    {
1974
1978
    case 0:
1975
 
      return new UFC_ProjectionBilinearForm_finite_element_0();
 
1979
      return new projection_0_finite_element_0();
1976
1980
      break;
1977
1981
    case 1:
1978
 
      return new UFC_ProjectionBilinearForm_finite_element_1();
 
1982
      return new projection_0_finite_element_1();
1979
1983
      break;
1980
1984
    }
1981
1985
    return 0;
1982
1986
  }
1983
 
  
 
1987
 
1984
1988
  /// Create a new dof map for argument function i
1985
1989
  virtual ufc::dof_map* create_dof_map(unsigned int i) const
1986
1990
  {
1987
1991
    switch ( i )
1988
1992
    {
1989
1993
    case 0:
1990
 
      return new UFC_ProjectionBilinearForm_dof_map_0();
 
1994
      return new projection_0_dof_map_0();
1991
1995
      break;
1992
1996
    case 1:
1993
 
      return new UFC_ProjectionBilinearForm_dof_map_1();
 
1997
      return new projection_0_dof_map_1();
1994
1998
      break;
1995
1999
    }
1996
2000
    return 0;
1999
2003
  /// Create a new cell integral on sub domain i
2000
2004
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
2001
2005
  {
2002
 
    return new UFC_ProjectionBilinearForm_cell_integral_0();
 
2006
    return new projection_0_cell_integral_0();
2003
2007
  }
2004
2008
 
2005
2009
  /// Create a new exterior facet integral on sub domain i
2018
2022
 
2019
2023
/// This class defines the interface for a finite element.
2020
2024
 
2021
 
class UFC_ProjectionLinearForm_finite_element_0: public ufc::finite_element
 
2025
class projection_1_finite_element_0: public ufc::finite_element
2022
2026
{
2023
2027
public:
2024
2028
 
2025
2029
  /// Constructor
2026
 
  UFC_ProjectionLinearForm_finite_element_0() : ufc::finite_element()
 
2030
  projection_1_finite_element_0() : ufc::finite_element()
2027
2031
  {
2028
2032
    // Do nothing
2029
2033
  }
2030
2034
 
2031
2035
  /// Destructor
2032
 
  virtual ~UFC_ProjectionLinearForm_finite_element_0()
 
2036
  virtual ~projection_1_finite_element_0()
2033
2037
  {
2034
2038
    // Do nothing
2035
2039
  }
2083
2087
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
2084
2088
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
2085
2089
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
2086
 
      
 
2090
    
2087
2091
    // Compute sub determinants
2088
2092
    const double d00 = J_11*J_22 - J_12*J_21;
2089
2093
    const double d01 = J_12*J_20 - J_10*J_22;
2096
2100
    const double d20 = J_01*J_12 - J_02*J_11;
2097
2101
    const double d21 = J_02*J_10 - J_00*J_12;
2098
2102
    const double d22 = J_00*J_11 - J_01*J_10;
2099
 
      
 
2103
    
2100
2104
    // Compute determinant of Jacobian
2101
2105
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
2102
2106
    
2183
2187
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
2184
2188
    
2185
2189
    // Table(s) of coefficients
2186
 
    const static double coefficients0[10][10] = \
2187
 
    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
2188
 
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
2189
 
    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},
 
2190
    static const double coefficients0[10][10] = \
 
2191
    {{-0.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.0503952630678969, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
2192
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
2193
    {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323},
2190
2194
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
2191
2195
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
2192
 
    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
2193
 
    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
2194
 
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
2196
    {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
2197
    {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
2198
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
2195
2199
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
2196
2200
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
2197
2201
    
2239
2243
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
2240
2244
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
2241
2245
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
2242
 
      
 
2246
    
2243
2247
    // Compute sub determinants
2244
2248
    const double d00 = J_11*J_22 - J_12*J_21;
2245
2249
    const double d01 = J_12*J_20 - J_10*J_22;
2252
2256
    const double d20 = J_01*J_12 - J_02*J_11;
2253
2257
    const double d21 = J_02*J_10 - J_00*J_12;
2254
2258
    const double d22 = J_00*J_11 - J_01*J_10;
2255
 
      
 
2259
    
2256
2260
    // Compute determinant of Jacobian
2257
2261
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
2258
2262
    
2296
2300
    
2297
2301
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
2298
2302
    unsigned int **combinations = new unsigned int *[num_derivatives];
2299
 
        
 
2303
    
2300
2304
    for (unsigned int j = 0; j < num_derivatives; j++)
2301
2305
    {
2302
2306
      combinations[j] = new unsigned int [n];
2303
2307
      for (unsigned int k = 0; k < n; k++)
2304
2308
        combinations[j][k] = 0;
2305
2309
    }
2306
 
        
 
2310
    
2307
2311
    // Generate combinations of derivatives
2308
2312
    for (unsigned int row = 1; row < num_derivatives; row++)
2309
2313
    {
2328
2332
    // Declare transformation matrix
2329
2333
    // Declare pointer to two dimensional array and initialise
2330
2334
    double **transform = new double *[num_derivatives];
2331
 
        
 
2335
    
2332
2336
    for (unsigned int j = 0; j < num_derivatives; j++)
2333
2337
    {
2334
2338
      transform[j] = new double [num_derivatives];
2399
2403
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
2400
2404
    
2401
2405
    // Table(s) of coefficients
2402
 
    const static double coefficients0[10][10] = \
2403
 
    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
2404
 
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
2405
 
    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},
 
2406
    static const double coefficients0[10][10] = \
 
2407
    {{-0.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.0503952630678969, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
2408
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
2409
    {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323},
2406
2410
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
2407
2411
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
2408
 
    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
2409
 
    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
2410
 
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
2412
    {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
2413
    {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
2414
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
2411
2415
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
2412
2416
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
2413
2417
    
2414
2418
    // Interesting (new) part
2415
2419
    // Tables of derivatives of the polynomial base (transpose)
2416
 
    const static double dmats0[10][10] = \
 
2420
    static const double dmats0[10][10] = \
2417
2421
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2418
2422
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2419
2423
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2425
2429
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2426
2430
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
2427
2431
    
2428
 
    const static double dmats1[10][10] = \
 
2432
    static const double dmats1[10][10] = \
2429
2433
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2430
2434
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2431
2435
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2432
2436
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2433
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825974, 0, 0, 0, 0, 0, 0},
 
2437
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
2434
2438
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
2435
 
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063974, 0, 0, 0, 0, 0, 0},
 
2439
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0},
2436
2440
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
2437
2441
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0},
2438
2442
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
2439
2443
    
2440
 
    const static double dmats2[10][10] = \
 
2444
    static const double dmats2[10][10] = \
2441
2445
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2442
2446
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2443
2447
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2444
2448
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2445
2449
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
2446
2450
    {2.29128784747792, 1.44913767461894, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
2447
 
    {1.32287565553229, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},
 
2451
    {1.3228756555323, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},
2448
2452
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
2449
2453
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960223, 0, 0, 0, 0, 0, 0},
2450
 
    {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};
 
2454
    {-3.81881307912987, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};
2451
2455
    
2452
2456
    // Compute reference derivatives
2453
2457
    // Declare pointer to array of derivatives on FIAT element
2589
2593
                              const ufc::cell& c) const
2590
2594
  {
2591
2595
    // The reference points, direction and weights:
2592
 
    const static double X[10][1][3] = {{{0, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0.5, 0.5}}, {{0.5, 0, 0.5}}, {{0.5, 0.5, 0}}, {{0, 0, 0.5}}, {{0, 0.5, 0}}, {{0.5, 0, 0}}};
2593
 
    const static double W[10][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
2594
 
    const static double D[10][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
 
2596
    static const double X[10][1][3] = {{{0, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0.5, 0.5}}, {{0.5, 0, 0.5}}, {{0.5, 0.5, 0}}, {{0, 0, 0.5}}, {{0, 0.5, 0}}, {{0.5, 0, 0}}};
 
2597
    static const double W[10][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
 
2598
    static const double D[10][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
2595
2599
    
2596
2600
    const double * const * x = c.coordinates;
2597
2601
    double result = 0.0;
2620
2624
    // Take directional components
2621
2625
    for(int k = 0; k < 1; k++)
2622
2626
      result += values[k]*D[i][0][k];
2623
 
    // Multiply by weights 
 
2627
    // Multiply by weights
2624
2628
    result *= W[i][0];
2625
2629
    
2626
2630
    return result;
2655
2659
  /// Create a new finite element for sub element i (for a mixed element)
2656
2660
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
2657
2661
  {
2658
 
    return new UFC_ProjectionLinearForm_finite_element_0();
 
2662
    return new projection_1_finite_element_0();
2659
2663
  }
2660
2664
 
2661
2665
};
2662
2666
 
2663
2667
/// This class defines the interface for a finite element.
2664
2668
 
2665
 
class UFC_ProjectionLinearForm_finite_element_1: public ufc::finite_element
 
2669
class projection_1_finite_element_1: public ufc::finite_element
2666
2670
{
2667
2671
public:
2668
2672
 
2669
2673
  /// Constructor
2670
 
  UFC_ProjectionLinearForm_finite_element_1() : ufc::finite_element()
 
2674
  projection_1_finite_element_1() : ufc::finite_element()
2671
2675
  {
2672
2676
    // Do nothing
2673
2677
  }
2674
2678
 
2675
2679
  /// Destructor
2676
 
  virtual ~UFC_ProjectionLinearForm_finite_element_1()
 
2680
  virtual ~projection_1_finite_element_1()
2677
2681
  {
2678
2682
    // Do nothing
2679
2683
  }
2727
2731
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
2728
2732
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
2729
2733
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
2730
 
      
 
2734
    
2731
2735
    // Compute sub determinants
2732
2736
    const double d00 = J_11*J_22 - J_12*J_21;
2733
2737
    const double d01 = J_12*J_20 - J_10*J_22;
2740
2744
    const double d20 = J_01*J_12 - J_02*J_11;
2741
2745
    const double d21 = J_02*J_10 - J_00*J_12;
2742
2746
    const double d22 = J_00*J_11 - J_01*J_10;
2743
 
      
 
2747
    
2744
2748
    // Compute determinant of Jacobian
2745
2749
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
2746
2750
    
2827
2831
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
2828
2832
    
2829
2833
    // Table(s) of coefficients
2830
 
    const static double coefficients0[10][10] = \
2831
 
    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
2832
 
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
2833
 
    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},
 
2834
    static const double coefficients0[10][10] = \
 
2835
    {{-0.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.0503952630678969, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
2836
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
2837
    {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323},
2834
2838
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
2835
2839
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
2836
 
    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
2837
 
    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
2838
 
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
2840
    {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
2841
    {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
2842
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
2839
2843
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
2840
2844
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
2841
2845
    
2883
2887
    const double J_20 = element_coordinates[1][2] - element_coordinates[0][2];
2884
2888
    const double J_21 = element_coordinates[2][2] - element_coordinates[0][2];
2885
2889
    const double J_22 = element_coordinates[3][2] - element_coordinates[0][2];
2886
 
      
 
2890
    
2887
2891
    // Compute sub determinants
2888
2892
    const double d00 = J_11*J_22 - J_12*J_21;
2889
2893
    const double d01 = J_12*J_20 - J_10*J_22;
2896
2900
    const double d20 = J_01*J_12 - J_02*J_11;
2897
2901
    const double d21 = J_02*J_10 - J_00*J_12;
2898
2902
    const double d22 = J_00*J_11 - J_01*J_10;
2899
 
      
 
2903
    
2900
2904
    // Compute determinant of Jacobian
2901
2905
    double detJ = J_00*d00 + J_10*d10 + J_20*d20;
2902
2906
    
2940
2944
    
2941
2945
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
2942
2946
    unsigned int **combinations = new unsigned int *[num_derivatives];
2943
 
        
 
2947
    
2944
2948
    for (unsigned int j = 0; j < num_derivatives; j++)
2945
2949
    {
2946
2950
      combinations[j] = new unsigned int [n];
2947
2951
      for (unsigned int k = 0; k < n; k++)
2948
2952
        combinations[j][k] = 0;
2949
2953
    }
2950
 
        
 
2954
    
2951
2955
    // Generate combinations of derivatives
2952
2956
    for (unsigned int row = 1; row < num_derivatives; row++)
2953
2957
    {
2972
2976
    // Declare transformation matrix
2973
2977
    // Declare pointer to two dimensional array and initialise
2974
2978
    double **transform = new double *[num_derivatives];
2975
 
        
 
2979
    
2976
2980
    for (unsigned int j = 0; j < num_derivatives; j++)
2977
2981
    {
2978
2982
      transform[j] = new double [num_derivatives];
3043
3047
    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;
3044
3048
    
3045
3049
    // Table(s) of coefficients
3046
 
    const static double coefficients0[10][10] = \
3047
 
    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
3048
 
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
3049
 
    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},
 
3050
    static const double coefficients0[10][10] = \
 
3051
    {{-0.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.0503952630678969, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
3052
    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},
 
3053
    {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323},
3050
3054
    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},
3051
3055
    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},
3052
 
    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
3053
 
    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
3054
 
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
3056
    {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},
 
3057
    {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},
 
3058
    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},
3055
3059
    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},
3056
3060
    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};
3057
3061
    
3058
3062
    // Interesting (new) part
3059
3063
    // Tables of derivatives of the polynomial base (transpose)
3060
 
    const static double dmats0[10][10] = \
 
3064
    static const double dmats0[10][10] = \
3061
3065
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3062
3066
    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3063
3067
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3069
3073
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3070
3074
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3071
3075
    
3072
 
    const static double dmats1[10][10] = \
 
3076
    static const double dmats1[10][10] = \
3073
3077
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3074
3078
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3075
3079
    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3076
3080
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3077
 
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825974, 0, 0, 0, 0, 0, 0},
 
3081
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
3078
3082
    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
3079
 
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063974, 0, 0, 0, 0, 0, 0},
 
3083
    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063973, 0, 0, 0, 0, 0, 0},
3080
3084
    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
3081
3085
    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0},
3082
3086
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
3083
3087
    
3084
 
    const static double dmats2[10][10] = \
 
3088
    static const double dmats2[10][10] = \
3085
3089
    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3086
3090
    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3087
3091
    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3088
3092
    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0},
3089
3093
    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},
3090
3094
    {2.29128784747792, 1.44913767461894, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},
3091
 
    {1.32287565553229, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},
 
3095
    {1.3228756555323, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},
3092
3096
    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},
3093
3097
    {1.08012344973464, 0, 7.09929573971954, 2.50998007960223, 0, 0, 0, 0, 0, 0},
3094
 
    {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};
 
3098
    {-3.81881307912987, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};
3095
3099
    
3096
3100
    // Compute reference derivatives
3097
3101
    // Declare pointer to array of derivatives on FIAT element
3233
3237
                              const ufc::cell& c) const
3234
3238
  {
3235
3239
    // The reference points, direction and weights:
3236
 
    const static double X[10][1][3] = {{{0, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0.5, 0.5}}, {{0.5, 0, 0.5}}, {{0.5, 0.5, 0}}, {{0, 0, 0.5}}, {{0, 0.5, 0}}, {{0.5, 0, 0}}};
3237
 
    const static double W[10][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
3238
 
    const static double D[10][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
 
3240
    static const double X[10][1][3] = {{{0, 0, 0}}, {{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}, {{0, 0.5, 0.5}}, {{0.5, 0, 0.5}}, {{0.5, 0.5, 0}}, {{0, 0, 0.5}}, {{0, 0.5, 0}}, {{0.5, 0, 0}}};
 
3241
    static const double W[10][1] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}};
 
3242
    static const double D[10][1][1] = {{{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}, {{1}}};
3239
3243
    
3240
3244
    const double * const * x = c.coordinates;
3241
3245
    double result = 0.0;
3264
3268
    // Take directional components
3265
3269
    for(int k = 0; k < 1; k++)
3266
3270
      result += values[k]*D[i][0][k];
3267
 
    // Multiply by weights 
 
3271
    // Multiply by weights
3268
3272
    result *= W[i][0];
3269
3273
    
3270
3274
    return result;
3299
3303
  /// Create a new finite element for sub element i (for a mixed element)
3300
3304
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
3301
3305
  {
3302
 
    return new UFC_ProjectionLinearForm_finite_element_1();
3303
 
  }
3304
 
 
3305
 
};
3306
 
 
3307
 
/// This class defines the interface for a local-to-global mapping of
3308
 
/// degrees of freedom (dofs).
3309
 
 
3310
 
class UFC_ProjectionLinearForm_dof_map_0: public ufc::dof_map
3311
 
{
3312
 
private:
3313
 
 
3314
 
  unsigned int __global_dimension;
3315
 
 
3316
 
public:
3317
 
 
3318
 
  /// Constructor
3319
 
  UFC_ProjectionLinearForm_dof_map_0() : ufc::dof_map()
3320
 
  {
3321
 
    __global_dimension = 0;
3322
 
  }
3323
 
 
3324
 
  /// Destructor
3325
 
  virtual ~UFC_ProjectionLinearForm_dof_map_0()
3326
 
  {
3327
 
    // Do nothing
3328
 
  }
3329
 
 
3330
 
  /// Return a string identifying the dof map
3331
 
  virtual const char* signature() const
3332
 
  {
3333
 
    return "FFC dof map for FiniteElement('Lagrange', 'tetrahedron', 2)";
3334
 
  }
3335
 
 
3336
 
  /// Return true iff mesh entities of topological dimension d are needed
3337
 
  virtual bool needs_mesh_entities(unsigned int d) const
3338
 
  {
3339
 
    switch ( d )
3340
 
    {
3341
 
    case 0:
3342
 
      return true;
3343
 
      break;
3344
 
    case 1:
3345
 
      return true;
3346
 
      break;
3347
 
    case 2:
3348
 
      return false;
3349
 
      break;
3350
 
    case 3:
3351
 
      return false;
3352
 
      break;
3353
 
    }
3354
 
    return false;
3355
 
  }
3356
 
 
3357
 
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
3358
 
  virtual bool init_mesh(const ufc::mesh& m)
3359
 
  {
3360
 
    __global_dimension = m.num_entities[0] + m.num_entities[1];
3361
 
    return false;
3362
 
  }
3363
 
 
3364
 
  /// Initialize dof map for given cell
3365
 
  virtual void init_cell(const ufc::mesh& m,
3366
 
                         const ufc::cell& c)
3367
 
  {
3368
 
    // Do nothing
3369
 
  }
3370
 
 
3371
 
  /// Finish initialization of dof map for cells
3372
 
  virtual void init_cell_finalize()
3373
 
  {
3374
 
    // Do nothing
3375
 
  }
3376
 
 
3377
 
  /// Return the dimension of the global finite element function space
3378
 
  virtual unsigned int global_dimension() const
3379
 
  {
3380
 
    return __global_dimension;
3381
 
  }
3382
 
 
3383
 
  /// Return the dimension of the local finite element function space
3384
 
  virtual unsigned int local_dimension() const
3385
 
  {
3386
 
    return 10;
3387
 
  }
3388
 
 
3389
 
  // Return the geometric dimension of the coordinates this dof map provides
3390
 
  virtual unsigned int geometric_dimension() const
3391
 
  {
3392
 
    return 3;
3393
 
  }
3394
 
 
3395
 
  /// Return the number of dofs on each cell facet
3396
 
  virtual unsigned int num_facet_dofs() const
3397
 
  {
3398
 
    return 6;
3399
 
  }
3400
 
 
3401
 
  /// Return the number of dofs associated with each cell entity of dimension d
3402
 
  virtual unsigned int num_entity_dofs(unsigned int d) const
3403
 
  {
3404
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
3405
 
  }
3406
 
 
3407
 
  /// Tabulate the local-to-global mapping of dofs on a cell
3408
 
  virtual void tabulate_dofs(unsigned int* dofs,
3409
 
                             const ufc::mesh& m,
3410
 
                             const ufc::cell& c) const
3411
 
  {
3412
 
    dofs[0] = c.entity_indices[0][0];
3413
 
    dofs[1] = c.entity_indices[0][1];
3414
 
    dofs[2] = c.entity_indices[0][2];
3415
 
    dofs[3] = c.entity_indices[0][3];
3416
 
    unsigned int offset = m.num_entities[0];
3417
 
    dofs[4] = offset + c.entity_indices[1][0];
3418
 
    dofs[5] = offset + c.entity_indices[1][1];
3419
 
    dofs[6] = offset + c.entity_indices[1][2];
3420
 
    dofs[7] = offset + c.entity_indices[1][3];
3421
 
    dofs[8] = offset + c.entity_indices[1][4];
3422
 
    dofs[9] = offset + c.entity_indices[1][5];
3423
 
  }
3424
 
 
3425
 
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
3426
 
  virtual void tabulate_facet_dofs(unsigned int* dofs,
3427
 
                                   unsigned int facet) const
3428
 
  {
3429
 
    switch ( facet )
3430
 
    {
3431
 
    case 0:
3432
 
      dofs[0] = 1;
3433
 
      dofs[1] = 2;
3434
 
      dofs[2] = 3;
3435
 
      dofs[3] = 4;
3436
 
      dofs[4] = 5;
3437
 
      dofs[5] = 6;
3438
 
      break;
3439
 
    case 1:
3440
 
      dofs[0] = 0;
3441
 
      dofs[1] = 2;
3442
 
      dofs[2] = 3;
3443
 
      dofs[3] = 4;
3444
 
      dofs[4] = 7;
3445
 
      dofs[5] = 8;
3446
 
      break;
3447
 
    case 2:
3448
 
      dofs[0] = 0;
3449
 
      dofs[1] = 1;
3450
 
      dofs[2] = 3;
3451
 
      dofs[3] = 5;
3452
 
      dofs[4] = 7;
3453
 
      dofs[5] = 9;
3454
 
      break;
3455
 
    case 3:
3456
 
      dofs[0] = 0;
3457
 
      dofs[1] = 1;
3458
 
      dofs[2] = 2;
3459
 
      dofs[3] = 6;
3460
 
      dofs[4] = 8;
3461
 
      dofs[5] = 9;
3462
 
      break;
3463
 
    }
3464
 
  }
3465
 
 
3466
 
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
3467
 
  virtual void tabulate_entity_dofs(unsigned int* dofs,
3468
 
                                    unsigned int d, unsigned int i) const
3469
 
  {
3470
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
3471
 
  }
3472
 
 
3473
 
  /// Tabulate the coordinates of all dofs on a cell
3474
 
  virtual void tabulate_coordinates(double** coordinates,
3475
 
                                    const ufc::cell& c) const
3476
 
  {
3477
 
    const double * const * x = c.coordinates;
3478
 
    coordinates[0][0] = x[0][0];
3479
 
    coordinates[0][1] = x[0][1];
3480
 
    coordinates[0][2] = x[0][2];
3481
 
    coordinates[1][0] = x[1][0];
3482
 
    coordinates[1][1] = x[1][1];
3483
 
    coordinates[1][2] = x[1][2];
3484
 
    coordinates[2][0] = x[2][0];
3485
 
    coordinates[2][1] = x[2][1];
3486
 
    coordinates[2][2] = x[2][2];
3487
 
    coordinates[3][0] = x[3][0];
3488
 
    coordinates[3][1] = x[3][1];
3489
 
    coordinates[3][2] = x[3][2];
3490
 
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
3491
 
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
3492
 
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
3493
 
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
3494
 
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
3495
 
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
3496
 
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
3497
 
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
3498
 
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
3499
 
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
3500
 
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
3501
 
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
3502
 
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
3503
 
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
3504
 
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
3505
 
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
3506
 
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
3507
 
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
3508
 
  }
3509
 
 
3510
 
  /// Return the number of sub dof maps (for a mixed element)
3511
 
  virtual unsigned int num_sub_dof_maps() const
3512
 
  {
3513
 
    return 1;
3514
 
  }
3515
 
 
3516
 
  /// Create a new dof_map for sub dof map i (for a mixed element)
3517
 
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
3518
 
  {
3519
 
    return new UFC_ProjectionLinearForm_dof_map_0();
3520
 
  }
3521
 
 
3522
 
};
3523
 
 
3524
 
/// This class defines the interface for a local-to-global mapping of
3525
 
/// degrees of freedom (dofs).
3526
 
 
3527
 
class UFC_ProjectionLinearForm_dof_map_1: public ufc::dof_map
3528
 
{
3529
 
private:
3530
 
 
3531
 
  unsigned int __global_dimension;
3532
 
 
3533
 
public:
3534
 
 
3535
 
  /// Constructor
3536
 
  UFC_ProjectionLinearForm_dof_map_1() : ufc::dof_map()
3537
 
  {
3538
 
    __global_dimension = 0;
3539
 
  }
3540
 
 
3541
 
  /// Destructor
3542
 
  virtual ~UFC_ProjectionLinearForm_dof_map_1()
3543
 
  {
3544
 
    // Do nothing
3545
 
  }
3546
 
 
3547
 
  /// Return a string identifying the dof map
3548
 
  virtual const char* signature() const
3549
 
  {
3550
 
    return "FFC dof map for FiniteElement('Lagrange', 'tetrahedron', 2)";
3551
 
  }
3552
 
 
3553
 
  /// Return true iff mesh entities of topological dimension d are needed
3554
 
  virtual bool needs_mesh_entities(unsigned int d) const
3555
 
  {
3556
 
    switch ( d )
3557
 
    {
3558
 
    case 0:
3559
 
      return true;
3560
 
      break;
3561
 
    case 1:
3562
 
      return true;
3563
 
      break;
3564
 
    case 2:
3565
 
      return false;
3566
 
      break;
3567
 
    case 3:
3568
 
      return false;
3569
 
      break;
3570
 
    }
3571
 
    return false;
3572
 
  }
3573
 
 
3574
 
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
3575
 
  virtual bool init_mesh(const ufc::mesh& m)
3576
 
  {
3577
 
    __global_dimension = m.num_entities[0] + m.num_entities[1];
3578
 
    return false;
3579
 
  }
3580
 
 
3581
 
  /// Initialize dof map for given cell
3582
 
  virtual void init_cell(const ufc::mesh& m,
3583
 
                         const ufc::cell& c)
3584
 
  {
3585
 
    // Do nothing
3586
 
  }
3587
 
 
3588
 
  /// Finish initialization of dof map for cells
3589
 
  virtual void init_cell_finalize()
3590
 
  {
3591
 
    // Do nothing
3592
 
  }
3593
 
 
3594
 
  /// Return the dimension of the global finite element function space
3595
 
  virtual unsigned int global_dimension() const
3596
 
  {
3597
 
    return __global_dimension;
3598
 
  }
3599
 
 
3600
 
  /// Return the dimension of the local finite element function space
3601
 
  virtual unsigned int local_dimension() const
3602
 
  {
3603
 
    return 10;
3604
 
  }
3605
 
 
3606
 
  // Return the geometric dimension of the coordinates this dof map provides
3607
 
  virtual unsigned int geometric_dimension() const
3608
 
  {
3609
 
    return 3;
3610
 
  }
3611
 
 
3612
 
  /// Return the number of dofs on each cell facet
3613
 
  virtual unsigned int num_facet_dofs() const
3614
 
  {
3615
 
    return 6;
3616
 
  }
3617
 
 
3618
 
  /// Return the number of dofs associated with each cell entity of dimension d
3619
 
  virtual unsigned int num_entity_dofs(unsigned int d) const
3620
 
  {
3621
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
3622
 
  }
3623
 
 
3624
 
  /// Tabulate the local-to-global mapping of dofs on a cell
3625
 
  virtual void tabulate_dofs(unsigned int* dofs,
3626
 
                             const ufc::mesh& m,
3627
 
                             const ufc::cell& c) const
3628
 
  {
3629
 
    dofs[0] = c.entity_indices[0][0];
3630
 
    dofs[1] = c.entity_indices[0][1];
3631
 
    dofs[2] = c.entity_indices[0][2];
3632
 
    dofs[3] = c.entity_indices[0][3];
3633
 
    unsigned int offset = m.num_entities[0];
3634
 
    dofs[4] = offset + c.entity_indices[1][0];
3635
 
    dofs[5] = offset + c.entity_indices[1][1];
3636
 
    dofs[6] = offset + c.entity_indices[1][2];
3637
 
    dofs[7] = offset + c.entity_indices[1][3];
3638
 
    dofs[8] = offset + c.entity_indices[1][4];
3639
 
    dofs[9] = offset + c.entity_indices[1][5];
3640
 
  }
3641
 
 
3642
 
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
3643
 
  virtual void tabulate_facet_dofs(unsigned int* dofs,
3644
 
                                   unsigned int facet) const
3645
 
  {
3646
 
    switch ( facet )
3647
 
    {
3648
 
    case 0:
3649
 
      dofs[0] = 1;
3650
 
      dofs[1] = 2;
3651
 
      dofs[2] = 3;
3652
 
      dofs[3] = 4;
3653
 
      dofs[4] = 5;
3654
 
      dofs[5] = 6;
3655
 
      break;
3656
 
    case 1:
3657
 
      dofs[0] = 0;
3658
 
      dofs[1] = 2;
3659
 
      dofs[2] = 3;
3660
 
      dofs[3] = 4;
3661
 
      dofs[4] = 7;
3662
 
      dofs[5] = 8;
3663
 
      break;
3664
 
    case 2:
3665
 
      dofs[0] = 0;
3666
 
      dofs[1] = 1;
3667
 
      dofs[2] = 3;
3668
 
      dofs[3] = 5;
3669
 
      dofs[4] = 7;
3670
 
      dofs[5] = 9;
3671
 
      break;
3672
 
    case 3:
3673
 
      dofs[0] = 0;
3674
 
      dofs[1] = 1;
3675
 
      dofs[2] = 2;
3676
 
      dofs[3] = 6;
3677
 
      dofs[4] = 8;
3678
 
      dofs[5] = 9;
3679
 
      break;
3680
 
    }
3681
 
  }
3682
 
 
3683
 
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
3684
 
  virtual void tabulate_entity_dofs(unsigned int* dofs,
3685
 
                                    unsigned int d, unsigned int i) const
3686
 
  {
3687
 
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
3688
 
  }
3689
 
 
3690
 
  /// Tabulate the coordinates of all dofs on a cell
3691
 
  virtual void tabulate_coordinates(double** coordinates,
3692
 
                                    const ufc::cell& c) const
3693
 
  {
3694
 
    const double * const * x = c.coordinates;
3695
 
    coordinates[0][0] = x[0][0];
3696
 
    coordinates[0][1] = x[0][1];
3697
 
    coordinates[0][2] = x[0][2];
3698
 
    coordinates[1][0] = x[1][0];
3699
 
    coordinates[1][1] = x[1][1];
3700
 
    coordinates[1][2] = x[1][2];
3701
 
    coordinates[2][0] = x[2][0];
3702
 
    coordinates[2][1] = x[2][1];
3703
 
    coordinates[2][2] = x[2][2];
3704
 
    coordinates[3][0] = x[3][0];
3705
 
    coordinates[3][1] = x[3][1];
3706
 
    coordinates[3][2] = x[3][2];
3707
 
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
3708
 
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
3709
 
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
3710
 
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
3711
 
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
3712
 
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
3713
 
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
3714
 
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
3715
 
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
3716
 
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
3717
 
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
3718
 
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
3719
 
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
3720
 
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
3721
 
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
3722
 
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
3723
 
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
3724
 
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
3725
 
  }
3726
 
 
3727
 
  /// Return the number of sub dof maps (for a mixed element)
3728
 
  virtual unsigned int num_sub_dof_maps() const
3729
 
  {
3730
 
    return 1;
3731
 
  }
3732
 
 
3733
 
  /// Create a new dof_map for sub dof map i (for a mixed element)
3734
 
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
3735
 
  {
3736
 
    return new UFC_ProjectionLinearForm_dof_map_1();
 
3306
    return new projection_1_finite_element_1();
 
3307
  }
 
3308
 
 
3309
};
 
3310
 
 
3311
/// This class defines the interface for a local-to-global mapping of
 
3312
/// degrees of freedom (dofs).
 
3313
 
 
3314
class projection_1_dof_map_0: public ufc::dof_map
 
3315
{
 
3316
private:
 
3317
 
 
3318
  unsigned int __global_dimension;
 
3319
 
 
3320
public:
 
3321
 
 
3322
  /// Constructor
 
3323
  projection_1_dof_map_0() : ufc::dof_map()
 
3324
  {
 
3325
    __global_dimension = 0;
 
3326
  }
 
3327
 
 
3328
  /// Destructor
 
3329
  virtual ~projection_1_dof_map_0()
 
3330
  {
 
3331
    // Do nothing
 
3332
  }
 
3333
 
 
3334
  /// Return a string identifying the dof map
 
3335
  virtual const char* signature() const
 
3336
  {
 
3337
    return "FFC dof map for FiniteElement('Lagrange', 'tetrahedron', 2)";
 
3338
  }
 
3339
 
 
3340
  /// Return true iff mesh entities of topological dimension d are needed
 
3341
  virtual bool needs_mesh_entities(unsigned int d) const
 
3342
  {
 
3343
    switch ( d )
 
3344
    {
 
3345
    case 0:
 
3346
      return true;
 
3347
      break;
 
3348
    case 1:
 
3349
      return true;
 
3350
      break;
 
3351
    case 2:
 
3352
      return false;
 
3353
      break;
 
3354
    case 3:
 
3355
      return false;
 
3356
      break;
 
3357
    }
 
3358
    return false;
 
3359
  }
 
3360
 
 
3361
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
3362
  virtual bool init_mesh(const ufc::mesh& m)
 
3363
  {
 
3364
    __global_dimension = m.num_entities[0] + m.num_entities[1];
 
3365
    return false;
 
3366
  }
 
3367
 
 
3368
  /// Initialize dof map for given cell
 
3369
  virtual void init_cell(const ufc::mesh& m,
 
3370
                         const ufc::cell& c)
 
3371
  {
 
3372
    // Do nothing
 
3373
  }
 
3374
 
 
3375
  /// Finish initialization of dof map for cells
 
3376
  virtual void init_cell_finalize()
 
3377
  {
 
3378
    // Do nothing
 
3379
  }
 
3380
 
 
3381
  /// Return the dimension of the global finite element function space
 
3382
  virtual unsigned int global_dimension() const
 
3383
  {
 
3384
    return __global_dimension;
 
3385
  }
 
3386
 
 
3387
  /// Return the dimension of the local finite element function space for a cell
 
3388
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
3389
  {
 
3390
    return 10;
 
3391
  }
 
3392
 
 
3393
  /// Return the maximum dimension of the local finite element function space
 
3394
  virtual unsigned int max_local_dimension() const
 
3395
  {
 
3396
    return 10;
 
3397
  }
 
3398
 
 
3399
  // Return the geometric dimension of the coordinates this dof map provides
 
3400
  virtual unsigned int geometric_dimension() const
 
3401
  {
 
3402
    return 3;
 
3403
  }
 
3404
 
 
3405
  /// Return the number of dofs on each cell facet
 
3406
  virtual unsigned int num_facet_dofs() const
 
3407
  {
 
3408
    return 6;
 
3409
  }
 
3410
 
 
3411
  /// Return the number of dofs associated with each cell entity of dimension d
 
3412
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
3413
  {
 
3414
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
3415
  }
 
3416
 
 
3417
  /// Tabulate the local-to-global mapping of dofs on a cell
 
3418
  virtual void tabulate_dofs(unsigned int* dofs,
 
3419
                             const ufc::mesh& m,
 
3420
                             const ufc::cell& c) const
 
3421
  {
 
3422
    dofs[0] = c.entity_indices[0][0];
 
3423
    dofs[1] = c.entity_indices[0][1];
 
3424
    dofs[2] = c.entity_indices[0][2];
 
3425
    dofs[3] = c.entity_indices[0][3];
 
3426
    unsigned int offset = m.num_entities[0];
 
3427
    dofs[4] = offset + c.entity_indices[1][0];
 
3428
    dofs[5] = offset + c.entity_indices[1][1];
 
3429
    dofs[6] = offset + c.entity_indices[1][2];
 
3430
    dofs[7] = offset + c.entity_indices[1][3];
 
3431
    dofs[8] = offset + c.entity_indices[1][4];
 
3432
    dofs[9] = offset + c.entity_indices[1][5];
 
3433
  }
 
3434
 
 
3435
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
3436
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
3437
                                   unsigned int facet) const
 
3438
  {
 
3439
    switch ( facet )
 
3440
    {
 
3441
    case 0:
 
3442
      dofs[0] = 1;
 
3443
      dofs[1] = 2;
 
3444
      dofs[2] = 3;
 
3445
      dofs[3] = 4;
 
3446
      dofs[4] = 5;
 
3447
      dofs[5] = 6;
 
3448
      break;
 
3449
    case 1:
 
3450
      dofs[0] = 0;
 
3451
      dofs[1] = 2;
 
3452
      dofs[2] = 3;
 
3453
      dofs[3] = 4;
 
3454
      dofs[4] = 7;
 
3455
      dofs[5] = 8;
 
3456
      break;
 
3457
    case 2:
 
3458
      dofs[0] = 0;
 
3459
      dofs[1] = 1;
 
3460
      dofs[2] = 3;
 
3461
      dofs[3] = 5;
 
3462
      dofs[4] = 7;
 
3463
      dofs[5] = 9;
 
3464
      break;
 
3465
    case 3:
 
3466
      dofs[0] = 0;
 
3467
      dofs[1] = 1;
 
3468
      dofs[2] = 2;
 
3469
      dofs[3] = 6;
 
3470
      dofs[4] = 8;
 
3471
      dofs[5] = 9;
 
3472
      break;
 
3473
    }
 
3474
  }
 
3475
 
 
3476
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
3477
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
3478
                                    unsigned int d, unsigned int i) const
 
3479
  {
 
3480
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
3481
  }
 
3482
 
 
3483
  /// Tabulate the coordinates of all dofs on a cell
 
3484
  virtual void tabulate_coordinates(double** coordinates,
 
3485
                                    const ufc::cell& c) const
 
3486
  {
 
3487
    const double * const * x = c.coordinates;
 
3488
    coordinates[0][0] = x[0][0];
 
3489
    coordinates[0][1] = x[0][1];
 
3490
    coordinates[0][2] = x[0][2];
 
3491
    coordinates[1][0] = x[1][0];
 
3492
    coordinates[1][1] = x[1][1];
 
3493
    coordinates[1][2] = x[1][2];
 
3494
    coordinates[2][0] = x[2][0];
 
3495
    coordinates[2][1] = x[2][1];
 
3496
    coordinates[2][2] = x[2][2];
 
3497
    coordinates[3][0] = x[3][0];
 
3498
    coordinates[3][1] = x[3][1];
 
3499
    coordinates[3][2] = x[3][2];
 
3500
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
3501
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
3502
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
3503
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
3504
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
3505
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
3506
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
3507
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
3508
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
3509
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
3510
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
3511
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
3512
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
3513
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
3514
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
3515
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
3516
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
3517
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
3518
  }
 
3519
 
 
3520
  /// Return the number of sub dof maps (for a mixed element)
 
3521
  virtual unsigned int num_sub_dof_maps() const
 
3522
  {
 
3523
    return 1;
 
3524
  }
 
3525
 
 
3526
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
3527
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
3528
  {
 
3529
    return new projection_1_dof_map_0();
 
3530
  }
 
3531
 
 
3532
};
 
3533
 
 
3534
/// This class defines the interface for a local-to-global mapping of
 
3535
/// degrees of freedom (dofs).
 
3536
 
 
3537
class projection_1_dof_map_1: public ufc::dof_map
 
3538
{
 
3539
private:
 
3540
 
 
3541
  unsigned int __global_dimension;
 
3542
 
 
3543
public:
 
3544
 
 
3545
  /// Constructor
 
3546
  projection_1_dof_map_1() : ufc::dof_map()
 
3547
  {
 
3548
    __global_dimension = 0;
 
3549
  }
 
3550
 
 
3551
  /// Destructor
 
3552
  virtual ~projection_1_dof_map_1()
 
3553
  {
 
3554
    // Do nothing
 
3555
  }
 
3556
 
 
3557
  /// Return a string identifying the dof map
 
3558
  virtual const char* signature() const
 
3559
  {
 
3560
    return "FFC dof map for FiniteElement('Lagrange', 'tetrahedron', 2)";
 
3561
  }
 
3562
 
 
3563
  /// Return true iff mesh entities of topological dimension d are needed
 
3564
  virtual bool needs_mesh_entities(unsigned int d) const
 
3565
  {
 
3566
    switch ( d )
 
3567
    {
 
3568
    case 0:
 
3569
      return true;
 
3570
      break;
 
3571
    case 1:
 
3572
      return true;
 
3573
      break;
 
3574
    case 2:
 
3575
      return false;
 
3576
      break;
 
3577
    case 3:
 
3578
      return false;
 
3579
      break;
 
3580
    }
 
3581
    return false;
 
3582
  }
 
3583
 
 
3584
  /// Initialize dof map for mesh (return true iff init_cell() is needed)
 
3585
  virtual bool init_mesh(const ufc::mesh& m)
 
3586
  {
 
3587
    __global_dimension = m.num_entities[0] + m.num_entities[1];
 
3588
    return false;
 
3589
  }
 
3590
 
 
3591
  /// Initialize dof map for given cell
 
3592
  virtual void init_cell(const ufc::mesh& m,
 
3593
                         const ufc::cell& c)
 
3594
  {
 
3595
    // Do nothing
 
3596
  }
 
3597
 
 
3598
  /// Finish initialization of dof map for cells
 
3599
  virtual void init_cell_finalize()
 
3600
  {
 
3601
    // Do nothing
 
3602
  }
 
3603
 
 
3604
  /// Return the dimension of the global finite element function space
 
3605
  virtual unsigned int global_dimension() const
 
3606
  {
 
3607
    return __global_dimension;
 
3608
  }
 
3609
 
 
3610
  /// Return the dimension of the local finite element function space for a cell
 
3611
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
3612
  {
 
3613
    return 10;
 
3614
  }
 
3615
 
 
3616
  /// Return the maximum dimension of the local finite element function space
 
3617
  virtual unsigned int max_local_dimension() const
 
3618
  {
 
3619
    return 10;
 
3620
  }
 
3621
 
 
3622
  // Return the geometric dimension of the coordinates this dof map provides
 
3623
  virtual unsigned int geometric_dimension() const
 
3624
  {
 
3625
    return 3;
 
3626
  }
 
3627
 
 
3628
  /// Return the number of dofs on each cell facet
 
3629
  virtual unsigned int num_facet_dofs() const
 
3630
  {
 
3631
    return 6;
 
3632
  }
 
3633
 
 
3634
  /// Return the number of dofs associated with each cell entity of dimension d
 
3635
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
3636
  {
 
3637
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
3638
  }
 
3639
 
 
3640
  /// Tabulate the local-to-global mapping of dofs on a cell
 
3641
  virtual void tabulate_dofs(unsigned int* dofs,
 
3642
                             const ufc::mesh& m,
 
3643
                             const ufc::cell& c) const
 
3644
  {
 
3645
    dofs[0] = c.entity_indices[0][0];
 
3646
    dofs[1] = c.entity_indices[0][1];
 
3647
    dofs[2] = c.entity_indices[0][2];
 
3648
    dofs[3] = c.entity_indices[0][3];
 
3649
    unsigned int offset = m.num_entities[0];
 
3650
    dofs[4] = offset + c.entity_indices[1][0];
 
3651
    dofs[5] = offset + c.entity_indices[1][1];
 
3652
    dofs[6] = offset + c.entity_indices[1][2];
 
3653
    dofs[7] = offset + c.entity_indices[1][3];
 
3654
    dofs[8] = offset + c.entity_indices[1][4];
 
3655
    dofs[9] = offset + c.entity_indices[1][5];
 
3656
  }
 
3657
 
 
3658
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
3659
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
3660
                                   unsigned int facet) const
 
3661
  {
 
3662
    switch ( facet )
 
3663
    {
 
3664
    case 0:
 
3665
      dofs[0] = 1;
 
3666
      dofs[1] = 2;
 
3667
      dofs[2] = 3;
 
3668
      dofs[3] = 4;
 
3669
      dofs[4] = 5;
 
3670
      dofs[5] = 6;
 
3671
      break;
 
3672
    case 1:
 
3673
      dofs[0] = 0;
 
3674
      dofs[1] = 2;
 
3675
      dofs[2] = 3;
 
3676
      dofs[3] = 4;
 
3677
      dofs[4] = 7;
 
3678
      dofs[5] = 8;
 
3679
      break;
 
3680
    case 2:
 
3681
      dofs[0] = 0;
 
3682
      dofs[1] = 1;
 
3683
      dofs[2] = 3;
 
3684
      dofs[3] = 5;
 
3685
      dofs[4] = 7;
 
3686
      dofs[5] = 9;
 
3687
      break;
 
3688
    case 3:
 
3689
      dofs[0] = 0;
 
3690
      dofs[1] = 1;
 
3691
      dofs[2] = 2;
 
3692
      dofs[3] = 6;
 
3693
      dofs[4] = 8;
 
3694
      dofs[5] = 9;
 
3695
      break;
 
3696
    }
 
3697
  }
 
3698
 
 
3699
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
3700
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
3701
                                    unsigned int d, unsigned int i) const
 
3702
  {
 
3703
    throw std::runtime_error("Not implemented (introduced in UFC v1.1).");
 
3704
  }
 
3705
 
 
3706
  /// Tabulate the coordinates of all dofs on a cell
 
3707
  virtual void tabulate_coordinates(double** coordinates,
 
3708
                                    const ufc::cell& c) const
 
3709
  {
 
3710
    const double * const * x = c.coordinates;
 
3711
    coordinates[0][0] = x[0][0];
 
3712
    coordinates[0][1] = x[0][1];
 
3713
    coordinates[0][2] = x[0][2];
 
3714
    coordinates[1][0] = x[1][0];
 
3715
    coordinates[1][1] = x[1][1];
 
3716
    coordinates[1][2] = x[1][2];
 
3717
    coordinates[2][0] = x[2][0];
 
3718
    coordinates[2][1] = x[2][1];
 
3719
    coordinates[2][2] = x[2][2];
 
3720
    coordinates[3][0] = x[3][0];
 
3721
    coordinates[3][1] = x[3][1];
 
3722
    coordinates[3][2] = x[3][2];
 
3723
    coordinates[4][0] = 0.5*x[2][0] + 0.5*x[3][0];
 
3724
    coordinates[4][1] = 0.5*x[2][1] + 0.5*x[3][1];
 
3725
    coordinates[4][2] = 0.5*x[2][2] + 0.5*x[3][2];
 
3726
    coordinates[5][0] = 0.5*x[1][0] + 0.5*x[3][0];
 
3727
    coordinates[5][1] = 0.5*x[1][1] + 0.5*x[3][1];
 
3728
    coordinates[5][2] = 0.5*x[1][2] + 0.5*x[3][2];
 
3729
    coordinates[6][0] = 0.5*x[1][0] + 0.5*x[2][0];
 
3730
    coordinates[6][1] = 0.5*x[1][1] + 0.5*x[2][1];
 
3731
    coordinates[6][2] = 0.5*x[1][2] + 0.5*x[2][2];
 
3732
    coordinates[7][0] = 0.5*x[0][0] + 0.5*x[3][0];
 
3733
    coordinates[7][1] = 0.5*x[0][1] + 0.5*x[3][1];
 
3734
    coordinates[7][2] = 0.5*x[0][2] + 0.5*x[3][2];
 
3735
    coordinates[8][0] = 0.5*x[0][0] + 0.5*x[2][0];
 
3736
    coordinates[8][1] = 0.5*x[0][1] + 0.5*x[2][1];
 
3737
    coordinates[8][2] = 0.5*x[0][2] + 0.5*x[2][2];
 
3738
    coordinates[9][0] = 0.5*x[0][0] + 0.5*x[1][0];
 
3739
    coordinates[9][1] = 0.5*x[0][1] + 0.5*x[1][1];
 
3740
    coordinates[9][2] = 0.5*x[0][2] + 0.5*x[1][2];
 
3741
  }
 
3742
 
 
3743
  /// Return the number of sub dof maps (for a mixed element)
 
3744
  virtual unsigned int num_sub_dof_maps() const
 
3745
  {
 
3746
    return 1;
 
3747
  }
 
3748
 
 
3749
  /// Create a new dof_map for sub dof map i (for a mixed element)
 
3750
  virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
 
3751
  {
 
3752
    return new projection_1_dof_map_1();
3737
3753
  }
3738
3754
 
3739
3755
};
3742
3758
/// tensor corresponding to the local contribution to a form from
3743
3759
/// the integral over a cell.
3744
3760
 
3745
 
class UFC_ProjectionLinearForm_cell_integral_0: public ufc::cell_integral
 
3761
class projection_1_cell_integral_0_quadrature: public ufc::cell_integral
3746
3762
{
3747
3763
public:
3748
3764
 
3749
3765
  /// Constructor
3750
 
  UFC_ProjectionLinearForm_cell_integral_0() : ufc::cell_integral()
 
3766
  projection_1_cell_integral_0_quadrature() : ufc::cell_integral()
3751
3767
  {
3752
3768
    // Do nothing
3753
3769
  }
3754
3770
 
3755
3771
  /// Destructor
3756
 
  virtual ~UFC_ProjectionLinearForm_cell_integral_0()
 
3772
  virtual ~projection_1_cell_integral_0_quadrature()
3757
3773
  {
3758
3774
    // Do nothing
3759
3775
  }
3776
3792
    const double J_20 = x[1][2] - x[0][2];
3777
3793
    const double J_21 = x[2][2] - x[0][2];
3778
3794
    const double J_22 = x[3][2] - x[0][2];
3779
 
      
 
3795
    
3780
3796
    // Compute sub determinants
3781
3797
    const double d_00 = J_11*J_22 - J_12*J_21;
3782
3798
    
3783
3799
    const double d_10 = J_02*J_21 - J_01*J_22;
3784
3800
    
3785
3801
    const double d_20 = J_01*J_12 - J_02*J_11;
3786
 
      
 
3802
    
3787
3803
    // Compute determinant of Jacobian
3788
3804
    double detJ = J_00*d_00 + J_10*d_10 + J_20*d_20;
3789
 
      
 
3805
    
3790
3806
    // Compute inverse of Jacobian
3791
3807
    
3792
3808
    // Set scale factor
3793
3809
    const double det = std::abs(detJ);
3794
3810
    
3795
 
    // Number of operations to compute element tensor = 200
3796
 
    // Compute coefficients
3797
 
    const double c0_0_0_0 = w[0][0];
3798
 
    const double c0_0_0_1 = w[0][1];
3799
 
    const double c0_0_0_2 = w[0][2];
3800
 
    const double c0_0_0_3 = w[0][3];
3801
 
    const double c0_0_0_4 = w[0][4];
3802
 
    const double c0_0_0_5 = w[0][5];
3803
 
    const double c0_0_0_6 = w[0][6];
3804
 
    const double c0_0_0_7 = w[0][7];
3805
 
    const double c0_0_0_8 = w[0][8];
3806
 
    const double c0_0_0_9 = w[0][9];
3807
 
    
3808
 
    // Compute geometry tensors
3809
 
    // Number of operations to compute decalrations = 10
3810
 
    const double G0_0 = det*c0_0_0_0;
3811
 
    const double G0_1 = det*c0_0_0_1;
3812
 
    const double G0_2 = det*c0_0_0_2;
3813
 
    const double G0_3 = det*c0_0_0_3;
3814
 
    const double G0_4 = det*c0_0_0_4;
3815
 
    const double G0_5 = det*c0_0_0_5;
3816
 
    const double G0_6 = det*c0_0_0_6;
3817
 
    const double G0_7 = det*c0_0_0_7;
3818
 
    const double G0_8 = det*c0_0_0_8;
3819
 
    const double G0_9 = det*c0_0_0_9;
3820
 
    
3821
 
    // Compute element tensor
3822
 
    // Number of operations to compute tensor = 190
3823
 
    A[0] = 0.00238095238095237*G0_0 + 0.000396825396825395*G0_1 + 0.000396825396825396*G0_2 + 0.000396825396825396*G0_3 - 0.00238095238095238*G0_4 - 0.00238095238095238*G0_5 - 0.00238095238095238*G0_6 - 0.00158730158730158*G0_7 - 0.00158730158730158*G0_8 - 0.00158730158730158*G0_9;
3824
 
    A[1] = 0.000396825396825395*G0_0 + 0.00238095238095238*G0_1 + 0.000396825396825396*G0_2 + 0.000396825396825396*G0_3 - 0.00238095238095238*G0_4 - 0.00158730158730158*G0_5 - 0.00158730158730158*G0_6 - 0.00238095238095237*G0_7 - 0.00238095238095237*G0_8 - 0.00158730158730158*G0_9;
3825
 
    A[2] = 0.000396825396825396*G0_0 + 0.000396825396825396*G0_1 + 0.00238095238095238*G0_2 + 0.000396825396825398*G0_3 - 0.00158730158730159*G0_4 - 0.00238095238095238*G0_5 - 0.00158730158730159*G0_6 - 0.00238095238095238*G0_7 - 0.00158730158730159*G0_8 - 0.00238095238095238*G0_9;
3826
 
    A[3] = 0.000396825396825396*G0_0 + 0.000396825396825396*G0_1 + 0.000396825396825398*G0_2 + 0.00238095238095238*G0_3 - 0.00158730158730159*G0_4 - 0.00158730158730159*G0_5 - 0.00238095238095238*G0_6 - 0.00158730158730159*G0_7 - 0.00238095238095238*G0_8 - 0.00238095238095238*G0_9;
3827
 
    A[4] = -0.00238095238095238*G0_0 - 0.00238095238095237*G0_1 - 0.00158730158730159*G0_2 - 0.00158730158730159*G0_3 + 0.0126984126984127*G0_4 + 0.00634920634920634*G0_5 + 0.00634920634920635*G0_6 + 0.00634920634920634*G0_7 + 0.00634920634920634*G0_8 + 0.00317460317460317*G0_9;
3828
 
    A[5] = -0.00238095238095238*G0_0 - 0.00158730158730158*G0_1 - 0.00238095238095238*G0_2 - 0.00158730158730159*G0_3 + 0.00634920634920634*G0_4 + 0.0126984126984127*G0_5 + 0.00634920634920635*G0_6 + 0.00634920634920634*G0_7 + 0.00317460317460317*G0_8 + 0.00634920634920634*G0_9;
3829
 
    A[6] = -0.00238095238095238*G0_0 - 0.00158730158730158*G0_1 - 0.00158730158730159*G0_2 - 0.00238095238095238*G0_3 + 0.00634920634920635*G0_4 + 0.00634920634920635*G0_5 + 0.0126984126984127*G0_6 + 0.00317460317460317*G0_7 + 0.00634920634920634*G0_8 + 0.00634920634920634*G0_9;
3830
 
    A[7] = -0.00158730158730158*G0_0 - 0.00238095238095237*G0_1 - 0.00238095238095238*G0_2 - 0.00158730158730159*G0_3 + 0.00634920634920634*G0_4 + 0.00634920634920634*G0_5 + 0.00317460317460317*G0_6 + 0.0126984126984127*G0_7 + 0.00634920634920634*G0_8 + 0.00634920634920633*G0_9;
3831
 
    A[8] = -0.00158730158730158*G0_0 - 0.00238095238095237*G0_1 - 0.00158730158730159*G0_2 - 0.00238095238095238*G0_3 + 0.00634920634920634*G0_4 + 0.00317460317460317*G0_5 + 0.00634920634920634*G0_6 + 0.00634920634920634*G0_7 + 0.0126984126984127*G0_8 + 0.00634920634920634*G0_9;
3832
 
    A[9] = -0.00158730158730158*G0_0 - 0.00158730158730158*G0_1 - 0.00238095238095238*G0_2 - 0.00238095238095238*G0_3 + 0.00317460317460317*G0_4 + 0.00634920634920634*G0_5 + 0.00634920634920634*G0_6 + 0.00634920634920633*G0_7 + 0.00634920634920634*G0_8 + 0.0126984126984127*G0_9;
 
3811
    
 
3812
    // Array of quadrature weights
 
3813
    static const double W27[27] = {0.00877047492965105, 0.00816265076654668, 0.0016716811314837, 0.0100061425721761, 0.00931268237947044, 0.00190720341498178, 0.00304787709051818, 0.00283664869563092, 0.000580935315837384, 0.0140327598874417, 0.0130602412264747, 0.00267468981037392, 0.0160098281154818, 0.0149002918071527, 0.00305152546397085, 0.0048766033448291, 0.00453863791300947, 0.000929496505339815, 0.00877047492965105, 0.00816265076654668, 0.0016716811314837, 0.0100061425721761, 0.00931268237947044, 0.00190720341498178, 0.00304787709051818, 0.00283664869563092, 0.000580935315837384};
 
3814
    // Quadrature points on the UFC reference element: (0.0952198798417149, 0.0821215678634425, 0.0729940240731498), (0.0670742417520586, 0.0578476039361427, 0.347003766038352), (0.0303014811742758, 0.0261332522867349, 0.705002209888498), (0.0616960186091465, 0.379578230280591, 0.0729940240731498), (0.0434595556538024, 0.267380320411884, 0.347003766038352), (0.0196333029354845, 0.120791820133903, 0.705002209888498), (0.0221843026408197, 0.730165028047632, 0.0729940240731498), (0.0156269392579017, 0.514338662174092, 0.347003766038352), (0.00705963113955477, 0.232357800579865, 0.705002209888498), (0.422442204031704, 0.0821215678634425, 0.0729940240731498), (0.297574315012753, 0.0578476039361427, 0.347003766038352), (0.134432268912383, 0.0261332522867349, 0.705002209888498), (0.27371387282313, 0.379578230280591, 0.0729940240731498), (0.192807956774882, 0.267380320411884, 0.347003766038352), (0.0871029849887995, 0.120791820133903, 0.705002209888498), (0.0984204739396093, 0.730165028047632, 0.0729940240731498), (0.0693287858937781, 0.514338662174092, 0.347003766038352), (0.0313199947658185, 0.232357800579865, 0.705002209888498), (0.749664528221693, 0.0821215678634425, 0.0729940240731498), (0.528074388273447, 0.0578476039361427, 0.347003766038352), (0.238563056650491, 0.0261332522867349, 0.705002209888498), (0.485731727037113, 0.379578230280591, 0.0729940240731498), (0.342156357895961, 0.267380320411884, 0.347003766038352), (0.154572667042115, 0.120791820133903, 0.705002209888498), (0.174656645238399, 0.730165028047632, 0.0729940240731498), (0.123030632529655, 0.514338662174092, 0.347003766038352), (0.0555803583920821, 0.232357800579865, 0.705002209888498)
 
3815
    
 
3816
    // Value of basis functions at quadrature points.
 
3817
    static const double FE0[27][10] = \
 
3818
    {{0.374329281526014, -0.0770862288075737, -0.0686336640467425, -0.0623377689723666, 0.0239775348061957, 0.0278019288056343, 0.031278423297481, 0.218884122479203, 0.246254505716693, 0.285531865195462},
 
3819
    {0.0296507308273033, -0.0580763339388314, -0.051154913373837, -0.106180538748753, 0.080293345688546, 0.0931000579685248, 0.0155203366847607, 0.73297520591714, 0.122191352246653, 0.141680756728494},
 
3820
    {-0.12473839265364, -0.0284651216515658, -0.0247673585365706, 0.289054022006834, 0.073696002454887, 0.0854504447630366, 0.00316750500875638, 0.672749928545405, 0.0249377141829676, 0.0289152558798901},
 
3821
    {-0.0138611057361999, -0.0540832211847061, -0.0914189644747004, -0.0623377689723666, 0.11082776991498, 0.0180137626702941, 0.0936738622360728, 0.141822053505759, 0.737492757359529, 0.119870854681338},
 
3822
    {-0.108014411398703, -0.0396820896985505, -0.12439584892476, -0.106180538748753, 0.37112791258986, 0.0603225179288912, 0.0464809196626873, 0.474918179055459, 0.365943506420742, 0.0594798531131275},
 
3823
    {-0.10678724824909, -0.0188623697671714, -0.0916104925113804, 0.289054022006834, 0.340634000523421, 0.0553660878277077, 0.00948616958726985, 0.435896287412199, 0.0746844551798748, 0.0121390879903345},
 
3824
    {-0.113646757786535, -0.0212000160735007, 0.336116908319966, -0.0623377689723666, 0.213190734538724, 0.00647728608404015, 0.0647928078398051, 0.050995565468269, 0.510112697076803, 0.0154985435047957},
 
3825
    {-0.0927575594483608, -0.0151385367967613, 0.0147498566399773, -0.106180538748753, 0.71390981117415, 0.0216904270965778, 0.0321501561271397, 0.170768371303483, 0.253117643766939, 0.00769036888560855},
 
3826
    {-0.0494020059140976, -0.0069599543559016, -0.12437750559924, 0.289054022006834, 0.655251051574542, 0.0199082222175352, 0.00656144145796827, 0.156737101971251, 0.0516581193256993, 0.00156950731540946},
 
3827
    {-0.0655273725373765, -0.0655273725373763, -0.0686336640467425, -0.0623377689723666, 0.0239775348061957, 0.123343025642419, 0.138766464507087, 0.123343025642418, 0.138766464507087, 0.713829662988655},
 
3828
    {-0.120473369102135, -0.120473369102135, -0.051154913373837, -0.106180538748753, 0.080293345688546, 0.413037631942832, 0.0688558444657068, 0.413037631942832, 0.0688558444657067, 0.354201891821236},
 
3829
    {-0.0982881990625207, -0.0982881990625206, -0.0247673585365706, 0.289054022006834, 0.073696002454887, 0.379100186654221, 0.014052609595862, 0.379100186654221, 0.014052609595862, 0.0722881396997254},
 
3830
    {-0.123875304471457, -0.123875304471457, -0.0914189644747004, -0.0623377689723666, 0.11082776991498, 0.0799179080880264, 0.415583309797801, 0.0799179080880263, 0.415583309797801, 0.299677136703346},
 
3831
    {-0.118458140383472, -0.118458140383472, -0.12439584892476, -0.106180538748753, 0.37112791258986, 0.267620348492175, 0.206212213041715, 0.267620348492175, 0.206212213041715, 0.148699632782819},
 
3832
    {-0.0719291250008815, -0.0719291250008814, -0.0916104925113804, 0.289054022006834, 0.340634000523421, 0.245631187619954, 0.0420853123835723, 0.245631187619954, 0.0420853123835723, 0.0303477199758362},
 
3833
    {-0.0790472945586147, -0.0790472945586147, 0.336116908319966, -0.0623377689723666, 0.213190734538724, 0.0287364257761546, 0.287452752458304, 0.0287364257761545, 0.287452752458304, 0.0387463587619893},
 
3834
    {-0.0597158247867675, -0.0597158247867675, 0.0147498566399773, -0.106180538748753, 0.71390981117415, 0.0962293992000304, 0.14263389994704, 0.0962293992000302, 0.142633899947039, 0.0192259222140213},
 
3835
    {-0.0293581106215567, -0.0293581106215567, -0.12437750559924, 0.289054022006834, 0.655251051574542, 0.088322662094393, 0.0291097803918338, 0.088322662094393, 0.0291097803918338, 0.00392376828852362},
 
3836
    {-0.0770862288075737, 0.374329281526014, -0.0686336640467425, -0.0623377689723666, 0.0239775348061957, 0.218884122479203, 0.246254505716693, 0.0278019288056342, 0.031278423297481, 0.285531865195462},
 
3837
    {-0.0580763339388313, 0.0296507308273035, -0.051154913373837, -0.106180538748753, 0.080293345688546, 0.73297520591714, 0.122191352246653, 0.0931000579685245, 0.0155203366847607, 0.141680756728494},
 
3838
    {-0.0284651216515658, -0.12473839265364, -0.0247673585365706, 0.289054022006834, 0.073696002454887, 0.672749928545405, 0.0249377141829676, 0.0854504447630365, 0.00316750500875635, 0.0289152558798901},
 
3839
    {-0.0540832211847061, -0.0138611057361997, -0.0914189644747004, -0.0623377689723666, 0.11082776991498, 0.141822053505759, 0.737492757359529, 0.018013762670294, 0.0936738622360726, 0.119870854681338},
 
3840
    {-0.0396820896985505, -0.108014411398703, -0.12439584892476, -0.106180538748753, 0.37112791258986, 0.474918179055459, 0.365943506420742, 0.060322517928891, 0.0464809196626872, 0.0594798531131274},
 
3841
    {-0.0188623697671715, -0.10678724824909, -0.0916104925113804, 0.289054022006834, 0.340634000523421, 0.435896287412199, 0.0746844551798748, 0.0553660878277076, 0.00948616958726982, 0.0121390879903345},
 
3842
    {-0.0212000160735008, -0.113646757786535, 0.336116908319966, -0.0623377689723666, 0.213190734538724, 0.0509955654682691, 0.510112697076803, 0.00647728608404003, 0.064792807839805, 0.0154985435047956},
 
3843
    {-0.0151385367967614, -0.0927575594483608, 0.0147498566399773, -0.106180538748753, 0.71390981117415, 0.170768371303483, 0.25311764376694, 0.0216904270965776, 0.0321501561271396, 0.00769036888560852},
 
3844
    {-0.00695995435590172, -0.0494020059140975, -0.12437750559924, 0.289054022006834, 0.655251051574542, 0.156737101971251, 0.0516581193256993, 0.0199082222175353, 0.00656144145796829, 0.00156950731540947}};
 
3845
    
 
3846
    
 
3847
    // Compute element tensor using UFL quadrature representation
 
3848
    // Optimisations: ('simplify expressions', True), ('ignore zero tables', True), ('non zero columns', True), ('remove zero terms', True), ('ignore ones', True)
 
3849
    // Total number of operations to compute element tensor: 1134
 
3850
    
 
3851
    // Loop quadrature points for integral
 
3852
    // Number of operations to compute element tensor for following IP loop = 1134
 
3853
    for (unsigned int ip = 0; ip < 27; ip++)
 
3854
    {
 
3855
      
 
3856
      // Function declarations
 
3857
      double F0 = 0;
 
3858
      
 
3859
      // Total number of operations to compute function values = 20
 
3860
      for (unsigned int r = 0; r < 10; r++)
 
3861
      {
 
3862
        F0 += FE0[ip][r]*w[0][r];
 
3863
      }// end loop over 'r'
 
3864
      
 
3865
      // Number of operations to compute ip constants: 2
 
3866
      // Number of operations: 2
 
3867
      const double Gip0 = F0*W27[ip]*det;
 
3868
      
 
3869
      
 
3870
      // Number of operations for primary indices = 20
 
3871
      for (unsigned int j = 0; j < 10; j++)
 
3872
      {
 
3873
        // Number of operations to compute entry = 2
 
3874
        A[j] += FE0[ip][j]*Gip0;
 
3875
      }// end loop over 'j'
 
3876
    }// end loop over 'ip'
 
3877
  }
 
3878
 
 
3879
};
 
3880
 
 
3881
/// This class defines the interface for the tabulation of the cell
 
3882
/// tensor corresponding to the local contribution to a form from
 
3883
/// the integral over a cell.
 
3884
 
 
3885
class projection_1_cell_integral_0: public ufc::cell_integral
 
3886
{
 
3887
private:
 
3888
 
 
3889
  projection_1_cell_integral_0_quadrature integral_0_quadrature;
 
3890
 
 
3891
public:
 
3892
 
 
3893
  /// Constructor
 
3894
  projection_1_cell_integral_0() : ufc::cell_integral()
 
3895
  {
 
3896
    // Do nothing
 
3897
  }
 
3898
 
 
3899
  /// Destructor
 
3900
  virtual ~projection_1_cell_integral_0()
 
3901
  {
 
3902
    // Do nothing
 
3903
  }
 
3904
 
 
3905
  /// Tabulate the tensor for the contribution from a local cell
 
3906
  virtual void tabulate_tensor(double* A,
 
3907
                               const double * const * w,
 
3908
                               const ufc::cell& c) const
 
3909
  {
 
3910
    // Reset values of the element tensor block
 
3911
    for (unsigned int j = 0; j < 10; j++)
 
3912
      A[j] = 0;
 
3913
    
 
3914
    // Add all contributions to element tensor
 
3915
    integral_0_quadrature.tabulate_tensor(A, w, c);
3833
3916
  }
3834
3917
 
3835
3918
};
3849
3932
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
3850
3933
/// fixed functions (coefficients).
3851
3934
 
3852
 
class UFC_ProjectionLinearForm: public ufc::form
 
3935
class projection_form_1: public ufc::form
3853
3936
{
3854
3937
public:
3855
3938
 
3856
3939
  /// Constructor
3857
 
  UFC_ProjectionLinearForm() : ufc::form()
 
3940
  projection_form_1() : ufc::form()
3858
3941
  {
3859
3942
    // Do nothing
3860
3943
  }
3861
3944
 
3862
3945
  /// Destructor
3863
 
  virtual ~UFC_ProjectionLinearForm()
 
3946
  virtual ~projection_form_1()
3864
3947
  {
3865
3948
    // Do nothing
3866
3949
  }
3868
3951
  /// Return a string identifying the form
3869
3952
  virtual const char* signature() const
3870
3953
  {
3871
 
    return "w0_a0[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | vi0[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]*va0[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]*dX(0)";
 
3954
    return "Form([Integral(Product(BasisFunction(FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2), 0), Function(FiniteElement('Lagrange', Cell('tetrahedron', 1, Space(3)), 2), 0)), Measure('cell', 0, None))])";
3872
3955
  }
3873
3956
 
3874
3957
  /// Return the rank of the global tensor (r)
3888
3971
  {
3889
3972
    return 1;
3890
3973
  }
3891
 
  
 
3974
 
3892
3975
  /// Return the number of exterior facet integrals
3893
3976
  virtual unsigned int num_exterior_facet_integrals() const
3894
3977
  {
3895
3978
    return 0;
3896
3979
  }
3897
 
  
 
3980
 
3898
3981
  /// Return the number of interior facet integrals
3899
3982
  virtual unsigned int num_interior_facet_integrals() const
3900
3983
  {
3901
3984
    return 0;
3902
3985
  }
3903
 
    
 
3986
 
3904
3987
  /// Create a new finite element for argument function i
3905
3988
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
3906
3989
  {
3907
3990
    switch ( i )
3908
3991
    {
3909
3992
    case 0:
3910
 
      return new UFC_ProjectionLinearForm_finite_element_0();
 
3993
      return new projection_1_finite_element_0();
3911
3994
      break;
3912
3995
    case 1:
3913
 
      return new UFC_ProjectionLinearForm_finite_element_1();
 
3996
      return new projection_1_finite_element_1();
3914
3997
      break;
3915
3998
    }
3916
3999
    return 0;
3917
4000
  }
3918
 
  
 
4001
 
3919
4002
  /// Create a new dof map for argument function i
3920
4003
  virtual ufc::dof_map* create_dof_map(unsigned int i) const
3921
4004
  {
3922
4005
    switch ( i )
3923
4006
    {
3924
4007
    case 0:
3925
 
      return new UFC_ProjectionLinearForm_dof_map_0();
 
4008
      return new projection_1_dof_map_0();
3926
4009
      break;
3927
4010
    case 1:
3928
 
      return new UFC_ProjectionLinearForm_dof_map_1();
 
4011
      return new projection_1_dof_map_1();
3929
4012
      break;
3930
4013
    }
3931
4014
    return 0;
3934
4017
  /// Create a new cell integral on sub domain i
3935
4018
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
3936
4019
  {
3937
 
    return new UFC_ProjectionLinearForm_cell_integral_0();
 
4020
    return new projection_1_cell_integral_0();
3938
4021
  }
3939
4022
 
3940
4023
  /// Create a new exterior facet integral on sub domain i
3953
4036
 
3954
4037
// DOLFIN wrappers
3955
4038
 
3956
 
#include <dolfin/fem/Form.h>
 
4039
// Standard library includes
 
4040
#include <string>
 
4041
 
 
4042
// DOLFIN includes
 
4043
#include <dolfin/common/NoDeleter.h>
3957
4044
#include <dolfin/fem/FiniteElement.h>
3958
4045
#include <dolfin/fem/DofMap.h>
3959
 
#include <dolfin/function/Coefficient.h>
3960
 
#include <dolfin/function/Function.h>
 
4046
#include <dolfin/fem/Form.h>
3961
4047
#include <dolfin/function/FunctionSpace.h>
3962
 
 
3963
 
class ProjectionBilinearFormFunctionSpace0 : public dolfin::FunctionSpace
3964
 
{
3965
 
public:
3966
 
 
3967
 
  ProjectionBilinearFormFunctionSpace0(const dolfin::Mesh& mesh)
3968
 
    : dolfin::FunctionSpace(boost::shared_ptr<const dolfin::Mesh>(&mesh, dolfin::NoDeleter<const dolfin::Mesh>()),
3969
 
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new UFC_ProjectionLinearForm_finite_element_1()))),
3970
 
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new UFC_ProjectionLinearForm_dof_map_1()), mesh)))
3971
 
  {
3972
 
    // Do nothing
3973
 
  }
3974
 
 
3975
 
};
3976
 
 
3977
 
class ProjectionBilinearFormFunctionSpace1 : public dolfin::FunctionSpace
3978
 
{
3979
 
public:
3980
 
 
3981
 
  ProjectionBilinearFormFunctionSpace1(const dolfin::Mesh& mesh)
3982
 
    : dolfin::FunctionSpace(boost::shared_ptr<const dolfin::Mesh>(&mesh, dolfin::NoDeleter<const dolfin::Mesh>()),
3983
 
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new UFC_ProjectionLinearForm_finite_element_1()))),
3984
 
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new UFC_ProjectionLinearForm_dof_map_1()), mesh)))
3985
 
  {
3986
 
    // Do nothing
3987
 
  }
3988
 
 
3989
 
};
3990
 
 
3991
 
class ProjectionLinearFormFunctionSpace0 : public dolfin::FunctionSpace
3992
 
{
3993
 
public:
3994
 
 
3995
 
  ProjectionLinearFormFunctionSpace0(const dolfin::Mesh& mesh)
3996
 
    : dolfin::FunctionSpace(boost::shared_ptr<const dolfin::Mesh>(&mesh, dolfin::NoDeleter<const dolfin::Mesh>()),
3997
 
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new UFC_ProjectionLinearForm_finite_element_1()))),
3998
 
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new UFC_ProjectionLinearForm_dof_map_1()), mesh)))
3999
 
  {
4000
 
    // Do nothing
4001
 
  }
4002
 
 
4003
 
};
4004
 
 
4005
 
class ProjectionLinearFormCoefficientSpace0 : public dolfin::FunctionSpace
4006
 
{
4007
 
public:
4008
 
 
4009
 
  ProjectionLinearFormCoefficientSpace0(const dolfin::Mesh& mesh)
4010
 
    : dolfin::FunctionSpace(boost::shared_ptr<const dolfin::Mesh>(&mesh, dolfin::NoDeleter<const dolfin::Mesh>()),
4011
 
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new UFC_ProjectionLinearForm_finite_element_1()))),
4012
 
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new UFC_ProjectionLinearForm_dof_map_1()), mesh)))
4013
 
  {
4014
 
    // Do nothing
4015
 
  }
4016
 
 
4017
 
};
4018
 
 
4019
 
class ProjectionTestSpace : public dolfin::FunctionSpace
4020
 
{
4021
 
public:
4022
 
 
4023
 
  ProjectionTestSpace(const dolfin::Mesh& mesh)
4024
 
    : dolfin::FunctionSpace(boost::shared_ptr<const dolfin::Mesh>(&mesh, dolfin::NoDeleter<const dolfin::Mesh>()),
4025
 
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new UFC_ProjectionLinearForm_finite_element_1()))),
4026
 
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new UFC_ProjectionLinearForm_dof_map_1()), mesh)))
4027
 
  {
4028
 
    // Do nothing
4029
 
  }
4030
 
 
4031
 
};
4032
 
 
4033
 
class ProjectionTrialSpace : public dolfin::FunctionSpace
4034
 
{
4035
 
public:
4036
 
 
4037
 
  ProjectionTrialSpace(const dolfin::Mesh& mesh)
4038
 
    : dolfin::FunctionSpace(boost::shared_ptr<const dolfin::Mesh>(&mesh, dolfin::NoDeleter<const dolfin::Mesh>()),
4039
 
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new UFC_ProjectionLinearForm_finite_element_1()))),
4040
 
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new UFC_ProjectionLinearForm_dof_map_1()), mesh)))
4041
 
  {
4042
 
    // Do nothing
4043
 
  }
4044
 
 
4045
 
};
4046
 
 
4047
 
class ProjectionCoefficientSpace : public dolfin::FunctionSpace
4048
 
{
4049
 
public:
4050
 
 
4051
 
  ProjectionCoefficientSpace(const dolfin::Mesh& mesh)
4052
 
    : dolfin::FunctionSpace(boost::shared_ptr<const dolfin::Mesh>(&mesh, dolfin::NoDeleter<const dolfin::Mesh>()),
4053
 
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new UFC_ProjectionLinearForm_finite_element_1()))),
4054
 
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new UFC_ProjectionLinearForm_dof_map_1()), mesh)))
4055
 
  {
4056
 
    // Do nothing
4057
 
  }
4058
 
 
4059
 
};
4060
 
 
4061
 
class ProjectionFunctionSpace : public dolfin::FunctionSpace
4062
 
{
4063
 
public:
4064
 
 
4065
 
  ProjectionFunctionSpace(const dolfin::Mesh& mesh)
4066
 
    : dolfin::FunctionSpace(boost::shared_ptr<const dolfin::Mesh>(&mesh, dolfin::NoDeleter<const dolfin::Mesh>()),
4067
 
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new UFC_ProjectionLinearForm_finite_element_1()))),
4068
 
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new UFC_ProjectionLinearForm_dof_map_1()), mesh)))
4069
 
  {
4070
 
    // Do nothing
4071
 
  }
4072
 
 
4073
 
};
4074
 
 
4075
 
class ProjectionBilinearForm : public dolfin::Form
4076
 
{
4077
 
public:
4078
 
 
4079
 
  // Create form on given function space(s)
4080
 
  ProjectionBilinearForm(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1) : dolfin::Form()
4081
 
  {
4082
 
    boost::shared_ptr<const dolfin::FunctionSpace> _V0(&V0, dolfin::NoDeleter<const dolfin::FunctionSpace>());
4083
 
    _function_spaces.push_back(_V0);
4084
 
    boost::shared_ptr<const dolfin::FunctionSpace> _V1(&V1, dolfin::NoDeleter<const dolfin::FunctionSpace>());
4085
 
    _function_spaces.push_back(_V1);
4086
 
 
4087
 
    _ufc_form = boost::shared_ptr<const ufc::form>(new UFC_ProjectionBilinearForm());
4088
 
  }
4089
 
 
4090
 
  // Create form on given function space(s) (shared data)
4091
 
  ProjectionBilinearForm(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1) : dolfin::Form()
4092
 
  {
4093
 
    _function_spaces.push_back(V0);
4094
 
    _function_spaces.push_back(V1);
4095
 
 
4096
 
    _ufc_form = boost::shared_ptr<const ufc::form>(new UFC_ProjectionBilinearForm());
4097
 
  }
4098
 
 
4099
 
  // Destructor
4100
 
  ~ProjectionBilinearForm() {}
4101
 
 
4102
 
};
4103
 
 
4104
 
class ProjectionLinearFormCoefficient0 : public dolfin::Coefficient
4105
 
{
4106
 
public:
4107
 
 
4108
 
  // Constructor
4109
 
  ProjectionLinearFormCoefficient0(dolfin::Form& form) : dolfin::Coefficient(form) {}
4110
 
 
4111
 
  // Destructor  
4112
 
  ~ProjectionLinearFormCoefficient0() {}
4113
 
 
4114
 
  // Attach function to coefficient
4115
 
  const ProjectionLinearFormCoefficient0& operator= (dolfin::Function& v)
4116
 
  {
4117
 
    attach(v);
4118
 
    return *this;
4119
 
  }
4120
 
 
4121
 
  /// Create function space for coefficient
4122
 
  const dolfin::FunctionSpace* create_function_space() const
4123
 
  {
4124
 
    return new ProjectionLinearFormCoefficientSpace0(form.mesh());
4125
 
  }
4126
 
  
4127
 
  /// Return coefficient number
4128
 
  dolfin::uint number() const
4129
 
  {
4130
 
    return 0;
4131
 
  }
4132
 
  
4133
 
  /// Return coefficient name
4134
 
  virtual std::string name() const
4135
 
  {
4136
 
    return "f";
4137
 
  }
4138
 
  
4139
 
};
4140
 
class ProjectionLinearForm : public dolfin::Form
4141
 
{
4142
 
public:
4143
 
 
4144
 
  // Create form on given function space(s)
4145
 
  ProjectionLinearForm(const dolfin::FunctionSpace& V0) : dolfin::Form(), f(*this)
4146
 
  {
4147
 
    boost::shared_ptr<const dolfin::FunctionSpace> _V0(&V0, dolfin::NoDeleter<const dolfin::FunctionSpace>());
4148
 
    _function_spaces.push_back(_V0);
4149
 
 
4150
 
    _coefficients.push_back(boost::shared_ptr<const dolfin::Function>(static_cast<const dolfin::Function*>(0)));
4151
 
 
4152
 
    _ufc_form = boost::shared_ptr<const ufc::form>(new UFC_ProjectionLinearForm());
4153
 
  }
4154
 
 
4155
 
  // Create form on given function space(s) (shared data)
4156
 
  ProjectionLinearForm(boost::shared_ptr<const dolfin::FunctionSpace> V0) : dolfin::Form(), f(*this)
4157
 
  {
4158
 
    _function_spaces.push_back(V0);
4159
 
 
4160
 
    _coefficients.push_back(boost::shared_ptr<const dolfin::Function>(static_cast<const dolfin::Function*>(0)));
4161
 
 
4162
 
    _ufc_form = boost::shared_ptr<const ufc::form>(new UFC_ProjectionLinearForm());
4163
 
  }
4164
 
 
4165
 
  // Create form on given function space(s) with given coefficient(s)
4166
 
  ProjectionLinearForm(const dolfin::FunctionSpace& V0, dolfin::Function& w0) : dolfin::Form(), f(*this)
4167
 
  {
4168
 
    boost::shared_ptr<const dolfin::FunctionSpace> _V0(&V0, dolfin::NoDeleter<const dolfin::FunctionSpace>());
4169
 
    _function_spaces.push_back(_V0);
4170
 
 
4171
 
    _coefficients.push_back(boost::shared_ptr<const dolfin::Function>(static_cast<const dolfin::Function*>(0)));
4172
 
 
4173
 
    this->f = w0;
4174
 
 
4175
 
    _ufc_form = boost::shared_ptr<const ufc::form>(new UFC_ProjectionLinearForm());
4176
 
  }
4177
 
 
4178
 
  // Create form on given function space(s) with given coefficient(s) (shared data)
4179
 
  ProjectionLinearForm(boost::shared_ptr<const dolfin::FunctionSpace> V0, dolfin::Function& w0) : dolfin::Form(), f(*this)
4180
 
  {
4181
 
    _function_spaces.push_back(V0);
4182
 
 
4183
 
    _coefficients.push_back(boost::shared_ptr<const dolfin::Function>(static_cast<const dolfin::Function*>(0)));
4184
 
 
4185
 
    this->f = w0;
4186
 
 
4187
 
    _ufc_form = boost::shared_ptr<const ufc::form>(new UFC_ProjectionLinearForm());
4188
 
  }
4189
 
 
4190
 
  // Destructor
4191
 
  ~ProjectionLinearForm() {}
4192
 
 
4193
 
  // Coefficients
4194
 
  ProjectionLinearFormCoefficient0 f;
4195
 
 
4196
 
};
 
4048
#include <dolfin/function/GenericFunction.h>
 
4049
#include <dolfin/function/CoefficientAssigner.h>
 
4050
 
 
4051
namespace Projection
 
4052
{
 
4053
 
 
4054
class CoefficientSpace_f: public dolfin::FunctionSpace
 
4055
{
 
4056
public:
 
4057
 
 
4058
  CoefficientSpace_f(const dolfin::Mesh& mesh):
 
4059
      dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
4060
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_1_finite_element_1()))),
 
4061
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_1_dof_map_1()), dolfin::reference_to_no_delete_pointer(mesh))))
 
4062
  {
 
4063
    // Do nothing
 
4064
  }
 
4065
 
 
4066
  CoefficientSpace_f(dolfin::Mesh& mesh):
 
4067
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
4068
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_1_finite_element_1()))),
 
4069
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_1_dof_map_1()), dolfin::reference_to_no_delete_pointer(mesh))))
 
4070
  {
 
4071
    // Do nothing
 
4072
  }
 
4073
 
 
4074
  CoefficientSpace_f(boost::shared_ptr<dolfin::Mesh> mesh):
 
4075
      dolfin::FunctionSpace(mesh,
 
4076
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_1_finite_element_1()))),
 
4077
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_1_dof_map_1()), mesh)))
 
4078
  {
 
4079
      // Do nothing
 
4080
  }
 
4081
 
 
4082
  CoefficientSpace_f(boost::shared_ptr<const dolfin::Mesh> mesh):
 
4083
      dolfin::FunctionSpace(mesh,
 
4084
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_1_finite_element_1()))),
 
4085
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_1_dof_map_1()), mesh)))
 
4086
  {
 
4087
      // Do nothing
 
4088
  }
 
4089
 
 
4090
 
 
4091
  ~CoefficientSpace_f()
 
4092
  {
 
4093
  }
 
4094
 
 
4095
};
 
4096
 
 
4097
class Form_0_FunctionSpace_0: public dolfin::FunctionSpace
 
4098
{
 
4099
public:
 
4100
 
 
4101
  Form_0_FunctionSpace_0(const dolfin::Mesh& mesh):
 
4102
      dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
4103
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_0_finite_element_0()))),
 
4104
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_0_dof_map_0()), dolfin::reference_to_no_delete_pointer(mesh))))
 
4105
  {
 
4106
    // Do nothing
 
4107
  }
 
4108
 
 
4109
  Form_0_FunctionSpace_0(dolfin::Mesh& mesh):
 
4110
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
4111
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_0_finite_element_0()))),
 
4112
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_0_dof_map_0()), dolfin::reference_to_no_delete_pointer(mesh))))
 
4113
  {
 
4114
    // Do nothing
 
4115
  }
 
4116
 
 
4117
  Form_0_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
4118
      dolfin::FunctionSpace(mesh,
 
4119
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_0_finite_element_0()))),
 
4120
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_0_dof_map_0()), mesh)))
 
4121
  {
 
4122
      // Do nothing
 
4123
  }
 
4124
 
 
4125
  Form_0_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
4126
      dolfin::FunctionSpace(mesh,
 
4127
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_0_finite_element_0()))),
 
4128
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_0_dof_map_0()), mesh)))
 
4129
  {
 
4130
      // Do nothing
 
4131
  }
 
4132
 
 
4133
 
 
4134
  ~Form_0_FunctionSpace_0()
 
4135
  {
 
4136
  }
 
4137
 
 
4138
};
 
4139
 
 
4140
class Form_0_FunctionSpace_1: public dolfin::FunctionSpace
 
4141
{
 
4142
public:
 
4143
 
 
4144
  Form_0_FunctionSpace_1(const dolfin::Mesh& mesh):
 
4145
      dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
4146
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_0_finite_element_1()))),
 
4147
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_0_dof_map_1()), dolfin::reference_to_no_delete_pointer(mesh))))
 
4148
  {
 
4149
    // Do nothing
 
4150
  }
 
4151
 
 
4152
  Form_0_FunctionSpace_1(dolfin::Mesh& mesh):
 
4153
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
4154
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_0_finite_element_1()))),
 
4155
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_0_dof_map_1()), dolfin::reference_to_no_delete_pointer(mesh))))
 
4156
  {
 
4157
    // Do nothing
 
4158
  }
 
4159
 
 
4160
  Form_0_FunctionSpace_1(boost::shared_ptr<dolfin::Mesh> mesh):
 
4161
      dolfin::FunctionSpace(mesh,
 
4162
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_0_finite_element_1()))),
 
4163
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_0_dof_map_1()), mesh)))
 
4164
  {
 
4165
      // Do nothing
 
4166
  }
 
4167
 
 
4168
  Form_0_FunctionSpace_1(boost::shared_ptr<const dolfin::Mesh> mesh):
 
4169
      dolfin::FunctionSpace(mesh,
 
4170
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_0_finite_element_1()))),
 
4171
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_0_dof_map_1()), mesh)))
 
4172
  {
 
4173
      // Do nothing
 
4174
  }
 
4175
 
 
4176
 
 
4177
  ~Form_0_FunctionSpace_1()
 
4178
  {
 
4179
  }
 
4180
 
 
4181
};
 
4182
 
 
4183
class Form_0: public dolfin::Form
 
4184
{
 
4185
public:
 
4186
 
 
4187
  // Constructor
 
4188
  Form_0(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1):
 
4189
    dolfin::Form(2, 0)
 
4190
  {
 
4191
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
4192
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
4193
 
 
4194
    _ufc_form = boost::shared_ptr<const ufc::form>(new projection_form_0());
 
4195
  }
 
4196
 
 
4197
  // Constructor
 
4198
  Form_0(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1):
 
4199
    dolfin::Form(2, 0)
 
4200
  {
 
4201
    _function_spaces[0] = V0;
 
4202
    _function_spaces[1] = V1;
 
4203
 
 
4204
    _ufc_form = boost::shared_ptr<const ufc::form>(new projection_form_0());
 
4205
  }
 
4206
 
 
4207
  // Destructor
 
4208
  ~Form_0()
 
4209
  {}
 
4210
 
 
4211
  /// Return the number of the coefficient with this name
 
4212
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
4213
  {
 
4214
 
 
4215
    dolfin::error("No coefficients.");
 
4216
    return 0;
 
4217
  }
 
4218
 
 
4219
  /// Return the name of the coefficient with this number
 
4220
  virtual std::string coefficient_name(dolfin::uint i) const
 
4221
  {
 
4222
 
 
4223
    dolfin::error("No coefficients.");
 
4224
    return "unnamed";
 
4225
  }
 
4226
 
 
4227
  // Typedefs
 
4228
  typedef Form_0_FunctionSpace_0 TestSpace;
 
4229
  typedef Form_0_FunctionSpace_1 TrialSpace;
 
4230
 
 
4231
  // Coefficients
 
4232
};
 
4233
 
 
4234
class Form_1_FunctionSpace_0: public dolfin::FunctionSpace
 
4235
{
 
4236
public:
 
4237
 
 
4238
  Form_1_FunctionSpace_0(const dolfin::Mesh& mesh):
 
4239
      dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
4240
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_1_finite_element_0()))),
 
4241
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_1_dof_map_0()), dolfin::reference_to_no_delete_pointer(mesh))))
 
4242
  {
 
4243
    // Do nothing
 
4244
  }
 
4245
 
 
4246
  Form_1_FunctionSpace_0(dolfin::Mesh& mesh):
 
4247
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
4248
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_1_finite_element_0()))),
 
4249
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_1_dof_map_0()), dolfin::reference_to_no_delete_pointer(mesh))))
 
4250
  {
 
4251
    // Do nothing
 
4252
  }
 
4253
 
 
4254
  Form_1_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
4255
      dolfin::FunctionSpace(mesh,
 
4256
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_1_finite_element_0()))),
 
4257
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_1_dof_map_0()), mesh)))
 
4258
  {
 
4259
      // Do nothing
 
4260
  }
 
4261
 
 
4262
  Form_1_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
4263
      dolfin::FunctionSpace(mesh,
 
4264
                            boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new projection_1_finite_element_0()))),
 
4265
                            boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dof_map>(new projection_1_dof_map_0()), mesh)))
 
4266
  {
 
4267
      // Do nothing
 
4268
  }
 
4269
 
 
4270
 
 
4271
  ~Form_1_FunctionSpace_0()
 
4272
  {
 
4273
  }
 
4274
 
 
4275
};
 
4276
 
 
4277
typedef CoefficientSpace_f Form_1_FunctionSpace_1;
 
4278
 
 
4279
class Form_1: public dolfin::Form
 
4280
{
 
4281
public:
 
4282
 
 
4283
  // Constructor
 
4284
  Form_1(const dolfin::FunctionSpace& V0):
 
4285
    dolfin::Form(1, 1), f(*this, 0)
 
4286
  {
 
4287
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
4288
 
 
4289
    _ufc_form = boost::shared_ptr<const ufc::form>(new projection_form_1());
 
4290
  }
 
4291
 
 
4292
  // Constructor
 
4293
  Form_1(const dolfin::FunctionSpace& V0, const dolfin::GenericFunction& f):
 
4294
    dolfin::Form(1, 1), f(*this, 0)
 
4295
  {
 
4296
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
4297
 
 
4298
    this->f = f;
 
4299
 
 
4300
    _ufc_form = boost::shared_ptr<const ufc::form>(new projection_form_1());
 
4301
  }
 
4302
 
 
4303
  // Constructor
 
4304
  Form_1(const dolfin::FunctionSpace& V0, boost::shared_ptr<const dolfin::GenericFunction> f):
 
4305
    dolfin::Form(1, 1), f(*this, 0)
 
4306
  {
 
4307
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
4308
 
 
4309
    this->f = *f;
 
4310
 
 
4311
    _ufc_form = boost::shared_ptr<const ufc::form>(new projection_form_1());
 
4312
  }
 
4313
 
 
4314
  // Constructor
 
4315
  Form_1(boost::shared_ptr<const dolfin::FunctionSpace> V0):
 
4316
    dolfin::Form(1, 1), f(*this, 0)
 
4317
  {
 
4318
    _function_spaces[0] = V0;
 
4319
 
 
4320
    _ufc_form = boost::shared_ptr<const ufc::form>(new projection_form_1());
 
4321
  }
 
4322
 
 
4323
  // Constructor
 
4324
  Form_1(boost::shared_ptr<const dolfin::FunctionSpace> V0, const dolfin::GenericFunction& f):
 
4325
    dolfin::Form(1, 1), f(*this, 0)
 
4326
  {
 
4327
    _function_spaces[0] = V0;
 
4328
 
 
4329
    this->f = f;
 
4330
 
 
4331
    _ufc_form = boost::shared_ptr<const ufc::form>(new projection_form_1());
 
4332
  }
 
4333
 
 
4334
  // Constructor
 
4335
  Form_1(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::GenericFunction> f):
 
4336
    dolfin::Form(1, 1), f(*this, 0)
 
4337
  {
 
4338
    _function_spaces[0] = V0;
 
4339
 
 
4340
    this->f = *f;
 
4341
 
 
4342
    _ufc_form = boost::shared_ptr<const ufc::form>(new projection_form_1());
 
4343
  }
 
4344
 
 
4345
  // Destructor
 
4346
  ~Form_1()
 
4347
  {}
 
4348
 
 
4349
  /// Return the number of the coefficient with this name
 
4350
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
4351
  {
 
4352
    if (name == "f")
 
4353
      return 0;
 
4354
 
 
4355
    dolfin::error("Invalid coefficient.");
 
4356
    return 0;
 
4357
  }
 
4358
 
 
4359
  /// Return the name of the coefficient with this number
 
4360
  virtual std::string coefficient_name(dolfin::uint i) const
 
4361
  {
 
4362
    switch (i)
 
4363
    {
 
4364
    case 0:
 
4365
      return "f";
 
4366
    }
 
4367
 
 
4368
    dolfin::error("Invalid coefficient.");
 
4369
    return "unnamed";
 
4370
  }
 
4371
 
 
4372
  // Typedefs
 
4373
  typedef Form_1_FunctionSpace_0 TestSpace;
 
4374
  typedef Form_1_FunctionSpace_1 CoefficientSpace_f;
 
4375
 
 
4376
  // Coefficients
 
4377
  dolfin::CoefficientAssigner f;
 
4378
};
 
4379
 
 
4380
// Class typedefs
 
4381
typedef Form_0 BilinearForm;
 
4382
typedef Form_1 LinearForm;
 
4383
typedef Form_0::TestSpace FunctionSpace;
 
4384
 
 
4385
} // namespace Projection
4197
4386
 
4198
4387
#endif