~ubuntu-branches/ubuntu/natty/dolfin/natty

« back to all changes in this revision

Viewing changes to demo/undocumented/auto-adaptive-poisson/cpp/AdaptivePoisson.h

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2011-02-24 10:34:44 UTC
  • mfrom: (1.1.7 upstream) (14.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110224103444-n3fwnmh32lfoske0
Tags: 0.9.10-1
* New upstream release. This release fixes bug "FTBFS: error:
  'SCOTCH_Dgraph' was not declared in this scope" (closes: #612602).
* debian/control:
  - Add libslepc3.1-dev and libboost-thread-dev to Build-Depends and
    Depends field in binary package libdolfin0-dev.
  - Bump build dependency on python-ufc to >= 2.0.0.
  - Remove Build-Depends-Indep field as upstream no longer ships the
    user manual.
  - Remove old fields Conflicts, Provides, and Replaces from
    libdolfin0-dev, libdolfin0, libdolfin0-dbg, and python-dolfin.
* Remove all patches as they are now incorporated upstream.
* Add dolfin-plot and dolfin-version to debian/dolfin-bin.install.
* Remove .doc-base file since the user manual is removed by upstream.
* Remove targets clean and install/dolfin-doc from debian/rules since
  they are no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This code conforms with the UFC specification version 1.4.2
 
2
// and was automatically generated by FFC version 0.9.4+.
 
3
//
 
4
// This code was generated with the option '-l dolfin' and
 
5
// contains DOLFIN-specific wrappers that depend on DOLFIN.
 
6
// 
 
7
// This code was generated with the following parameters:
 
8
// 
 
9
//   cache_dir:                      ''
 
10
//   convert_exceptions_to_warnings: False
 
11
//   cpp_optimize:                   False
 
12
//   cpp_optimize_flags:             '-O2'
 
13
//   epsilon:                        1e-14
 
14
//   error_control:                  True
 
15
//   form_postfix:                   True
 
16
//   format:                         'dolfin'
 
17
//   log_level:                      10
 
18
//   log_prefix:                     ''
 
19
//   no_ferari:                      True
 
20
//   optimize:                       True
 
21
//   output_dir:                     '.'
 
22
//   precision:                      15
 
23
//   quadrature_degree:              'auto'
 
24
//   quadrature_rule:                'auto'
 
25
//   representation:                 'auto'
 
26
//   split:                          False
 
27
 
 
28
#ifndef __ADAPTIVEPOISSON_H
 
29
#define __ADAPTIVEPOISSON_H
 
30
 
 
31
#include <cmath>
 
32
#include <stdexcept>
 
33
#include <fstream>
 
34
#include <ufc.h>
 
35
 
 
36
/// This class defines the interface for a finite element.
 
37
 
 
38
class adaptivepoisson_finite_element_0: public ufc::finite_element
 
39
{
 
40
public:
 
41
 
 
42
  /// Constructor
 
43
  adaptivepoisson_finite_element_0() : ufc::finite_element()
 
44
  {
 
45
    // Do nothing
 
46
  }
 
47
 
 
48
  /// Destructor
 
49
  virtual ~adaptivepoisson_finite_element_0()
 
50
  {
 
51
    // Do nothing
 
52
  }
 
53
 
 
54
  /// Return a string identifying the finite element
 
55
  virtual const char* signature() const
 
56
  {
 
57
    return "FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0)";
 
58
  }
 
59
 
 
60
  /// Return the cell shape
 
61
  virtual ufc::shape cell_shape() const
 
62
  {
 
63
    return ufc::triangle;
 
64
  }
 
65
 
 
66
  /// Return the topological dimension of the cell shape
 
67
  virtual unsigned int topological_dimension() const
 
68
  {
 
69
    return 2;
 
70
  }
 
71
 
 
72
  /// Return the geometric dimension of the cell shape
 
73
  virtual unsigned int geometric_dimension() const
 
74
  {
 
75
    return 2;
 
76
  }
 
77
 
 
78
  /// Return the dimension of the finite element function space
 
79
  virtual unsigned int space_dimension() const
 
80
  {
 
81
    return 1;
 
82
  }
 
83
 
 
84
  /// Return the rank of the value space
 
85
  virtual unsigned int value_rank() const
 
86
  {
 
87
    return 0;
 
88
  }
 
89
 
 
90
  /// Return the dimension of the value space for axis i
 
91
  virtual unsigned int value_dimension(unsigned int i) const
 
92
  {
 
93
    return 1;
 
94
  }
 
95
 
 
96
  /// Evaluate basis function i at given point in cell
 
97
  virtual void evaluate_basis(unsigned int i,
 
98
                              double* values,
 
99
                              const double* coordinates,
 
100
                              const ufc::cell& c) const
 
101
  {
 
102
    // Extract vertex coordinates
 
103
    
 
104
    // Compute Jacobian of affine map from reference cell
 
105
    
 
106
    // Compute determinant of Jacobian
 
107
    
 
108
    // Compute inverse of Jacobian
 
109
    
 
110
    // Compute constants
 
111
    
 
112
    // Get coordinates and map to the reference (FIAT) element
 
113
    
 
114
    // Reset values.
 
115
    *values = 0.000000000000000;
 
116
    
 
117
    // Array of basisvalues.
 
118
    double basisvalues[1] = {0.000000000000000};
 
119
    
 
120
    // Declare helper variables.
 
121
    
 
122
    // Compute basisvalues.
 
123
    basisvalues[0] = 1.000000000000000;
 
124
    
 
125
    // Table(s) of coefficients.
 
126
    static const double coefficients0[1] = \
 
127
    {1.000000000000000};
 
128
    
 
129
    // Compute value(s).
 
130
    for (unsigned int r = 0; r < 1; r++)
 
131
    {
 
132
      *values += coefficients0[r]*basisvalues[r];
 
133
    }// end loop over 'r'
 
134
  }
 
135
 
 
136
  /// Evaluate all basis functions at given point in cell
 
137
  virtual void evaluate_basis_all(double* values,
 
138
                                  const double* coordinates,
 
139
                                  const ufc::cell& c) const
 
140
  {
 
141
    // Element is constant, calling evaluate_basis.
 
142
    evaluate_basis(0, values, coordinates, c);
 
143
  }
 
144
 
 
145
  /// Evaluate order n derivatives of basis function i at given point in cell
 
146
  virtual void evaluate_basis_derivatives(unsigned int i,
 
147
                                          unsigned int n,
 
148
                                          double* values,
 
149
                                          const double* coordinates,
 
150
                                          const ufc::cell& c) const
 
151
  {
 
152
    // Extract vertex coordinates
 
153
    const double * const * x = c.coordinates;
 
154
    
 
155
    // Compute Jacobian of affine map from reference cell
 
156
    const double J_00 = x[1][0] - x[0][0];
 
157
    const double J_01 = x[2][0] - x[0][0];
 
158
    const double J_10 = x[1][1] - x[0][1];
 
159
    const double J_11 = x[2][1] - x[0][1];
 
160
    
 
161
    // Compute determinant of Jacobian
 
162
    double detJ = J_00*J_11 - J_01*J_10;
 
163
    
 
164
    // Compute inverse of Jacobian
 
165
    const double K_00 =  J_11 / detJ;
 
166
    const double K_01 = -J_01 / detJ;
 
167
    const double K_10 = -J_10 / detJ;
 
168
    const double K_11 =  J_00 / detJ;
 
169
    
 
170
    // Compute constants
 
171
    
 
172
    // Get coordinates and map to the reference (FIAT) element
 
173
    
 
174
    // Compute number of derivatives.
 
175
    unsigned int num_derivatives = 1;
 
176
    for (unsigned int r = 0; r < n; r++)
 
177
    {
 
178
      num_derivatives *= 2;
 
179
    }// end loop over 'r'
 
180
    
 
181
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
182
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
183
    for (unsigned int row = 0; row < num_derivatives; row++)
 
184
    {
 
185
      combinations[row] = new unsigned int [n];
 
186
      for (unsigned int col = 0; col < n; col++)
 
187
        combinations[row][col] = 0;
 
188
    }
 
189
    
 
190
    // Generate combinations of derivatives
 
191
    for (unsigned int row = 1; row < num_derivatives; row++)
 
192
    {
 
193
      for (unsigned int num = 0; num < row; num++)
 
194
      {
 
195
        for (unsigned int col = n-1; col+1 > 0; col--)
 
196
        {
 
197
          if (combinations[row][col] + 1 > 1)
 
198
            combinations[row][col] = 0;
 
199
          else
 
200
          {
 
201
            combinations[row][col] += 1;
 
202
            break;
 
203
          }
 
204
        }
 
205
      }
 
206
    }
 
207
    
 
208
    // Compute inverse of Jacobian
 
209
    const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
 
210
    
 
211
    // Declare transformation matrix
 
212
    // Declare pointer to two dimensional array and initialise
 
213
    double **transform = new double *[num_derivatives];
 
214
    
 
215
    for (unsigned int j = 0; j < num_derivatives; j++)
 
216
    {
 
217
      transform[j] = new double [num_derivatives];
 
218
      for (unsigned int k = 0; k < num_derivatives; k++)
 
219
        transform[j][k] = 1;
 
220
    }
 
221
    
 
222
    // Construct transformation matrix
 
223
    for (unsigned int row = 0; row < num_derivatives; row++)
 
224
    {
 
225
      for (unsigned int col = 0; col < num_derivatives; col++)
 
226
      {
 
227
        for (unsigned int k = 0; k < n; k++)
 
228
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
229
      }
 
230
    }
 
231
    
 
232
    // Reset values. Assuming that values is always an array.
 
233
    for (unsigned int r = 0; r < num_derivatives; r++)
 
234
    {
 
235
      values[r] = 0.000000000000000;
 
236
    }// end loop over 'r'
 
237
    
 
238
    
 
239
    // Array of basisvalues.
 
240
    double basisvalues[1] = {0.000000000000000};
 
241
    
 
242
    // Declare helper variables.
 
243
    
 
244
    // Compute basisvalues.
 
245
    basisvalues[0] = 1.000000000000000;
 
246
    
 
247
    // Table(s) of coefficients.
 
248
    static const double coefficients0[1] = \
 
249
    {1.000000000000000};
 
250
    
 
251
    // Tables of derivatives of the polynomial base (transpose).
 
252
    static const double dmats0[1][1] = \
 
253
    {{0.000000000000000}};
 
254
    
 
255
    static const double dmats1[1][1] = \
 
256
    {{0.000000000000000}};
 
257
    
 
258
    // Compute reference derivatives.
 
259
    // Declare pointer to array of derivatives on FIAT element.
 
260
    double *derivatives = new double[num_derivatives];
 
261
    for (unsigned int r = 0; r < num_derivatives; r++)
 
262
    {
 
263
      derivatives[r] = 0.000000000000000;
 
264
    }// end loop over 'r'
 
265
    
 
266
    // Declare derivative matrix (of polynomial basis).
 
267
    double dmats[1][1] = \
 
268
    {{1.000000000000000}};
 
269
    
 
270
    // Declare (auxiliary) derivative matrix (of polynomial basis).
 
271
    double dmats_old[1][1] = \
 
272
    {{1.000000000000000}};
 
273
    
 
274
    // Loop possible derivatives.
 
275
    for (unsigned int r = 0; r < num_derivatives; r++)
 
276
    {
 
277
      // Resetting dmats values to compute next derivative.
 
278
      for (unsigned int t = 0; t < 1; t++)
 
279
      {
 
280
        for (unsigned int u = 0; u < 1; u++)
 
281
        {
 
282
          dmats[t][u] = 0.000000000000000;
 
283
          if (t == u)
 
284
          {
 
285
          dmats[t][u] = 1.000000000000000;
 
286
          }
 
287
          
 
288
        }// end loop over 'u'
 
289
      }// end loop over 't'
 
290
      
 
291
      // Looping derivative order to generate dmats.
 
292
      for (unsigned int s = 0; s < n; s++)
 
293
      {
 
294
        // Updating dmats_old with new values and resetting dmats.
 
295
        for (unsigned int t = 0; t < 1; t++)
 
296
        {
 
297
          for (unsigned int u = 0; u < 1; u++)
 
298
          {
 
299
            dmats_old[t][u] = dmats[t][u];
 
300
            dmats[t][u] = 0.000000000000000;
 
301
          }// end loop over 'u'
 
302
        }// end loop over 't'
 
303
        
 
304
        // Update dmats using an inner product.
 
305
        if (combinations[r][s] == 0)
 
306
        {
 
307
        for (unsigned int t = 0; t < 1; t++)
 
308
        {
 
309
          for (unsigned int u = 0; u < 1; u++)
 
310
          {
 
311
            for (unsigned int tu = 0; tu < 1; tu++)
 
312
            {
 
313
              dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
314
            }// end loop over 'tu'
 
315
          }// end loop over 'u'
 
316
        }// end loop over 't'
 
317
        }
 
318
        
 
319
        if (combinations[r][s] == 1)
 
320
        {
 
321
        for (unsigned int t = 0; t < 1; t++)
 
322
        {
 
323
          for (unsigned int u = 0; u < 1; u++)
 
324
          {
 
325
            for (unsigned int tu = 0; tu < 1; tu++)
 
326
            {
 
327
              dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
328
            }// end loop over 'tu'
 
329
          }// end loop over 'u'
 
330
        }// end loop over 't'
 
331
        }
 
332
        
 
333
      }// end loop over 's'
 
334
      for (unsigned int s = 0; s < 1; s++)
 
335
      {
 
336
        for (unsigned int t = 0; t < 1; t++)
 
337
        {
 
338
          derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
339
        }// end loop over 't'
 
340
      }// end loop over 's'
 
341
    }// end loop over 'r'
 
342
    
 
343
    // Transform derivatives back to physical element
 
344
    for (unsigned int r = 0; r < num_derivatives; r++)
 
345
    {
 
346
      for (unsigned int s = 0; s < num_derivatives; s++)
 
347
      {
 
348
        values[r] += transform[r][s]*derivatives[s];
 
349
      }// end loop over 's'
 
350
    }// end loop over 'r'
 
351
    
 
352
    // Delete pointer to array of derivatives on FIAT element
 
353
    delete [] derivatives;
 
354
    
 
355
    // Delete pointer to array of combinations of derivatives and transform
 
356
    for (unsigned int r = 0; r < num_derivatives; r++)
 
357
    {
 
358
      delete [] combinations[r];
 
359
    }// end loop over 'r'
 
360
    delete [] combinations;
 
361
    for (unsigned int r = 0; r < num_derivatives; r++)
 
362
    {
 
363
      delete [] transform[r];
 
364
    }// end loop over 'r'
 
365
    delete [] transform;
 
366
  }
 
367
 
 
368
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
369
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
370
                                              double* values,
 
371
                                              const double* coordinates,
 
372
                                              const ufc::cell& c) const
 
373
  {
 
374
    // Element is constant, calling evaluate_basis_derivatives.
 
375
    evaluate_basis_derivatives(0, n, values, coordinates, c);
 
376
  }
 
377
 
 
378
  /// Evaluate linear functional for dof i on the function f
 
379
  virtual double evaluate_dof(unsigned int i,
 
380
                              const ufc::function& f,
 
381
                              const ufc::cell& c) const
 
382
  {
 
383
    // Declare variables for result of evaluation.
 
384
    double vals[1];
 
385
    
 
386
    // Declare variable for physical coordinates.
 
387
    double y[2];
 
388
    const double * const * x = c.coordinates;
 
389
    switch (i)
 
390
    {
 
391
    case 0:
 
392
      {
 
393
        y[0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
 
394
      y[1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
 
395
      f.evaluate(vals, y, c);
 
396
      return vals[0];
 
397
        break;
 
398
      }
 
399
    }
 
400
    
 
401
    return 0.000000000000000;
 
402
  }
 
403
 
 
404
  /// Evaluate linear functionals for all dofs on the function f
 
405
  virtual void evaluate_dofs(double* values,
 
406
                             const ufc::function& f,
 
407
                             const ufc::cell& c) const
 
408
  {
 
409
    // Declare variables for result of evaluation.
 
410
    double vals[1];
 
411
    
 
412
    // Declare variable for physical coordinates.
 
413
    double y[2];
 
414
    const double * const * x = c.coordinates;
 
415
    y[0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
 
416
    y[1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
 
417
    f.evaluate(vals, y, c);
 
418
    values[0] = vals[0];
 
419
  }
 
420
 
 
421
  /// Interpolate vertex values from dof values
 
422
  virtual void interpolate_vertex_values(double* vertex_values,
 
423
                                         const double* dof_values,
 
424
                                         const ufc::cell& c) const
 
425
  {
 
426
    // Evaluate function and change variables
 
427
    vertex_values[0] = dof_values[0];
 
428
    vertex_values[1] = dof_values[0];
 
429
    vertex_values[2] = dof_values[0];
 
430
  }
 
431
 
 
432
  /// Map coordinate xhat from reference cell to coordinate x in cell
 
433
  virtual void map_from_reference_cell(double* x,
 
434
                                       const double* xhat,
 
435
                                       const ufc::cell& c)
 
436
  {
 
437
    throw std::runtime_error("map_from_reference_cell not yet implemented (introduced in UFC 2.0).");
 
438
  }
 
439
 
 
440
  /// Map from coordinate x in cell to coordinate xhat in reference cell
 
441
  virtual void map_to_reference_cell(double* xhat,
 
442
                                     const double* x,
 
443
                                     const ufc::cell& c)
 
444
  {
 
445
    throw std::runtime_error("map_to_reference_cell not yet implemented (introduced in UFC 2.0).");
 
446
  }
 
447
 
 
448
  /// Return the number of sub elements (for a mixed element)
 
449
  virtual unsigned int num_sub_elements() const
 
450
  {
 
451
    return 0;
 
452
  }
 
453
 
 
454
  /// Create a new finite element for sub element i (for a mixed element)
 
455
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
456
  {
 
457
    return 0;
 
458
  }
 
459
 
 
460
  /// Create a new class instance
 
461
  virtual ufc::finite_element* create() const
 
462
  {
 
463
    return new adaptivepoisson_finite_element_0();
 
464
  }
 
465
 
 
466
};
 
467
 
 
468
/// This class defines the interface for a finite element.
 
469
 
 
470
class adaptivepoisson_finite_element_1: public ufc::finite_element
 
471
{
 
472
public:
 
473
 
 
474
  /// Constructor
 
475
  adaptivepoisson_finite_element_1() : ufc::finite_element()
 
476
  {
 
477
    // Do nothing
 
478
  }
 
479
 
 
480
  /// Destructor
 
481
  virtual ~adaptivepoisson_finite_element_1()
 
482
  {
 
483
    // Do nothing
 
484
  }
 
485
 
 
486
  /// Return a string identifying the finite element
 
487
  virtual const char* signature() const
 
488
  {
 
489
    return "FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2)";
 
490
  }
 
491
 
 
492
  /// Return the cell shape
 
493
  virtual ufc::shape cell_shape() const
 
494
  {
 
495
    return ufc::triangle;
 
496
  }
 
497
 
 
498
  /// Return the topological dimension of the cell shape
 
499
  virtual unsigned int topological_dimension() const
 
500
  {
 
501
    return 2;
 
502
  }
 
503
 
 
504
  /// Return the geometric dimension of the cell shape
 
505
  virtual unsigned int geometric_dimension() const
 
506
  {
 
507
    return 2;
 
508
  }
 
509
 
 
510
  /// Return the dimension of the finite element function space
 
511
  virtual unsigned int space_dimension() const
 
512
  {
 
513
    return 6;
 
514
  }
 
515
 
 
516
  /// Return the rank of the value space
 
517
  virtual unsigned int value_rank() const
 
518
  {
 
519
    return 0;
 
520
  }
 
521
 
 
522
  /// Return the dimension of the value space for axis i
 
523
  virtual unsigned int value_dimension(unsigned int i) const
 
524
  {
 
525
    return 1;
 
526
  }
 
527
 
 
528
  /// Evaluate basis function i at given point in cell
 
529
  virtual void evaluate_basis(unsigned int i,
 
530
                              double* values,
 
531
                              const double* coordinates,
 
532
                              const ufc::cell& c) const
 
533
  {
 
534
    // Extract vertex coordinates
 
535
    const double * const * x = c.coordinates;
 
536
    
 
537
    // Compute Jacobian of affine map from reference cell
 
538
    const double J_00 = x[1][0] - x[0][0];
 
539
    const double J_01 = x[2][0] - x[0][0];
 
540
    const double J_10 = x[1][1] - x[0][1];
 
541
    const double J_11 = x[2][1] - x[0][1];
 
542
    
 
543
    // Compute determinant of Jacobian
 
544
    double detJ = J_00*J_11 - J_01*J_10;
 
545
    
 
546
    // Compute inverse of Jacobian
 
547
    
 
548
    // Compute constants
 
549
    const double C0 = x[1][0] + x[2][0];
 
550
    const double C1 = x[1][1] + x[2][1];
 
551
    
 
552
    // Get coordinates and map to the reference (FIAT) element
 
553
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
554
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
555
    
 
556
    // Reset values.
 
557
    *values = 0.000000000000000;
 
558
    switch (i)
 
559
    {
 
560
    case 0:
 
561
      {
 
562
        
 
563
      // Array of basisvalues.
 
564
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
565
      
 
566
      // Declare helper variables.
 
567
      unsigned int rr = 0;
 
568
      unsigned int ss = 0;
 
569
      unsigned int tt = 0;
 
570
      double tmp5 = 0.000000000000000;
 
571
      double tmp6 = 0.000000000000000;
 
572
      double tmp7 = 0.000000000000000;
 
573
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
574
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
575
      double tmp2 = tmp1*tmp1;
 
576
      
 
577
      // Compute basisvalues.
 
578
      basisvalues[0] = 1.000000000000000;
 
579
      basisvalues[1] = tmp0;
 
580
      for (unsigned int r = 1; r < 2; r++)
 
581
      {
 
582
        rr = (r + 1)*((r + 1) + 1)/2;
 
583
        ss = r*(r + 1)/2;
 
584
        tt = (r - 1)*((r - 1) + 1)/2;
 
585
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
586
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
587
      }// end loop over 'r'
 
588
      for (unsigned int r = 0; r < 2; r++)
 
589
      {
 
590
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
591
        ss = r*(r + 1)/2;
 
592
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
593
      }// end loop over 'r'
 
594
      for (unsigned int r = 0; r < 1; r++)
 
595
      {
 
596
        for (unsigned int s = 1; s < 2 - r; s++)
 
597
        {
 
598
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
599
          ss = (r + s)*(r + s + 1)/2 + s;
 
600
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
601
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
602
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
603
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
604
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
605
        }// end loop over 's'
 
606
      }// end loop over 'r'
 
607
      for (unsigned int r = 0; r < 3; r++)
 
608
      {
 
609
        for (unsigned int s = 0; s < 3 - r; s++)
 
610
        {
 
611
          rr = (r + s)*(r + s + 1)/2 + s;
 
612
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
613
        }// end loop over 's'
 
614
      }// end loop over 'r'
 
615
      
 
616
      // Table(s) of coefficients.
 
617
      static const double coefficients0[6] = \
 
618
      {0.000000000000000, -0.173205080756888, -0.100000000000000, 0.121716123890037, 0.094280904158206, 0.054433105395182};
 
619
      
 
620
      // Compute value(s).
 
621
      for (unsigned int r = 0; r < 6; r++)
 
622
      {
 
623
        *values += coefficients0[r]*basisvalues[r];
 
624
      }// end loop over 'r'
 
625
        break;
 
626
      }
 
627
    case 1:
 
628
      {
 
629
        
 
630
      // Array of basisvalues.
 
631
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
632
      
 
633
      // Declare helper variables.
 
634
      unsigned int rr = 0;
 
635
      unsigned int ss = 0;
 
636
      unsigned int tt = 0;
 
637
      double tmp5 = 0.000000000000000;
 
638
      double tmp6 = 0.000000000000000;
 
639
      double tmp7 = 0.000000000000000;
 
640
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
641
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
642
      double tmp2 = tmp1*tmp1;
 
643
      
 
644
      // Compute basisvalues.
 
645
      basisvalues[0] = 1.000000000000000;
 
646
      basisvalues[1] = tmp0;
 
647
      for (unsigned int r = 1; r < 2; r++)
 
648
      {
 
649
        rr = (r + 1)*((r + 1) + 1)/2;
 
650
        ss = r*(r + 1)/2;
 
651
        tt = (r - 1)*((r - 1) + 1)/2;
 
652
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
653
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
654
      }// end loop over 'r'
 
655
      for (unsigned int r = 0; r < 2; r++)
 
656
      {
 
657
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
658
        ss = r*(r + 1)/2;
 
659
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
660
      }// end loop over 'r'
 
661
      for (unsigned int r = 0; r < 1; r++)
 
662
      {
 
663
        for (unsigned int s = 1; s < 2 - r; s++)
 
664
        {
 
665
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
666
          ss = (r + s)*(r + s + 1)/2 + s;
 
667
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
668
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
669
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
670
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
671
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
672
        }// end loop over 's'
 
673
      }// end loop over 'r'
 
674
      for (unsigned int r = 0; r < 3; r++)
 
675
      {
 
676
        for (unsigned int s = 0; s < 3 - r; s++)
 
677
        {
 
678
          rr = (r + s)*(r + s + 1)/2 + s;
 
679
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
680
        }// end loop over 's'
 
681
      }// end loop over 'r'
 
682
      
 
683
      // Table(s) of coefficients.
 
684
      static const double coefficients0[6] = \
 
685
      {0.000000000000000, 0.173205080756888, -0.100000000000000, 0.121716123890037, -0.094280904158206, 0.054433105395182};
 
686
      
 
687
      // Compute value(s).
 
688
      for (unsigned int r = 0; r < 6; r++)
 
689
      {
 
690
        *values += coefficients0[r]*basisvalues[r];
 
691
      }// end loop over 'r'
 
692
        break;
 
693
      }
 
694
    case 2:
 
695
      {
 
696
        
 
697
      // Array of basisvalues.
 
698
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
699
      
 
700
      // Declare helper variables.
 
701
      unsigned int rr = 0;
 
702
      unsigned int ss = 0;
 
703
      unsigned int tt = 0;
 
704
      double tmp5 = 0.000000000000000;
 
705
      double tmp6 = 0.000000000000000;
 
706
      double tmp7 = 0.000000000000000;
 
707
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
708
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
709
      double tmp2 = tmp1*tmp1;
 
710
      
 
711
      // Compute basisvalues.
 
712
      basisvalues[0] = 1.000000000000000;
 
713
      basisvalues[1] = tmp0;
 
714
      for (unsigned int r = 1; r < 2; r++)
 
715
      {
 
716
        rr = (r + 1)*((r + 1) + 1)/2;
 
717
        ss = r*(r + 1)/2;
 
718
        tt = (r - 1)*((r - 1) + 1)/2;
 
719
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
720
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
721
      }// end loop over 'r'
 
722
      for (unsigned int r = 0; r < 2; r++)
 
723
      {
 
724
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
725
        ss = r*(r + 1)/2;
 
726
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
727
      }// end loop over 'r'
 
728
      for (unsigned int r = 0; r < 1; r++)
 
729
      {
 
730
        for (unsigned int s = 1; s < 2 - r; s++)
 
731
        {
 
732
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
733
          ss = (r + s)*(r + s + 1)/2 + s;
 
734
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
735
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
736
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
737
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
738
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
739
        }// end loop over 's'
 
740
      }// end loop over 'r'
 
741
      for (unsigned int r = 0; r < 3; r++)
 
742
      {
 
743
        for (unsigned int s = 0; s < 3 - r; s++)
 
744
        {
 
745
          rr = (r + s)*(r + s + 1)/2 + s;
 
746
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
747
        }// end loop over 's'
 
748
      }// end loop over 'r'
 
749
      
 
750
      // Table(s) of coefficients.
 
751
      static const double coefficients0[6] = \
 
752
      {0.000000000000000, 0.000000000000000, 0.200000000000000, 0.000000000000000, 0.000000000000000, 0.163299316185545};
 
753
      
 
754
      // Compute value(s).
 
755
      for (unsigned int r = 0; r < 6; r++)
 
756
      {
 
757
        *values += coefficients0[r]*basisvalues[r];
 
758
      }// end loop over 'r'
 
759
        break;
 
760
      }
 
761
    case 3:
 
762
      {
 
763
        
 
764
      // Array of basisvalues.
 
765
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
766
      
 
767
      // Declare helper variables.
 
768
      unsigned int rr = 0;
 
769
      unsigned int ss = 0;
 
770
      unsigned int tt = 0;
 
771
      double tmp5 = 0.000000000000000;
 
772
      double tmp6 = 0.000000000000000;
 
773
      double tmp7 = 0.000000000000000;
 
774
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
775
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
776
      double tmp2 = tmp1*tmp1;
 
777
      
 
778
      // Compute basisvalues.
 
779
      basisvalues[0] = 1.000000000000000;
 
780
      basisvalues[1] = tmp0;
 
781
      for (unsigned int r = 1; r < 2; r++)
 
782
      {
 
783
        rr = (r + 1)*((r + 1) + 1)/2;
 
784
        ss = r*(r + 1)/2;
 
785
        tt = (r - 1)*((r - 1) + 1)/2;
 
786
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
787
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
788
      }// end loop over 'r'
 
789
      for (unsigned int r = 0; r < 2; r++)
 
790
      {
 
791
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
792
        ss = r*(r + 1)/2;
 
793
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
794
      }// end loop over 'r'
 
795
      for (unsigned int r = 0; r < 1; r++)
 
796
      {
 
797
        for (unsigned int s = 1; s < 2 - r; s++)
 
798
        {
 
799
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
800
          ss = (r + s)*(r + s + 1)/2 + s;
 
801
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
802
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
803
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
804
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
805
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
806
        }// end loop over 's'
 
807
      }// end loop over 'r'
 
808
      for (unsigned int r = 0; r < 3; r++)
 
809
      {
 
810
        for (unsigned int s = 0; s < 3 - r; s++)
 
811
        {
 
812
          rr = (r + s)*(r + s + 1)/2 + s;
 
813
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
814
        }// end loop over 's'
 
815
      }// end loop over 'r'
 
816
      
 
817
      // Table(s) of coefficients.
 
818
      static const double coefficients0[6] = \
 
819
      {0.471404520791032, 0.230940107675850, 0.133333333333333, 0.000000000000000, 0.188561808316413, -0.163299316185545};
 
820
      
 
821
      // Compute value(s).
 
822
      for (unsigned int r = 0; r < 6; r++)
 
823
      {
 
824
        *values += coefficients0[r]*basisvalues[r];
 
825
      }// end loop over 'r'
 
826
        break;
 
827
      }
 
828
    case 4:
 
829
      {
 
830
        
 
831
      // Array of basisvalues.
 
832
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
833
      
 
834
      // Declare helper variables.
 
835
      unsigned int rr = 0;
 
836
      unsigned int ss = 0;
 
837
      unsigned int tt = 0;
 
838
      double tmp5 = 0.000000000000000;
 
839
      double tmp6 = 0.000000000000000;
 
840
      double tmp7 = 0.000000000000000;
 
841
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
842
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
843
      double tmp2 = tmp1*tmp1;
 
844
      
 
845
      // Compute basisvalues.
 
846
      basisvalues[0] = 1.000000000000000;
 
847
      basisvalues[1] = tmp0;
 
848
      for (unsigned int r = 1; r < 2; r++)
 
849
      {
 
850
        rr = (r + 1)*((r + 1) + 1)/2;
 
851
        ss = r*(r + 1)/2;
 
852
        tt = (r - 1)*((r - 1) + 1)/2;
 
853
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
854
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
855
      }// end loop over 'r'
 
856
      for (unsigned int r = 0; r < 2; r++)
 
857
      {
 
858
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
859
        ss = r*(r + 1)/2;
 
860
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
861
      }// end loop over 'r'
 
862
      for (unsigned int r = 0; r < 1; r++)
 
863
      {
 
864
        for (unsigned int s = 1; s < 2 - r; s++)
 
865
        {
 
866
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
867
          ss = (r + s)*(r + s + 1)/2 + s;
 
868
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
869
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
870
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
871
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
872
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
873
        }// end loop over 's'
 
874
      }// end loop over 'r'
 
875
      for (unsigned int r = 0; r < 3; r++)
 
876
      {
 
877
        for (unsigned int s = 0; s < 3 - r; s++)
 
878
        {
 
879
          rr = (r + s)*(r + s + 1)/2 + s;
 
880
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
881
        }// end loop over 's'
 
882
      }// end loop over 'r'
 
883
      
 
884
      // Table(s) of coefficients.
 
885
      static const double coefficients0[6] = \
 
886
      {0.471404520791032, -0.230940107675850, 0.133333333333333, 0.000000000000000, -0.188561808316413, -0.163299316185545};
 
887
      
 
888
      // Compute value(s).
 
889
      for (unsigned int r = 0; r < 6; r++)
 
890
      {
 
891
        *values += coefficients0[r]*basisvalues[r];
 
892
      }// end loop over 'r'
 
893
        break;
 
894
      }
 
895
    case 5:
 
896
      {
 
897
        
 
898
      // Array of basisvalues.
 
899
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
900
      
 
901
      // Declare helper variables.
 
902
      unsigned int rr = 0;
 
903
      unsigned int ss = 0;
 
904
      unsigned int tt = 0;
 
905
      double tmp5 = 0.000000000000000;
 
906
      double tmp6 = 0.000000000000000;
 
907
      double tmp7 = 0.000000000000000;
 
908
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
909
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
910
      double tmp2 = tmp1*tmp1;
 
911
      
 
912
      // Compute basisvalues.
 
913
      basisvalues[0] = 1.000000000000000;
 
914
      basisvalues[1] = tmp0;
 
915
      for (unsigned int r = 1; r < 2; r++)
 
916
      {
 
917
        rr = (r + 1)*((r + 1) + 1)/2;
 
918
        ss = r*(r + 1)/2;
 
919
        tt = (r - 1)*((r - 1) + 1)/2;
 
920
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
921
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
922
      }// end loop over 'r'
 
923
      for (unsigned int r = 0; r < 2; r++)
 
924
      {
 
925
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
926
        ss = r*(r + 1)/2;
 
927
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
928
      }// end loop over 'r'
 
929
      for (unsigned int r = 0; r < 1; r++)
 
930
      {
 
931
        for (unsigned int s = 1; s < 2 - r; s++)
 
932
        {
 
933
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
934
          ss = (r + s)*(r + s + 1)/2 + s;
 
935
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
936
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
937
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
938
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
939
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
940
        }// end loop over 's'
 
941
      }// end loop over 'r'
 
942
      for (unsigned int r = 0; r < 3; r++)
 
943
      {
 
944
        for (unsigned int s = 0; s < 3 - r; s++)
 
945
        {
 
946
          rr = (r + s)*(r + s + 1)/2 + s;
 
947
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
948
        }// end loop over 's'
 
949
      }// end loop over 'r'
 
950
      
 
951
      // Table(s) of coefficients.
 
952
      static const double coefficients0[6] = \
 
953
      {0.471404520791032, 0.000000000000000, -0.266666666666667, -0.243432247780074, 0.000000000000000, 0.054433105395182};
 
954
      
 
955
      // Compute value(s).
 
956
      for (unsigned int r = 0; r < 6; r++)
 
957
      {
 
958
        *values += coefficients0[r]*basisvalues[r];
 
959
      }// end loop over 'r'
 
960
        break;
 
961
      }
 
962
    }
 
963
    
 
964
  }
 
965
 
 
966
  /// Evaluate all basis functions at given point in cell
 
967
  virtual void evaluate_basis_all(double* values,
 
968
                                  const double* coordinates,
 
969
                                  const ufc::cell& c) const
 
970
  {
 
971
    // Helper variable to hold values of a single dof.
 
972
    double dof_values = 0.000000000000000;
 
973
    
 
974
    // Loop dofs and call evaluate_basis.
 
975
    for (unsigned int r = 0; r < 6; r++)
 
976
    {
 
977
      evaluate_basis(r, &dof_values, coordinates, c);
 
978
      values[r] = dof_values;
 
979
    }// end loop over 'r'
 
980
  }
 
981
 
 
982
  /// Evaluate order n derivatives of basis function i at given point in cell
 
983
  virtual void evaluate_basis_derivatives(unsigned int i,
 
984
                                          unsigned int n,
 
985
                                          double* values,
 
986
                                          const double* coordinates,
 
987
                                          const ufc::cell& c) const
 
988
  {
 
989
    // Extract vertex coordinates
 
990
    const double * const * x = c.coordinates;
 
991
    
 
992
    // Compute Jacobian of affine map from reference cell
 
993
    const double J_00 = x[1][0] - x[0][0];
 
994
    const double J_01 = x[2][0] - x[0][0];
 
995
    const double J_10 = x[1][1] - x[0][1];
 
996
    const double J_11 = x[2][1] - x[0][1];
 
997
    
 
998
    // Compute determinant of Jacobian
 
999
    double detJ = J_00*J_11 - J_01*J_10;
 
1000
    
 
1001
    // Compute inverse of Jacobian
 
1002
    const double K_00 =  J_11 / detJ;
 
1003
    const double K_01 = -J_01 / detJ;
 
1004
    const double K_10 = -J_10 / detJ;
 
1005
    const double K_11 =  J_00 / detJ;
 
1006
    
 
1007
    // Compute constants
 
1008
    const double C0 = x[1][0] + x[2][0];
 
1009
    const double C1 = x[1][1] + x[2][1];
 
1010
    
 
1011
    // Get coordinates and map to the reference (FIAT) element
 
1012
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
1013
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
1014
    
 
1015
    // Compute number of derivatives.
 
1016
    unsigned int num_derivatives = 1;
 
1017
    for (unsigned int r = 0; r < n; r++)
 
1018
    {
 
1019
      num_derivatives *= 2;
 
1020
    }// end loop over 'r'
 
1021
    
 
1022
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
1023
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
1024
    for (unsigned int row = 0; row < num_derivatives; row++)
 
1025
    {
 
1026
      combinations[row] = new unsigned int [n];
 
1027
      for (unsigned int col = 0; col < n; col++)
 
1028
        combinations[row][col] = 0;
 
1029
    }
 
1030
    
 
1031
    // Generate combinations of derivatives
 
1032
    for (unsigned int row = 1; row < num_derivatives; row++)
 
1033
    {
 
1034
      for (unsigned int num = 0; num < row; num++)
 
1035
      {
 
1036
        for (unsigned int col = n-1; col+1 > 0; col--)
 
1037
        {
 
1038
          if (combinations[row][col] + 1 > 1)
 
1039
            combinations[row][col] = 0;
 
1040
          else
 
1041
          {
 
1042
            combinations[row][col] += 1;
 
1043
            break;
 
1044
          }
 
1045
        }
 
1046
      }
 
1047
    }
 
1048
    
 
1049
    // Compute inverse of Jacobian
 
1050
    const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
 
1051
    
 
1052
    // Declare transformation matrix
 
1053
    // Declare pointer to two dimensional array and initialise
 
1054
    double **transform = new double *[num_derivatives];
 
1055
    
 
1056
    for (unsigned int j = 0; j < num_derivatives; j++)
 
1057
    {
 
1058
      transform[j] = new double [num_derivatives];
 
1059
      for (unsigned int k = 0; k < num_derivatives; k++)
 
1060
        transform[j][k] = 1;
 
1061
    }
 
1062
    
 
1063
    // Construct transformation matrix
 
1064
    for (unsigned int row = 0; row < num_derivatives; row++)
 
1065
    {
 
1066
      for (unsigned int col = 0; col < num_derivatives; col++)
 
1067
      {
 
1068
        for (unsigned int k = 0; k < n; k++)
 
1069
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
1070
      }
 
1071
    }
 
1072
    
 
1073
    // Reset values. Assuming that values is always an array.
 
1074
    for (unsigned int r = 0; r < num_derivatives; r++)
 
1075
    {
 
1076
      values[r] = 0.000000000000000;
 
1077
    }// end loop over 'r'
 
1078
    
 
1079
    switch (i)
 
1080
    {
 
1081
    case 0:
 
1082
      {
 
1083
        
 
1084
      // Array of basisvalues.
 
1085
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
1086
      
 
1087
      // Declare helper variables.
 
1088
      unsigned int rr = 0;
 
1089
      unsigned int ss = 0;
 
1090
      unsigned int tt = 0;
 
1091
      double tmp5 = 0.000000000000000;
 
1092
      double tmp6 = 0.000000000000000;
 
1093
      double tmp7 = 0.000000000000000;
 
1094
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
1095
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
1096
      double tmp2 = tmp1*tmp1;
 
1097
      
 
1098
      // Compute basisvalues.
 
1099
      basisvalues[0] = 1.000000000000000;
 
1100
      basisvalues[1] = tmp0;
 
1101
      for (unsigned int r = 1; r < 2; r++)
 
1102
      {
 
1103
        rr = (r + 1)*((r + 1) + 1)/2;
 
1104
        ss = r*(r + 1)/2;
 
1105
        tt = (r - 1)*((r - 1) + 1)/2;
 
1106
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
1107
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
1108
      }// end loop over 'r'
 
1109
      for (unsigned int r = 0; r < 2; r++)
 
1110
      {
 
1111
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
1112
        ss = r*(r + 1)/2;
 
1113
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
1114
      }// end loop over 'r'
 
1115
      for (unsigned int r = 0; r < 1; r++)
 
1116
      {
 
1117
        for (unsigned int s = 1; s < 2 - r; s++)
 
1118
        {
 
1119
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
1120
          ss = (r + s)*(r + s + 1)/2 + s;
 
1121
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
1122
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1123
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1124
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1125
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
1126
        }// end loop over 's'
 
1127
      }// end loop over 'r'
 
1128
      for (unsigned int r = 0; r < 3; r++)
 
1129
      {
 
1130
        for (unsigned int s = 0; s < 3 - r; s++)
 
1131
        {
 
1132
          rr = (r + s)*(r + s + 1)/2 + s;
 
1133
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
1134
        }// end loop over 's'
 
1135
      }// end loop over 'r'
 
1136
      
 
1137
      // Table(s) of coefficients.
 
1138
      static const double coefficients0[6] = \
 
1139
      {0.000000000000000, -0.173205080756888, -0.100000000000000, 0.121716123890037, 0.094280904158206, 0.054433105395182};
 
1140
      
 
1141
      // Tables of derivatives of the polynomial base (transpose).
 
1142
      static const double dmats0[6][6] = \
 
1143
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1144
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1145
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1146
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1147
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1148
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1149
      
 
1150
      static const double dmats1[6][6] = \
 
1151
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1152
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1153
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1154
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1155
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1156
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1157
      
 
1158
      // Compute reference derivatives.
 
1159
      // Declare pointer to array of derivatives on FIAT element.
 
1160
      double *derivatives = new double[num_derivatives];
 
1161
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1162
      {
 
1163
        derivatives[r] = 0.000000000000000;
 
1164
      }// end loop over 'r'
 
1165
      
 
1166
      // Declare derivative matrix (of polynomial basis).
 
1167
      double dmats[6][6] = \
 
1168
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1169
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1170
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1171
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1172
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1173
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1174
      
 
1175
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
1176
      double dmats_old[6][6] = \
 
1177
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1178
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1179
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1180
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1181
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1182
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1183
      
 
1184
      // Loop possible derivatives.
 
1185
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1186
      {
 
1187
        // Resetting dmats values to compute next derivative.
 
1188
        for (unsigned int t = 0; t < 6; t++)
 
1189
        {
 
1190
          for (unsigned int u = 0; u < 6; u++)
 
1191
          {
 
1192
            dmats[t][u] = 0.000000000000000;
 
1193
            if (t == u)
 
1194
            {
 
1195
            dmats[t][u] = 1.000000000000000;
 
1196
            }
 
1197
            
 
1198
          }// end loop over 'u'
 
1199
        }// end loop over 't'
 
1200
        
 
1201
        // Looping derivative order to generate dmats.
 
1202
        for (unsigned int s = 0; s < n; s++)
 
1203
        {
 
1204
          // Updating dmats_old with new values and resetting dmats.
 
1205
          for (unsigned int t = 0; t < 6; t++)
 
1206
          {
 
1207
            for (unsigned int u = 0; u < 6; u++)
 
1208
            {
 
1209
              dmats_old[t][u] = dmats[t][u];
 
1210
              dmats[t][u] = 0.000000000000000;
 
1211
            }// end loop over 'u'
 
1212
          }// end loop over 't'
 
1213
          
 
1214
          // Update dmats using an inner product.
 
1215
          if (combinations[r][s] == 0)
 
1216
          {
 
1217
          for (unsigned int t = 0; t < 6; t++)
 
1218
          {
 
1219
            for (unsigned int u = 0; u < 6; u++)
 
1220
            {
 
1221
              for (unsigned int tu = 0; tu < 6; tu++)
 
1222
              {
 
1223
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
1224
              }// end loop over 'tu'
 
1225
            }// end loop over 'u'
 
1226
          }// end loop over 't'
 
1227
          }
 
1228
          
 
1229
          if (combinations[r][s] == 1)
 
1230
          {
 
1231
          for (unsigned int t = 0; t < 6; t++)
 
1232
          {
 
1233
            for (unsigned int u = 0; u < 6; u++)
 
1234
            {
 
1235
              for (unsigned int tu = 0; tu < 6; tu++)
 
1236
              {
 
1237
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
1238
              }// end loop over 'tu'
 
1239
            }// end loop over 'u'
 
1240
          }// end loop over 't'
 
1241
          }
 
1242
          
 
1243
        }// end loop over 's'
 
1244
        for (unsigned int s = 0; s < 6; s++)
 
1245
        {
 
1246
          for (unsigned int t = 0; t < 6; t++)
 
1247
          {
 
1248
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
1249
          }// end loop over 't'
 
1250
        }// end loop over 's'
 
1251
      }// end loop over 'r'
 
1252
      
 
1253
      // Transform derivatives back to physical element
 
1254
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1255
      {
 
1256
        for (unsigned int s = 0; s < num_derivatives; s++)
 
1257
        {
 
1258
          values[r] += transform[r][s]*derivatives[s];
 
1259
        }// end loop over 's'
 
1260
      }// end loop over 'r'
 
1261
      
 
1262
      // Delete pointer to array of derivatives on FIAT element
 
1263
      delete [] derivatives;
 
1264
      
 
1265
      // Delete pointer to array of combinations of derivatives and transform
 
1266
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1267
      {
 
1268
        delete [] combinations[r];
 
1269
      }// end loop over 'r'
 
1270
      delete [] combinations;
 
1271
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1272
      {
 
1273
        delete [] transform[r];
 
1274
      }// end loop over 'r'
 
1275
      delete [] transform;
 
1276
        break;
 
1277
      }
 
1278
    case 1:
 
1279
      {
 
1280
        
 
1281
      // Array of basisvalues.
 
1282
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
1283
      
 
1284
      // Declare helper variables.
 
1285
      unsigned int rr = 0;
 
1286
      unsigned int ss = 0;
 
1287
      unsigned int tt = 0;
 
1288
      double tmp5 = 0.000000000000000;
 
1289
      double tmp6 = 0.000000000000000;
 
1290
      double tmp7 = 0.000000000000000;
 
1291
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
1292
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
1293
      double tmp2 = tmp1*tmp1;
 
1294
      
 
1295
      // Compute basisvalues.
 
1296
      basisvalues[0] = 1.000000000000000;
 
1297
      basisvalues[1] = tmp0;
 
1298
      for (unsigned int r = 1; r < 2; r++)
 
1299
      {
 
1300
        rr = (r + 1)*((r + 1) + 1)/2;
 
1301
        ss = r*(r + 1)/2;
 
1302
        tt = (r - 1)*((r - 1) + 1)/2;
 
1303
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
1304
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
1305
      }// end loop over 'r'
 
1306
      for (unsigned int r = 0; r < 2; r++)
 
1307
      {
 
1308
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
1309
        ss = r*(r + 1)/2;
 
1310
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
1311
      }// end loop over 'r'
 
1312
      for (unsigned int r = 0; r < 1; r++)
 
1313
      {
 
1314
        for (unsigned int s = 1; s < 2 - r; s++)
 
1315
        {
 
1316
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
1317
          ss = (r + s)*(r + s + 1)/2 + s;
 
1318
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
1319
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1320
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1321
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1322
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
1323
        }// end loop over 's'
 
1324
      }// end loop over 'r'
 
1325
      for (unsigned int r = 0; r < 3; r++)
 
1326
      {
 
1327
        for (unsigned int s = 0; s < 3 - r; s++)
 
1328
        {
 
1329
          rr = (r + s)*(r + s + 1)/2 + s;
 
1330
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
1331
        }// end loop over 's'
 
1332
      }// end loop over 'r'
 
1333
      
 
1334
      // Table(s) of coefficients.
 
1335
      static const double coefficients0[6] = \
 
1336
      {0.000000000000000, 0.173205080756888, -0.100000000000000, 0.121716123890037, -0.094280904158206, 0.054433105395182};
 
1337
      
 
1338
      // Tables of derivatives of the polynomial base (transpose).
 
1339
      static const double dmats0[6][6] = \
 
1340
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1341
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1342
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1343
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1344
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1345
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1346
      
 
1347
      static const double dmats1[6][6] = \
 
1348
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1349
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1350
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1351
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1352
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1353
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1354
      
 
1355
      // Compute reference derivatives.
 
1356
      // Declare pointer to array of derivatives on FIAT element.
 
1357
      double *derivatives = new double[num_derivatives];
 
1358
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1359
      {
 
1360
        derivatives[r] = 0.000000000000000;
 
1361
      }// end loop over 'r'
 
1362
      
 
1363
      // Declare derivative matrix (of polynomial basis).
 
1364
      double dmats[6][6] = \
 
1365
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1366
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1367
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1368
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1369
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1370
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1371
      
 
1372
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
1373
      double dmats_old[6][6] = \
 
1374
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1375
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1376
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1377
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1378
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1379
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1380
      
 
1381
      // Loop possible derivatives.
 
1382
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1383
      {
 
1384
        // Resetting dmats values to compute next derivative.
 
1385
        for (unsigned int t = 0; t < 6; t++)
 
1386
        {
 
1387
          for (unsigned int u = 0; u < 6; u++)
 
1388
          {
 
1389
            dmats[t][u] = 0.000000000000000;
 
1390
            if (t == u)
 
1391
            {
 
1392
            dmats[t][u] = 1.000000000000000;
 
1393
            }
 
1394
            
 
1395
          }// end loop over 'u'
 
1396
        }// end loop over 't'
 
1397
        
 
1398
        // Looping derivative order to generate dmats.
 
1399
        for (unsigned int s = 0; s < n; s++)
 
1400
        {
 
1401
          // Updating dmats_old with new values and resetting dmats.
 
1402
          for (unsigned int t = 0; t < 6; t++)
 
1403
          {
 
1404
            for (unsigned int u = 0; u < 6; u++)
 
1405
            {
 
1406
              dmats_old[t][u] = dmats[t][u];
 
1407
              dmats[t][u] = 0.000000000000000;
 
1408
            }// end loop over 'u'
 
1409
          }// end loop over 't'
 
1410
          
 
1411
          // Update dmats using an inner product.
 
1412
          if (combinations[r][s] == 0)
 
1413
          {
 
1414
          for (unsigned int t = 0; t < 6; t++)
 
1415
          {
 
1416
            for (unsigned int u = 0; u < 6; u++)
 
1417
            {
 
1418
              for (unsigned int tu = 0; tu < 6; tu++)
 
1419
              {
 
1420
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
1421
              }// end loop over 'tu'
 
1422
            }// end loop over 'u'
 
1423
          }// end loop over 't'
 
1424
          }
 
1425
          
 
1426
          if (combinations[r][s] == 1)
 
1427
          {
 
1428
          for (unsigned int t = 0; t < 6; t++)
 
1429
          {
 
1430
            for (unsigned int u = 0; u < 6; u++)
 
1431
            {
 
1432
              for (unsigned int tu = 0; tu < 6; tu++)
 
1433
              {
 
1434
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
1435
              }// end loop over 'tu'
 
1436
            }// end loop over 'u'
 
1437
          }// end loop over 't'
 
1438
          }
 
1439
          
 
1440
        }// end loop over 's'
 
1441
        for (unsigned int s = 0; s < 6; s++)
 
1442
        {
 
1443
          for (unsigned int t = 0; t < 6; t++)
 
1444
          {
 
1445
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
1446
          }// end loop over 't'
 
1447
        }// end loop over 's'
 
1448
      }// end loop over 'r'
 
1449
      
 
1450
      // Transform derivatives back to physical element
 
1451
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1452
      {
 
1453
        for (unsigned int s = 0; s < num_derivatives; s++)
 
1454
        {
 
1455
          values[r] += transform[r][s]*derivatives[s];
 
1456
        }// end loop over 's'
 
1457
      }// end loop over 'r'
 
1458
      
 
1459
      // Delete pointer to array of derivatives on FIAT element
 
1460
      delete [] derivatives;
 
1461
      
 
1462
      // Delete pointer to array of combinations of derivatives and transform
 
1463
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1464
      {
 
1465
        delete [] combinations[r];
 
1466
      }// end loop over 'r'
 
1467
      delete [] combinations;
 
1468
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1469
      {
 
1470
        delete [] transform[r];
 
1471
      }// end loop over 'r'
 
1472
      delete [] transform;
 
1473
        break;
 
1474
      }
 
1475
    case 2:
 
1476
      {
 
1477
        
 
1478
      // Array of basisvalues.
 
1479
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
1480
      
 
1481
      // Declare helper variables.
 
1482
      unsigned int rr = 0;
 
1483
      unsigned int ss = 0;
 
1484
      unsigned int tt = 0;
 
1485
      double tmp5 = 0.000000000000000;
 
1486
      double tmp6 = 0.000000000000000;
 
1487
      double tmp7 = 0.000000000000000;
 
1488
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
1489
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
1490
      double tmp2 = tmp1*tmp1;
 
1491
      
 
1492
      // Compute basisvalues.
 
1493
      basisvalues[0] = 1.000000000000000;
 
1494
      basisvalues[1] = tmp0;
 
1495
      for (unsigned int r = 1; r < 2; r++)
 
1496
      {
 
1497
        rr = (r + 1)*((r + 1) + 1)/2;
 
1498
        ss = r*(r + 1)/2;
 
1499
        tt = (r - 1)*((r - 1) + 1)/2;
 
1500
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
1501
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
1502
      }// end loop over 'r'
 
1503
      for (unsigned int r = 0; r < 2; r++)
 
1504
      {
 
1505
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
1506
        ss = r*(r + 1)/2;
 
1507
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
1508
      }// end loop over 'r'
 
1509
      for (unsigned int r = 0; r < 1; r++)
 
1510
      {
 
1511
        for (unsigned int s = 1; s < 2 - r; s++)
 
1512
        {
 
1513
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
1514
          ss = (r + s)*(r + s + 1)/2 + s;
 
1515
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
1516
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1517
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1518
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1519
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
1520
        }// end loop over 's'
 
1521
      }// end loop over 'r'
 
1522
      for (unsigned int r = 0; r < 3; r++)
 
1523
      {
 
1524
        for (unsigned int s = 0; s < 3 - r; s++)
 
1525
        {
 
1526
          rr = (r + s)*(r + s + 1)/2 + s;
 
1527
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
1528
        }// end loop over 's'
 
1529
      }// end loop over 'r'
 
1530
      
 
1531
      // Table(s) of coefficients.
 
1532
      static const double coefficients0[6] = \
 
1533
      {0.000000000000000, 0.000000000000000, 0.200000000000000, 0.000000000000000, 0.000000000000000, 0.163299316185545};
 
1534
      
 
1535
      // Tables of derivatives of the polynomial base (transpose).
 
1536
      static const double dmats0[6][6] = \
 
1537
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1538
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1539
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1540
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1541
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1542
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1543
      
 
1544
      static const double dmats1[6][6] = \
 
1545
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1546
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1547
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1548
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1549
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1550
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1551
      
 
1552
      // Compute reference derivatives.
 
1553
      // Declare pointer to array of derivatives on FIAT element.
 
1554
      double *derivatives = new double[num_derivatives];
 
1555
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1556
      {
 
1557
        derivatives[r] = 0.000000000000000;
 
1558
      }// end loop over 'r'
 
1559
      
 
1560
      // Declare derivative matrix (of polynomial basis).
 
1561
      double dmats[6][6] = \
 
1562
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1563
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1564
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1565
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1566
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1567
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1568
      
 
1569
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
1570
      double dmats_old[6][6] = \
 
1571
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1572
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1573
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1574
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1575
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1576
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1577
      
 
1578
      // Loop possible derivatives.
 
1579
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1580
      {
 
1581
        // Resetting dmats values to compute next derivative.
 
1582
        for (unsigned int t = 0; t < 6; t++)
 
1583
        {
 
1584
          for (unsigned int u = 0; u < 6; u++)
 
1585
          {
 
1586
            dmats[t][u] = 0.000000000000000;
 
1587
            if (t == u)
 
1588
            {
 
1589
            dmats[t][u] = 1.000000000000000;
 
1590
            }
 
1591
            
 
1592
          }// end loop over 'u'
 
1593
        }// end loop over 't'
 
1594
        
 
1595
        // Looping derivative order to generate dmats.
 
1596
        for (unsigned int s = 0; s < n; s++)
 
1597
        {
 
1598
          // Updating dmats_old with new values and resetting dmats.
 
1599
          for (unsigned int t = 0; t < 6; t++)
 
1600
          {
 
1601
            for (unsigned int u = 0; u < 6; u++)
 
1602
            {
 
1603
              dmats_old[t][u] = dmats[t][u];
 
1604
              dmats[t][u] = 0.000000000000000;
 
1605
            }// end loop over 'u'
 
1606
          }// end loop over 't'
 
1607
          
 
1608
          // Update dmats using an inner product.
 
1609
          if (combinations[r][s] == 0)
 
1610
          {
 
1611
          for (unsigned int t = 0; t < 6; t++)
 
1612
          {
 
1613
            for (unsigned int u = 0; u < 6; u++)
 
1614
            {
 
1615
              for (unsigned int tu = 0; tu < 6; tu++)
 
1616
              {
 
1617
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
1618
              }// end loop over 'tu'
 
1619
            }// end loop over 'u'
 
1620
          }// end loop over 't'
 
1621
          }
 
1622
          
 
1623
          if (combinations[r][s] == 1)
 
1624
          {
 
1625
          for (unsigned int t = 0; t < 6; t++)
 
1626
          {
 
1627
            for (unsigned int u = 0; u < 6; u++)
 
1628
            {
 
1629
              for (unsigned int tu = 0; tu < 6; tu++)
 
1630
              {
 
1631
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
1632
              }// end loop over 'tu'
 
1633
            }// end loop over 'u'
 
1634
          }// end loop over 't'
 
1635
          }
 
1636
          
 
1637
        }// end loop over 's'
 
1638
        for (unsigned int s = 0; s < 6; s++)
 
1639
        {
 
1640
          for (unsigned int t = 0; t < 6; t++)
 
1641
          {
 
1642
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
1643
          }// end loop over 't'
 
1644
        }// end loop over 's'
 
1645
      }// end loop over 'r'
 
1646
      
 
1647
      // Transform derivatives back to physical element
 
1648
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1649
      {
 
1650
        for (unsigned int s = 0; s < num_derivatives; s++)
 
1651
        {
 
1652
          values[r] += transform[r][s]*derivatives[s];
 
1653
        }// end loop over 's'
 
1654
      }// end loop over 'r'
 
1655
      
 
1656
      // Delete pointer to array of derivatives on FIAT element
 
1657
      delete [] derivatives;
 
1658
      
 
1659
      // Delete pointer to array of combinations of derivatives and transform
 
1660
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1661
      {
 
1662
        delete [] combinations[r];
 
1663
      }// end loop over 'r'
 
1664
      delete [] combinations;
 
1665
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1666
      {
 
1667
        delete [] transform[r];
 
1668
      }// end loop over 'r'
 
1669
      delete [] transform;
 
1670
        break;
 
1671
      }
 
1672
    case 3:
 
1673
      {
 
1674
        
 
1675
      // Array of basisvalues.
 
1676
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
1677
      
 
1678
      // Declare helper variables.
 
1679
      unsigned int rr = 0;
 
1680
      unsigned int ss = 0;
 
1681
      unsigned int tt = 0;
 
1682
      double tmp5 = 0.000000000000000;
 
1683
      double tmp6 = 0.000000000000000;
 
1684
      double tmp7 = 0.000000000000000;
 
1685
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
1686
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
1687
      double tmp2 = tmp1*tmp1;
 
1688
      
 
1689
      // Compute basisvalues.
 
1690
      basisvalues[0] = 1.000000000000000;
 
1691
      basisvalues[1] = tmp0;
 
1692
      for (unsigned int r = 1; r < 2; r++)
 
1693
      {
 
1694
        rr = (r + 1)*((r + 1) + 1)/2;
 
1695
        ss = r*(r + 1)/2;
 
1696
        tt = (r - 1)*((r - 1) + 1)/2;
 
1697
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
1698
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
1699
      }// end loop over 'r'
 
1700
      for (unsigned int r = 0; r < 2; r++)
 
1701
      {
 
1702
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
1703
        ss = r*(r + 1)/2;
 
1704
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
1705
      }// end loop over 'r'
 
1706
      for (unsigned int r = 0; r < 1; r++)
 
1707
      {
 
1708
        for (unsigned int s = 1; s < 2 - r; s++)
 
1709
        {
 
1710
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
1711
          ss = (r + s)*(r + s + 1)/2 + s;
 
1712
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
1713
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1714
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1715
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1716
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
1717
        }// end loop over 's'
 
1718
      }// end loop over 'r'
 
1719
      for (unsigned int r = 0; r < 3; r++)
 
1720
      {
 
1721
        for (unsigned int s = 0; s < 3 - r; s++)
 
1722
        {
 
1723
          rr = (r + s)*(r + s + 1)/2 + s;
 
1724
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
1725
        }// end loop over 's'
 
1726
      }// end loop over 'r'
 
1727
      
 
1728
      // Table(s) of coefficients.
 
1729
      static const double coefficients0[6] = \
 
1730
      {0.471404520791032, 0.230940107675850, 0.133333333333333, 0.000000000000000, 0.188561808316413, -0.163299316185545};
 
1731
      
 
1732
      // Tables of derivatives of the polynomial base (transpose).
 
1733
      static const double dmats0[6][6] = \
 
1734
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1735
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1736
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1737
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1738
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1739
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1740
      
 
1741
      static const double dmats1[6][6] = \
 
1742
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1743
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1744
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1745
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1746
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1747
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1748
      
 
1749
      // Compute reference derivatives.
 
1750
      // Declare pointer to array of derivatives on FIAT element.
 
1751
      double *derivatives = new double[num_derivatives];
 
1752
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1753
      {
 
1754
        derivatives[r] = 0.000000000000000;
 
1755
      }// end loop over 'r'
 
1756
      
 
1757
      // Declare derivative matrix (of polynomial basis).
 
1758
      double dmats[6][6] = \
 
1759
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1760
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1761
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1762
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1763
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1764
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1765
      
 
1766
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
1767
      double dmats_old[6][6] = \
 
1768
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1769
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1770
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1771
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1772
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1773
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1774
      
 
1775
      // Loop possible derivatives.
 
1776
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1777
      {
 
1778
        // Resetting dmats values to compute next derivative.
 
1779
        for (unsigned int t = 0; t < 6; t++)
 
1780
        {
 
1781
          for (unsigned int u = 0; u < 6; u++)
 
1782
          {
 
1783
            dmats[t][u] = 0.000000000000000;
 
1784
            if (t == u)
 
1785
            {
 
1786
            dmats[t][u] = 1.000000000000000;
 
1787
            }
 
1788
            
 
1789
          }// end loop over 'u'
 
1790
        }// end loop over 't'
 
1791
        
 
1792
        // Looping derivative order to generate dmats.
 
1793
        for (unsigned int s = 0; s < n; s++)
 
1794
        {
 
1795
          // Updating dmats_old with new values and resetting dmats.
 
1796
          for (unsigned int t = 0; t < 6; t++)
 
1797
          {
 
1798
            for (unsigned int u = 0; u < 6; u++)
 
1799
            {
 
1800
              dmats_old[t][u] = dmats[t][u];
 
1801
              dmats[t][u] = 0.000000000000000;
 
1802
            }// end loop over 'u'
 
1803
          }// end loop over 't'
 
1804
          
 
1805
          // Update dmats using an inner product.
 
1806
          if (combinations[r][s] == 0)
 
1807
          {
 
1808
          for (unsigned int t = 0; t < 6; t++)
 
1809
          {
 
1810
            for (unsigned int u = 0; u < 6; u++)
 
1811
            {
 
1812
              for (unsigned int tu = 0; tu < 6; tu++)
 
1813
              {
 
1814
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
1815
              }// end loop over 'tu'
 
1816
            }// end loop over 'u'
 
1817
          }// end loop over 't'
 
1818
          }
 
1819
          
 
1820
          if (combinations[r][s] == 1)
 
1821
          {
 
1822
          for (unsigned int t = 0; t < 6; t++)
 
1823
          {
 
1824
            for (unsigned int u = 0; u < 6; u++)
 
1825
            {
 
1826
              for (unsigned int tu = 0; tu < 6; tu++)
 
1827
              {
 
1828
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
1829
              }// end loop over 'tu'
 
1830
            }// end loop over 'u'
 
1831
          }// end loop over 't'
 
1832
          }
 
1833
          
 
1834
        }// end loop over 's'
 
1835
        for (unsigned int s = 0; s < 6; s++)
 
1836
        {
 
1837
          for (unsigned int t = 0; t < 6; t++)
 
1838
          {
 
1839
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
1840
          }// end loop over 't'
 
1841
        }// end loop over 's'
 
1842
      }// end loop over 'r'
 
1843
      
 
1844
      // Transform derivatives back to physical element
 
1845
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1846
      {
 
1847
        for (unsigned int s = 0; s < num_derivatives; s++)
 
1848
        {
 
1849
          values[r] += transform[r][s]*derivatives[s];
 
1850
        }// end loop over 's'
 
1851
      }// end loop over 'r'
 
1852
      
 
1853
      // Delete pointer to array of derivatives on FIAT element
 
1854
      delete [] derivatives;
 
1855
      
 
1856
      // Delete pointer to array of combinations of derivatives and transform
 
1857
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1858
      {
 
1859
        delete [] combinations[r];
 
1860
      }// end loop over 'r'
 
1861
      delete [] combinations;
 
1862
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1863
      {
 
1864
        delete [] transform[r];
 
1865
      }// end loop over 'r'
 
1866
      delete [] transform;
 
1867
        break;
 
1868
      }
 
1869
    case 4:
 
1870
      {
 
1871
        
 
1872
      // Array of basisvalues.
 
1873
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
1874
      
 
1875
      // Declare helper variables.
 
1876
      unsigned int rr = 0;
 
1877
      unsigned int ss = 0;
 
1878
      unsigned int tt = 0;
 
1879
      double tmp5 = 0.000000000000000;
 
1880
      double tmp6 = 0.000000000000000;
 
1881
      double tmp7 = 0.000000000000000;
 
1882
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
1883
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
1884
      double tmp2 = tmp1*tmp1;
 
1885
      
 
1886
      // Compute basisvalues.
 
1887
      basisvalues[0] = 1.000000000000000;
 
1888
      basisvalues[1] = tmp0;
 
1889
      for (unsigned int r = 1; r < 2; r++)
 
1890
      {
 
1891
        rr = (r + 1)*((r + 1) + 1)/2;
 
1892
        ss = r*(r + 1)/2;
 
1893
        tt = (r - 1)*((r - 1) + 1)/2;
 
1894
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
1895
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
1896
      }// end loop over 'r'
 
1897
      for (unsigned int r = 0; r < 2; r++)
 
1898
      {
 
1899
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
1900
        ss = r*(r + 1)/2;
 
1901
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
1902
      }// end loop over 'r'
 
1903
      for (unsigned int r = 0; r < 1; r++)
 
1904
      {
 
1905
        for (unsigned int s = 1; s < 2 - r; s++)
 
1906
        {
 
1907
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
1908
          ss = (r + s)*(r + s + 1)/2 + s;
 
1909
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
1910
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1911
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1912
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
1913
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
1914
        }// end loop over 's'
 
1915
      }// end loop over 'r'
 
1916
      for (unsigned int r = 0; r < 3; r++)
 
1917
      {
 
1918
        for (unsigned int s = 0; s < 3 - r; s++)
 
1919
        {
 
1920
          rr = (r + s)*(r + s + 1)/2 + s;
 
1921
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
1922
        }// end loop over 's'
 
1923
      }// end loop over 'r'
 
1924
      
 
1925
      // Table(s) of coefficients.
 
1926
      static const double coefficients0[6] = \
 
1927
      {0.471404520791032, -0.230940107675850, 0.133333333333333, 0.000000000000000, -0.188561808316413, -0.163299316185545};
 
1928
      
 
1929
      // Tables of derivatives of the polynomial base (transpose).
 
1930
      static const double dmats0[6][6] = \
 
1931
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1932
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1933
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1934
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1935
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1936
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1937
      
 
1938
      static const double dmats1[6][6] = \
 
1939
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1940
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1941
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1942
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1943
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1944
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
1945
      
 
1946
      // Compute reference derivatives.
 
1947
      // Declare pointer to array of derivatives on FIAT element.
 
1948
      double *derivatives = new double[num_derivatives];
 
1949
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1950
      {
 
1951
        derivatives[r] = 0.000000000000000;
 
1952
      }// end loop over 'r'
 
1953
      
 
1954
      // Declare derivative matrix (of polynomial basis).
 
1955
      double dmats[6][6] = \
 
1956
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1957
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1958
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1959
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1960
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1961
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1962
      
 
1963
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
1964
      double dmats_old[6][6] = \
 
1965
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1966
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1967
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
1968
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
1969
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
1970
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
1971
      
 
1972
      // Loop possible derivatives.
 
1973
      for (unsigned int r = 0; r < num_derivatives; r++)
 
1974
      {
 
1975
        // Resetting dmats values to compute next derivative.
 
1976
        for (unsigned int t = 0; t < 6; t++)
 
1977
        {
 
1978
          for (unsigned int u = 0; u < 6; u++)
 
1979
          {
 
1980
            dmats[t][u] = 0.000000000000000;
 
1981
            if (t == u)
 
1982
            {
 
1983
            dmats[t][u] = 1.000000000000000;
 
1984
            }
 
1985
            
 
1986
          }// end loop over 'u'
 
1987
        }// end loop over 't'
 
1988
        
 
1989
        // Looping derivative order to generate dmats.
 
1990
        for (unsigned int s = 0; s < n; s++)
 
1991
        {
 
1992
          // Updating dmats_old with new values and resetting dmats.
 
1993
          for (unsigned int t = 0; t < 6; t++)
 
1994
          {
 
1995
            for (unsigned int u = 0; u < 6; u++)
 
1996
            {
 
1997
              dmats_old[t][u] = dmats[t][u];
 
1998
              dmats[t][u] = 0.000000000000000;
 
1999
            }// end loop over 'u'
 
2000
          }// end loop over 't'
 
2001
          
 
2002
          // Update dmats using an inner product.
 
2003
          if (combinations[r][s] == 0)
 
2004
          {
 
2005
          for (unsigned int t = 0; t < 6; t++)
 
2006
          {
 
2007
            for (unsigned int u = 0; u < 6; u++)
 
2008
            {
 
2009
              for (unsigned int tu = 0; tu < 6; tu++)
 
2010
              {
 
2011
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
2012
              }// end loop over 'tu'
 
2013
            }// end loop over 'u'
 
2014
          }// end loop over 't'
 
2015
          }
 
2016
          
 
2017
          if (combinations[r][s] == 1)
 
2018
          {
 
2019
          for (unsigned int t = 0; t < 6; t++)
 
2020
          {
 
2021
            for (unsigned int u = 0; u < 6; u++)
 
2022
            {
 
2023
              for (unsigned int tu = 0; tu < 6; tu++)
 
2024
              {
 
2025
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
2026
              }// end loop over 'tu'
 
2027
            }// end loop over 'u'
 
2028
          }// end loop over 't'
 
2029
          }
 
2030
          
 
2031
        }// end loop over 's'
 
2032
        for (unsigned int s = 0; s < 6; s++)
 
2033
        {
 
2034
          for (unsigned int t = 0; t < 6; t++)
 
2035
          {
 
2036
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
2037
          }// end loop over 't'
 
2038
        }// end loop over 's'
 
2039
      }// end loop over 'r'
 
2040
      
 
2041
      // Transform derivatives back to physical element
 
2042
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2043
      {
 
2044
        for (unsigned int s = 0; s < num_derivatives; s++)
 
2045
        {
 
2046
          values[r] += transform[r][s]*derivatives[s];
 
2047
        }// end loop over 's'
 
2048
      }// end loop over 'r'
 
2049
      
 
2050
      // Delete pointer to array of derivatives on FIAT element
 
2051
      delete [] derivatives;
 
2052
      
 
2053
      // Delete pointer to array of combinations of derivatives and transform
 
2054
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2055
      {
 
2056
        delete [] combinations[r];
 
2057
      }// end loop over 'r'
 
2058
      delete [] combinations;
 
2059
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2060
      {
 
2061
        delete [] transform[r];
 
2062
      }// end loop over 'r'
 
2063
      delete [] transform;
 
2064
        break;
 
2065
      }
 
2066
    case 5:
 
2067
      {
 
2068
        
 
2069
      // Array of basisvalues.
 
2070
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
2071
      
 
2072
      // Declare helper variables.
 
2073
      unsigned int rr = 0;
 
2074
      unsigned int ss = 0;
 
2075
      unsigned int tt = 0;
 
2076
      double tmp5 = 0.000000000000000;
 
2077
      double tmp6 = 0.000000000000000;
 
2078
      double tmp7 = 0.000000000000000;
 
2079
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
2080
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
2081
      double tmp2 = tmp1*tmp1;
 
2082
      
 
2083
      // Compute basisvalues.
 
2084
      basisvalues[0] = 1.000000000000000;
 
2085
      basisvalues[1] = tmp0;
 
2086
      for (unsigned int r = 1; r < 2; r++)
 
2087
      {
 
2088
        rr = (r + 1)*((r + 1) + 1)/2;
 
2089
        ss = r*(r + 1)/2;
 
2090
        tt = (r - 1)*((r - 1) + 1)/2;
 
2091
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
2092
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
2093
      }// end loop over 'r'
 
2094
      for (unsigned int r = 0; r < 2; r++)
 
2095
      {
 
2096
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
2097
        ss = r*(r + 1)/2;
 
2098
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
2099
      }// end loop over 'r'
 
2100
      for (unsigned int r = 0; r < 1; r++)
 
2101
      {
 
2102
        for (unsigned int s = 1; s < 2 - r; s++)
 
2103
        {
 
2104
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
2105
          ss = (r + s)*(r + s + 1)/2 + s;
 
2106
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
2107
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2108
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2109
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2110
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
2111
        }// end loop over 's'
 
2112
      }// end loop over 'r'
 
2113
      for (unsigned int r = 0; r < 3; r++)
 
2114
      {
 
2115
        for (unsigned int s = 0; s < 3 - r; s++)
 
2116
        {
 
2117
          rr = (r + s)*(r + s + 1)/2 + s;
 
2118
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
2119
        }// end loop over 's'
 
2120
      }// end loop over 'r'
 
2121
      
 
2122
      // Table(s) of coefficients.
 
2123
      static const double coefficients0[6] = \
 
2124
      {0.471404520791032, 0.000000000000000, -0.266666666666667, -0.243432247780074, 0.000000000000000, 0.054433105395182};
 
2125
      
 
2126
      // Tables of derivatives of the polynomial base (transpose).
 
2127
      static const double dmats0[6][6] = \
 
2128
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2129
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2130
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2131
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2132
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2133
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
2134
      
 
2135
      static const double dmats1[6][6] = \
 
2136
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2137
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2138
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2139
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2140
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2141
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
2142
      
 
2143
      // Compute reference derivatives.
 
2144
      // Declare pointer to array of derivatives on FIAT element.
 
2145
      double *derivatives = new double[num_derivatives];
 
2146
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2147
      {
 
2148
        derivatives[r] = 0.000000000000000;
 
2149
      }// end loop over 'r'
 
2150
      
 
2151
      // Declare derivative matrix (of polynomial basis).
 
2152
      double dmats[6][6] = \
 
2153
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2154
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2155
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2156
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
2157
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
2158
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
2159
      
 
2160
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
2161
      double dmats_old[6][6] = \
 
2162
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2163
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2164
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
2165
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
2166
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
2167
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
2168
      
 
2169
      // Loop possible derivatives.
 
2170
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2171
      {
 
2172
        // Resetting dmats values to compute next derivative.
 
2173
        for (unsigned int t = 0; t < 6; t++)
 
2174
        {
 
2175
          for (unsigned int u = 0; u < 6; u++)
 
2176
          {
 
2177
            dmats[t][u] = 0.000000000000000;
 
2178
            if (t == u)
 
2179
            {
 
2180
            dmats[t][u] = 1.000000000000000;
 
2181
            }
 
2182
            
 
2183
          }// end loop over 'u'
 
2184
        }// end loop over 't'
 
2185
        
 
2186
        // Looping derivative order to generate dmats.
 
2187
        for (unsigned int s = 0; s < n; s++)
 
2188
        {
 
2189
          // Updating dmats_old with new values and resetting dmats.
 
2190
          for (unsigned int t = 0; t < 6; t++)
 
2191
          {
 
2192
            for (unsigned int u = 0; u < 6; u++)
 
2193
            {
 
2194
              dmats_old[t][u] = dmats[t][u];
 
2195
              dmats[t][u] = 0.000000000000000;
 
2196
            }// end loop over 'u'
 
2197
          }// end loop over 't'
 
2198
          
 
2199
          // Update dmats using an inner product.
 
2200
          if (combinations[r][s] == 0)
 
2201
          {
 
2202
          for (unsigned int t = 0; t < 6; t++)
 
2203
          {
 
2204
            for (unsigned int u = 0; u < 6; u++)
 
2205
            {
 
2206
              for (unsigned int tu = 0; tu < 6; tu++)
 
2207
              {
 
2208
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
2209
              }// end loop over 'tu'
 
2210
            }// end loop over 'u'
 
2211
          }// end loop over 't'
 
2212
          }
 
2213
          
 
2214
          if (combinations[r][s] == 1)
 
2215
          {
 
2216
          for (unsigned int t = 0; t < 6; t++)
 
2217
          {
 
2218
            for (unsigned int u = 0; u < 6; u++)
 
2219
            {
 
2220
              for (unsigned int tu = 0; tu < 6; tu++)
 
2221
              {
 
2222
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
2223
              }// end loop over 'tu'
 
2224
            }// end loop over 'u'
 
2225
          }// end loop over 't'
 
2226
          }
 
2227
          
 
2228
        }// end loop over 's'
 
2229
        for (unsigned int s = 0; s < 6; s++)
 
2230
        {
 
2231
          for (unsigned int t = 0; t < 6; t++)
 
2232
          {
 
2233
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
2234
          }// end loop over 't'
 
2235
        }// end loop over 's'
 
2236
      }// end loop over 'r'
 
2237
      
 
2238
      // Transform derivatives back to physical element
 
2239
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2240
      {
 
2241
        for (unsigned int s = 0; s < num_derivatives; s++)
 
2242
        {
 
2243
          values[r] += transform[r][s]*derivatives[s];
 
2244
        }// end loop over 's'
 
2245
      }// end loop over 'r'
 
2246
      
 
2247
      // Delete pointer to array of derivatives on FIAT element
 
2248
      delete [] derivatives;
 
2249
      
 
2250
      // Delete pointer to array of combinations of derivatives and transform
 
2251
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2252
      {
 
2253
        delete [] combinations[r];
 
2254
      }// end loop over 'r'
 
2255
      delete [] combinations;
 
2256
      for (unsigned int r = 0; r < num_derivatives; r++)
 
2257
      {
 
2258
        delete [] transform[r];
 
2259
      }// end loop over 'r'
 
2260
      delete [] transform;
 
2261
        break;
 
2262
      }
 
2263
    }
 
2264
    
 
2265
  }
 
2266
 
 
2267
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
2268
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
2269
                                              double* values,
 
2270
                                              const double* coordinates,
 
2271
                                              const ufc::cell& c) const
 
2272
  {
 
2273
    // Compute number of derivatives.
 
2274
    unsigned int num_derivatives = 1;
 
2275
    for (unsigned int r = 0; r < n; r++)
 
2276
    {
 
2277
      num_derivatives *= 2;
 
2278
    }// end loop over 'r'
 
2279
    
 
2280
    // Helper variable to hold values of a single dof.
 
2281
    double *dof_values = new double[num_derivatives];
 
2282
    for (unsigned int r = 0; r < num_derivatives; r++)
 
2283
    {
 
2284
      dof_values[r] = 0.000000000000000;
 
2285
    }// end loop over 'r'
 
2286
    
 
2287
    // Loop dofs and call evaluate_basis_derivatives.
 
2288
    for (unsigned int r = 0; r < 6; r++)
 
2289
    {
 
2290
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
2291
      for (unsigned int s = 0; s < num_derivatives; s++)
 
2292
      {
 
2293
        values[r*num_derivatives + s] = dof_values[s];
 
2294
      }// end loop over 's'
 
2295
    }// end loop over 'r'
 
2296
    
 
2297
    // Delete pointer.
 
2298
    delete [] dof_values;
 
2299
  }
 
2300
 
 
2301
  /// Evaluate linear functional for dof i on the function f
 
2302
  virtual double evaluate_dof(unsigned int i,
 
2303
                              const ufc::function& f,
 
2304
                              const ufc::cell& c) const
 
2305
  {
 
2306
    // Declare variables for result of evaluation.
 
2307
    double vals[1];
 
2308
    
 
2309
    // Declare variable for physical coordinates.
 
2310
    double y[2];
 
2311
    const double * const * x = c.coordinates;
 
2312
    switch (i)
 
2313
    {
 
2314
    case 0:
 
2315
      {
 
2316
        y[0] = x[0][0];
 
2317
      y[1] = x[0][1];
 
2318
      f.evaluate(vals, y, c);
 
2319
      return vals[0];
 
2320
        break;
 
2321
      }
 
2322
    case 1:
 
2323
      {
 
2324
        y[0] = x[1][0];
 
2325
      y[1] = x[1][1];
 
2326
      f.evaluate(vals, y, c);
 
2327
      return vals[0];
 
2328
        break;
 
2329
      }
 
2330
    case 2:
 
2331
      {
 
2332
        y[0] = x[2][0];
 
2333
      y[1] = x[2][1];
 
2334
      f.evaluate(vals, y, c);
 
2335
      return vals[0];
 
2336
        break;
 
2337
      }
 
2338
    case 3:
 
2339
      {
 
2340
        y[0] = 0.500000000000000*x[1][0] + 0.500000000000000*x[2][0];
 
2341
      y[1] = 0.500000000000000*x[1][1] + 0.500000000000000*x[2][1];
 
2342
      f.evaluate(vals, y, c);
 
2343
      return vals[0];
 
2344
        break;
 
2345
      }
 
2346
    case 4:
 
2347
      {
 
2348
        y[0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[2][0];
 
2349
      y[1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[2][1];
 
2350
      f.evaluate(vals, y, c);
 
2351
      return vals[0];
 
2352
        break;
 
2353
      }
 
2354
    case 5:
 
2355
      {
 
2356
        y[0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[1][0];
 
2357
      y[1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[1][1];
 
2358
      f.evaluate(vals, y, c);
 
2359
      return vals[0];
 
2360
        break;
 
2361
      }
 
2362
    }
 
2363
    
 
2364
    return 0.000000000000000;
 
2365
  }
 
2366
 
 
2367
  /// Evaluate linear functionals for all dofs on the function f
 
2368
  virtual void evaluate_dofs(double* values,
 
2369
                             const ufc::function& f,
 
2370
                             const ufc::cell& c) const
 
2371
  {
 
2372
    // Declare variables for result of evaluation.
 
2373
    double vals[1];
 
2374
    
 
2375
    // Declare variable for physical coordinates.
 
2376
    double y[2];
 
2377
    const double * const * x = c.coordinates;
 
2378
    y[0] = x[0][0];
 
2379
    y[1] = x[0][1];
 
2380
    f.evaluate(vals, y, c);
 
2381
    values[0] = vals[0];
 
2382
    y[0] = x[1][0];
 
2383
    y[1] = x[1][1];
 
2384
    f.evaluate(vals, y, c);
 
2385
    values[1] = vals[0];
 
2386
    y[0] = x[2][0];
 
2387
    y[1] = x[2][1];
 
2388
    f.evaluate(vals, y, c);
 
2389
    values[2] = vals[0];
 
2390
    y[0] = 0.500000000000000*x[1][0] + 0.500000000000000*x[2][0];
 
2391
    y[1] = 0.500000000000000*x[1][1] + 0.500000000000000*x[2][1];
 
2392
    f.evaluate(vals, y, c);
 
2393
    values[3] = vals[0];
 
2394
    y[0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[2][0];
 
2395
    y[1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[2][1];
 
2396
    f.evaluate(vals, y, c);
 
2397
    values[4] = vals[0];
 
2398
    y[0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[1][0];
 
2399
    y[1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[1][1];
 
2400
    f.evaluate(vals, y, c);
 
2401
    values[5] = vals[0];
 
2402
  }
 
2403
 
 
2404
  /// Interpolate vertex values from dof values
 
2405
  virtual void interpolate_vertex_values(double* vertex_values,
 
2406
                                         const double* dof_values,
 
2407
                                         const ufc::cell& c) const
 
2408
  {
 
2409
    // Evaluate function and change variables
 
2410
    vertex_values[0] = dof_values[0];
 
2411
    vertex_values[1] = dof_values[1];
 
2412
    vertex_values[2] = dof_values[2];
 
2413
  }
 
2414
 
 
2415
  /// Map coordinate xhat from reference cell to coordinate x in cell
 
2416
  virtual void map_from_reference_cell(double* x,
 
2417
                                       const double* xhat,
 
2418
                                       const ufc::cell& c)
 
2419
  {
 
2420
    throw std::runtime_error("map_from_reference_cell not yet implemented (introduced in UFC 2.0).");
 
2421
  }
 
2422
 
 
2423
  /// Map from coordinate x in cell to coordinate xhat in reference cell
 
2424
  virtual void map_to_reference_cell(double* xhat,
 
2425
                                     const double* x,
 
2426
                                     const ufc::cell& c)
 
2427
  {
 
2428
    throw std::runtime_error("map_to_reference_cell not yet implemented (introduced in UFC 2.0).");
 
2429
  }
 
2430
 
 
2431
  /// Return the number of sub elements (for a mixed element)
 
2432
  virtual unsigned int num_sub_elements() const
 
2433
  {
 
2434
    return 0;
 
2435
  }
 
2436
 
 
2437
  /// Create a new finite element for sub element i (for a mixed element)
 
2438
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
2439
  {
 
2440
    return 0;
 
2441
  }
 
2442
 
 
2443
  /// Create a new class instance
 
2444
  virtual ufc::finite_element* create() const
 
2445
  {
 
2446
    return new adaptivepoisson_finite_element_1();
 
2447
  }
 
2448
 
 
2449
};
 
2450
 
 
2451
/// This class defines the interface for a finite element.
 
2452
 
 
2453
class adaptivepoisson_finite_element_2: public ufc::finite_element
 
2454
{
 
2455
public:
 
2456
 
 
2457
  /// Constructor
 
2458
  adaptivepoisson_finite_element_2() : ufc::finite_element()
 
2459
  {
 
2460
    // Do nothing
 
2461
  }
 
2462
 
 
2463
  /// Destructor
 
2464
  virtual ~adaptivepoisson_finite_element_2()
 
2465
  {
 
2466
    // Do nothing
 
2467
  }
 
2468
 
 
2469
  /// Return a string identifying the finite element
 
2470
  virtual const char* signature() const
 
2471
  {
 
2472
    return "FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2)";
 
2473
  }
 
2474
 
 
2475
  /// Return the cell shape
 
2476
  virtual ufc::shape cell_shape() const
 
2477
  {
 
2478
    return ufc::triangle;
 
2479
  }
 
2480
 
 
2481
  /// Return the topological dimension of the cell shape
 
2482
  virtual unsigned int topological_dimension() const
 
2483
  {
 
2484
    return 2;
 
2485
  }
 
2486
 
 
2487
  /// Return the geometric dimension of the cell shape
 
2488
  virtual unsigned int geometric_dimension() const
 
2489
  {
 
2490
    return 2;
 
2491
  }
 
2492
 
 
2493
  /// Return the dimension of the finite element function space
 
2494
  virtual unsigned int space_dimension() const
 
2495
  {
 
2496
    return 6;
 
2497
  }
 
2498
 
 
2499
  /// Return the rank of the value space
 
2500
  virtual unsigned int value_rank() const
 
2501
  {
 
2502
    return 0;
 
2503
  }
 
2504
 
 
2505
  /// Return the dimension of the value space for axis i
 
2506
  virtual unsigned int value_dimension(unsigned int i) const
 
2507
  {
 
2508
    return 1;
 
2509
  }
 
2510
 
 
2511
  /// Evaluate basis function i at given point in cell
 
2512
  virtual void evaluate_basis(unsigned int i,
 
2513
                              double* values,
 
2514
                              const double* coordinates,
 
2515
                              const ufc::cell& c) const
 
2516
  {
 
2517
    // Extract vertex coordinates
 
2518
    const double * const * x = c.coordinates;
 
2519
    
 
2520
    // Compute Jacobian of affine map from reference cell
 
2521
    const double J_00 = x[1][0] - x[0][0];
 
2522
    const double J_01 = x[2][0] - x[0][0];
 
2523
    const double J_10 = x[1][1] - x[0][1];
 
2524
    const double J_11 = x[2][1] - x[0][1];
 
2525
    
 
2526
    // Compute determinant of Jacobian
 
2527
    double detJ = J_00*J_11 - J_01*J_10;
 
2528
    
 
2529
    // Compute inverse of Jacobian
 
2530
    
 
2531
    // Compute constants
 
2532
    const double C0 = x[1][0] + x[2][0];
 
2533
    const double C1 = x[1][1] + x[2][1];
 
2534
    
 
2535
    // Get coordinates and map to the reference (FIAT) element
 
2536
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
2537
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
2538
    
 
2539
    // Reset values.
 
2540
    *values = 0.000000000000000;
 
2541
    switch (i)
 
2542
    {
 
2543
    case 0:
 
2544
      {
 
2545
        
 
2546
      // Array of basisvalues.
 
2547
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
2548
      
 
2549
      // Declare helper variables.
 
2550
      unsigned int rr = 0;
 
2551
      unsigned int ss = 0;
 
2552
      unsigned int tt = 0;
 
2553
      double tmp5 = 0.000000000000000;
 
2554
      double tmp6 = 0.000000000000000;
 
2555
      double tmp7 = 0.000000000000000;
 
2556
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
2557
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
2558
      double tmp2 = tmp1*tmp1;
 
2559
      
 
2560
      // Compute basisvalues.
 
2561
      basisvalues[0] = 1.000000000000000;
 
2562
      basisvalues[1] = tmp0;
 
2563
      for (unsigned int r = 1; r < 2; r++)
 
2564
      {
 
2565
        rr = (r + 1)*((r + 1) + 1)/2;
 
2566
        ss = r*(r + 1)/2;
 
2567
        tt = (r - 1)*((r - 1) + 1)/2;
 
2568
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
2569
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
2570
      }// end loop over 'r'
 
2571
      for (unsigned int r = 0; r < 2; r++)
 
2572
      {
 
2573
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
2574
        ss = r*(r + 1)/2;
 
2575
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
2576
      }// end loop over 'r'
 
2577
      for (unsigned int r = 0; r < 1; r++)
 
2578
      {
 
2579
        for (unsigned int s = 1; s < 2 - r; s++)
 
2580
        {
 
2581
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
2582
          ss = (r + s)*(r + s + 1)/2 + s;
 
2583
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
2584
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2585
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2586
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2587
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
2588
        }// end loop over 's'
 
2589
      }// end loop over 'r'
 
2590
      for (unsigned int r = 0; r < 3; r++)
 
2591
      {
 
2592
        for (unsigned int s = 0; s < 3 - r; s++)
 
2593
        {
 
2594
          rr = (r + s)*(r + s + 1)/2 + s;
 
2595
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
2596
        }// end loop over 's'
 
2597
      }// end loop over 'r'
 
2598
      
 
2599
      // Table(s) of coefficients.
 
2600
      static const double coefficients0[6] = \
 
2601
      {0.000000000000000, -0.173205080756888, -0.100000000000000, 0.121716123890037, 0.094280904158206, 0.054433105395182};
 
2602
      
 
2603
      // Compute value(s).
 
2604
      for (unsigned int r = 0; r < 6; r++)
 
2605
      {
 
2606
        *values += coefficients0[r]*basisvalues[r];
 
2607
      }// end loop over 'r'
 
2608
        break;
 
2609
      }
 
2610
    case 1:
 
2611
      {
 
2612
        
 
2613
      // Array of basisvalues.
 
2614
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
2615
      
 
2616
      // Declare helper variables.
 
2617
      unsigned int rr = 0;
 
2618
      unsigned int ss = 0;
 
2619
      unsigned int tt = 0;
 
2620
      double tmp5 = 0.000000000000000;
 
2621
      double tmp6 = 0.000000000000000;
 
2622
      double tmp7 = 0.000000000000000;
 
2623
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
2624
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
2625
      double tmp2 = tmp1*tmp1;
 
2626
      
 
2627
      // Compute basisvalues.
 
2628
      basisvalues[0] = 1.000000000000000;
 
2629
      basisvalues[1] = tmp0;
 
2630
      for (unsigned int r = 1; r < 2; r++)
 
2631
      {
 
2632
        rr = (r + 1)*((r + 1) + 1)/2;
 
2633
        ss = r*(r + 1)/2;
 
2634
        tt = (r - 1)*((r - 1) + 1)/2;
 
2635
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
2636
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
2637
      }// end loop over 'r'
 
2638
      for (unsigned int r = 0; r < 2; r++)
 
2639
      {
 
2640
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
2641
        ss = r*(r + 1)/2;
 
2642
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
2643
      }// end loop over 'r'
 
2644
      for (unsigned int r = 0; r < 1; r++)
 
2645
      {
 
2646
        for (unsigned int s = 1; s < 2 - r; s++)
 
2647
        {
 
2648
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
2649
          ss = (r + s)*(r + s + 1)/2 + s;
 
2650
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
2651
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2652
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2653
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2654
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
2655
        }// end loop over 's'
 
2656
      }// end loop over 'r'
 
2657
      for (unsigned int r = 0; r < 3; r++)
 
2658
      {
 
2659
        for (unsigned int s = 0; s < 3 - r; s++)
 
2660
        {
 
2661
          rr = (r + s)*(r + s + 1)/2 + s;
 
2662
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
2663
        }// end loop over 's'
 
2664
      }// end loop over 'r'
 
2665
      
 
2666
      // Table(s) of coefficients.
 
2667
      static const double coefficients0[6] = \
 
2668
      {0.000000000000000, 0.173205080756888, -0.100000000000000, 0.121716123890037, -0.094280904158206, 0.054433105395182};
 
2669
      
 
2670
      // Compute value(s).
 
2671
      for (unsigned int r = 0; r < 6; r++)
 
2672
      {
 
2673
        *values += coefficients0[r]*basisvalues[r];
 
2674
      }// end loop over 'r'
 
2675
        break;
 
2676
      }
 
2677
    case 2:
 
2678
      {
 
2679
        
 
2680
      // Array of basisvalues.
 
2681
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
2682
      
 
2683
      // Declare helper variables.
 
2684
      unsigned int rr = 0;
 
2685
      unsigned int ss = 0;
 
2686
      unsigned int tt = 0;
 
2687
      double tmp5 = 0.000000000000000;
 
2688
      double tmp6 = 0.000000000000000;
 
2689
      double tmp7 = 0.000000000000000;
 
2690
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
2691
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
2692
      double tmp2 = tmp1*tmp1;
 
2693
      
 
2694
      // Compute basisvalues.
 
2695
      basisvalues[0] = 1.000000000000000;
 
2696
      basisvalues[1] = tmp0;
 
2697
      for (unsigned int r = 1; r < 2; r++)
 
2698
      {
 
2699
        rr = (r + 1)*((r + 1) + 1)/2;
 
2700
        ss = r*(r + 1)/2;
 
2701
        tt = (r - 1)*((r - 1) + 1)/2;
 
2702
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
2703
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
2704
      }// end loop over 'r'
 
2705
      for (unsigned int r = 0; r < 2; r++)
 
2706
      {
 
2707
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
2708
        ss = r*(r + 1)/2;
 
2709
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
2710
      }// end loop over 'r'
 
2711
      for (unsigned int r = 0; r < 1; r++)
 
2712
      {
 
2713
        for (unsigned int s = 1; s < 2 - r; s++)
 
2714
        {
 
2715
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
2716
          ss = (r + s)*(r + s + 1)/2 + s;
 
2717
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
2718
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2719
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2720
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2721
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
2722
        }// end loop over 's'
 
2723
      }// end loop over 'r'
 
2724
      for (unsigned int r = 0; r < 3; r++)
 
2725
      {
 
2726
        for (unsigned int s = 0; s < 3 - r; s++)
 
2727
        {
 
2728
          rr = (r + s)*(r + s + 1)/2 + s;
 
2729
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
2730
        }// end loop over 's'
 
2731
      }// end loop over 'r'
 
2732
      
 
2733
      // Table(s) of coefficients.
 
2734
      static const double coefficients0[6] = \
 
2735
      {0.000000000000000, 0.000000000000000, 0.200000000000000, 0.000000000000000, 0.000000000000000, 0.163299316185545};
 
2736
      
 
2737
      // Compute value(s).
 
2738
      for (unsigned int r = 0; r < 6; r++)
 
2739
      {
 
2740
        *values += coefficients0[r]*basisvalues[r];
 
2741
      }// end loop over 'r'
 
2742
        break;
 
2743
      }
 
2744
    case 3:
 
2745
      {
 
2746
        
 
2747
      // Array of basisvalues.
 
2748
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
2749
      
 
2750
      // Declare helper variables.
 
2751
      unsigned int rr = 0;
 
2752
      unsigned int ss = 0;
 
2753
      unsigned int tt = 0;
 
2754
      double tmp5 = 0.000000000000000;
 
2755
      double tmp6 = 0.000000000000000;
 
2756
      double tmp7 = 0.000000000000000;
 
2757
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
2758
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
2759
      double tmp2 = tmp1*tmp1;
 
2760
      
 
2761
      // Compute basisvalues.
 
2762
      basisvalues[0] = 1.000000000000000;
 
2763
      basisvalues[1] = tmp0;
 
2764
      for (unsigned int r = 1; r < 2; r++)
 
2765
      {
 
2766
        rr = (r + 1)*((r + 1) + 1)/2;
 
2767
        ss = r*(r + 1)/2;
 
2768
        tt = (r - 1)*((r - 1) + 1)/2;
 
2769
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
2770
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
2771
      }// end loop over 'r'
 
2772
      for (unsigned int r = 0; r < 2; r++)
 
2773
      {
 
2774
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
2775
        ss = r*(r + 1)/2;
 
2776
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
2777
      }// end loop over 'r'
 
2778
      for (unsigned int r = 0; r < 1; r++)
 
2779
      {
 
2780
        for (unsigned int s = 1; s < 2 - r; s++)
 
2781
        {
 
2782
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
2783
          ss = (r + s)*(r + s + 1)/2 + s;
 
2784
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
2785
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2786
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2787
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2788
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
2789
        }// end loop over 's'
 
2790
      }// end loop over 'r'
 
2791
      for (unsigned int r = 0; r < 3; r++)
 
2792
      {
 
2793
        for (unsigned int s = 0; s < 3 - r; s++)
 
2794
        {
 
2795
          rr = (r + s)*(r + s + 1)/2 + s;
 
2796
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
2797
        }// end loop over 's'
 
2798
      }// end loop over 'r'
 
2799
      
 
2800
      // Table(s) of coefficients.
 
2801
      static const double coefficients0[6] = \
 
2802
      {0.471404520791032, 0.230940107675850, 0.133333333333333, 0.000000000000000, 0.188561808316413, -0.163299316185545};
 
2803
      
 
2804
      // Compute value(s).
 
2805
      for (unsigned int r = 0; r < 6; r++)
 
2806
      {
 
2807
        *values += coefficients0[r]*basisvalues[r];
 
2808
      }// end loop over 'r'
 
2809
        break;
 
2810
      }
 
2811
    case 4:
 
2812
      {
 
2813
        
 
2814
      // Array of basisvalues.
 
2815
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
2816
      
 
2817
      // Declare helper variables.
 
2818
      unsigned int rr = 0;
 
2819
      unsigned int ss = 0;
 
2820
      unsigned int tt = 0;
 
2821
      double tmp5 = 0.000000000000000;
 
2822
      double tmp6 = 0.000000000000000;
 
2823
      double tmp7 = 0.000000000000000;
 
2824
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
2825
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
2826
      double tmp2 = tmp1*tmp1;
 
2827
      
 
2828
      // Compute basisvalues.
 
2829
      basisvalues[0] = 1.000000000000000;
 
2830
      basisvalues[1] = tmp0;
 
2831
      for (unsigned int r = 1; r < 2; r++)
 
2832
      {
 
2833
        rr = (r + 1)*((r + 1) + 1)/2;
 
2834
        ss = r*(r + 1)/2;
 
2835
        tt = (r - 1)*((r - 1) + 1)/2;
 
2836
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
2837
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
2838
      }// end loop over 'r'
 
2839
      for (unsigned int r = 0; r < 2; r++)
 
2840
      {
 
2841
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
2842
        ss = r*(r + 1)/2;
 
2843
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
2844
      }// end loop over 'r'
 
2845
      for (unsigned int r = 0; r < 1; r++)
 
2846
      {
 
2847
        for (unsigned int s = 1; s < 2 - r; s++)
 
2848
        {
 
2849
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
2850
          ss = (r + s)*(r + s + 1)/2 + s;
 
2851
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
2852
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2853
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2854
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2855
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
2856
        }// end loop over 's'
 
2857
      }// end loop over 'r'
 
2858
      for (unsigned int r = 0; r < 3; r++)
 
2859
      {
 
2860
        for (unsigned int s = 0; s < 3 - r; s++)
 
2861
        {
 
2862
          rr = (r + s)*(r + s + 1)/2 + s;
 
2863
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
2864
        }// end loop over 's'
 
2865
      }// end loop over 'r'
 
2866
      
 
2867
      // Table(s) of coefficients.
 
2868
      static const double coefficients0[6] = \
 
2869
      {0.471404520791032, -0.230940107675850, 0.133333333333333, 0.000000000000000, -0.188561808316413, -0.163299316185545};
 
2870
      
 
2871
      // Compute value(s).
 
2872
      for (unsigned int r = 0; r < 6; r++)
 
2873
      {
 
2874
        *values += coefficients0[r]*basisvalues[r];
 
2875
      }// end loop over 'r'
 
2876
        break;
 
2877
      }
 
2878
    case 5:
 
2879
      {
 
2880
        
 
2881
      // Array of basisvalues.
 
2882
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
2883
      
 
2884
      // Declare helper variables.
 
2885
      unsigned int rr = 0;
 
2886
      unsigned int ss = 0;
 
2887
      unsigned int tt = 0;
 
2888
      double tmp5 = 0.000000000000000;
 
2889
      double tmp6 = 0.000000000000000;
 
2890
      double tmp7 = 0.000000000000000;
 
2891
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
2892
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
2893
      double tmp2 = tmp1*tmp1;
 
2894
      
 
2895
      // Compute basisvalues.
 
2896
      basisvalues[0] = 1.000000000000000;
 
2897
      basisvalues[1] = tmp0;
 
2898
      for (unsigned int r = 1; r < 2; r++)
 
2899
      {
 
2900
        rr = (r + 1)*((r + 1) + 1)/2;
 
2901
        ss = r*(r + 1)/2;
 
2902
        tt = (r - 1)*((r - 1) + 1)/2;
 
2903
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
2904
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
2905
      }// end loop over 'r'
 
2906
      for (unsigned int r = 0; r < 2; r++)
 
2907
      {
 
2908
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
2909
        ss = r*(r + 1)/2;
 
2910
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
2911
      }// end loop over 'r'
 
2912
      for (unsigned int r = 0; r < 1; r++)
 
2913
      {
 
2914
        for (unsigned int s = 1; s < 2 - r; s++)
 
2915
        {
 
2916
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
2917
          ss = (r + s)*(r + s + 1)/2 + s;
 
2918
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
2919
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2920
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2921
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
2922
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
2923
        }// end loop over 's'
 
2924
      }// end loop over 'r'
 
2925
      for (unsigned int r = 0; r < 3; r++)
 
2926
      {
 
2927
        for (unsigned int s = 0; s < 3 - r; s++)
 
2928
        {
 
2929
          rr = (r + s)*(r + s + 1)/2 + s;
 
2930
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
2931
        }// end loop over 's'
 
2932
      }// end loop over 'r'
 
2933
      
 
2934
      // Table(s) of coefficients.
 
2935
      static const double coefficients0[6] = \
 
2936
      {0.471404520791032, 0.000000000000000, -0.266666666666667, -0.243432247780074, 0.000000000000000, 0.054433105395182};
 
2937
      
 
2938
      // Compute value(s).
 
2939
      for (unsigned int r = 0; r < 6; r++)
 
2940
      {
 
2941
        *values += coefficients0[r]*basisvalues[r];
 
2942
      }// end loop over 'r'
 
2943
        break;
 
2944
      }
 
2945
    }
 
2946
    
 
2947
  }
 
2948
 
 
2949
  /// Evaluate all basis functions at given point in cell
 
2950
  virtual void evaluate_basis_all(double* values,
 
2951
                                  const double* coordinates,
 
2952
                                  const ufc::cell& c) const
 
2953
  {
 
2954
    // Helper variable to hold values of a single dof.
 
2955
    double dof_values = 0.000000000000000;
 
2956
    
 
2957
    // Loop dofs and call evaluate_basis.
 
2958
    for (unsigned int r = 0; r < 6; r++)
 
2959
    {
 
2960
      evaluate_basis(r, &dof_values, coordinates, c);
 
2961
      values[r] = dof_values;
 
2962
    }// end loop over 'r'
 
2963
  }
 
2964
 
 
2965
  /// Evaluate order n derivatives of basis function i at given point in cell
 
2966
  virtual void evaluate_basis_derivatives(unsigned int i,
 
2967
                                          unsigned int n,
 
2968
                                          double* values,
 
2969
                                          const double* coordinates,
 
2970
                                          const ufc::cell& c) const
 
2971
  {
 
2972
    // Extract vertex coordinates
 
2973
    const double * const * x = c.coordinates;
 
2974
    
 
2975
    // Compute Jacobian of affine map from reference cell
 
2976
    const double J_00 = x[1][0] - x[0][0];
 
2977
    const double J_01 = x[2][0] - x[0][0];
 
2978
    const double J_10 = x[1][1] - x[0][1];
 
2979
    const double J_11 = x[2][1] - x[0][1];
 
2980
    
 
2981
    // Compute determinant of Jacobian
 
2982
    double detJ = J_00*J_11 - J_01*J_10;
 
2983
    
 
2984
    // Compute inverse of Jacobian
 
2985
    const double K_00 =  J_11 / detJ;
 
2986
    const double K_01 = -J_01 / detJ;
 
2987
    const double K_10 = -J_10 / detJ;
 
2988
    const double K_11 =  J_00 / detJ;
 
2989
    
 
2990
    // Compute constants
 
2991
    const double C0 = x[1][0] + x[2][0];
 
2992
    const double C1 = x[1][1] + x[2][1];
 
2993
    
 
2994
    // Get coordinates and map to the reference (FIAT) element
 
2995
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
2996
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
2997
    
 
2998
    // Compute number of derivatives.
 
2999
    unsigned int num_derivatives = 1;
 
3000
    for (unsigned int r = 0; r < n; r++)
 
3001
    {
 
3002
      num_derivatives *= 2;
 
3003
    }// end loop over 'r'
 
3004
    
 
3005
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
3006
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
3007
    for (unsigned int row = 0; row < num_derivatives; row++)
 
3008
    {
 
3009
      combinations[row] = new unsigned int [n];
 
3010
      for (unsigned int col = 0; col < n; col++)
 
3011
        combinations[row][col] = 0;
 
3012
    }
 
3013
    
 
3014
    // Generate combinations of derivatives
 
3015
    for (unsigned int row = 1; row < num_derivatives; row++)
 
3016
    {
 
3017
      for (unsigned int num = 0; num < row; num++)
 
3018
      {
 
3019
        for (unsigned int col = n-1; col+1 > 0; col--)
 
3020
        {
 
3021
          if (combinations[row][col] + 1 > 1)
 
3022
            combinations[row][col] = 0;
 
3023
          else
 
3024
          {
 
3025
            combinations[row][col] += 1;
 
3026
            break;
 
3027
          }
 
3028
        }
 
3029
      }
 
3030
    }
 
3031
    
 
3032
    // Compute inverse of Jacobian
 
3033
    const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
 
3034
    
 
3035
    // Declare transformation matrix
 
3036
    // Declare pointer to two dimensional array and initialise
 
3037
    double **transform = new double *[num_derivatives];
 
3038
    
 
3039
    for (unsigned int j = 0; j < num_derivatives; j++)
 
3040
    {
 
3041
      transform[j] = new double [num_derivatives];
 
3042
      for (unsigned int k = 0; k < num_derivatives; k++)
 
3043
        transform[j][k] = 1;
 
3044
    }
 
3045
    
 
3046
    // Construct transformation matrix
 
3047
    for (unsigned int row = 0; row < num_derivatives; row++)
 
3048
    {
 
3049
      for (unsigned int col = 0; col < num_derivatives; col++)
 
3050
      {
 
3051
        for (unsigned int k = 0; k < n; k++)
 
3052
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
3053
      }
 
3054
    }
 
3055
    
 
3056
    // Reset values. Assuming that values is always an array.
 
3057
    for (unsigned int r = 0; r < num_derivatives; r++)
 
3058
    {
 
3059
      values[r] = 0.000000000000000;
 
3060
    }// end loop over 'r'
 
3061
    
 
3062
    switch (i)
 
3063
    {
 
3064
    case 0:
 
3065
      {
 
3066
        
 
3067
      // Array of basisvalues.
 
3068
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
3069
      
 
3070
      // Declare helper variables.
 
3071
      unsigned int rr = 0;
 
3072
      unsigned int ss = 0;
 
3073
      unsigned int tt = 0;
 
3074
      double tmp5 = 0.000000000000000;
 
3075
      double tmp6 = 0.000000000000000;
 
3076
      double tmp7 = 0.000000000000000;
 
3077
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
3078
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
3079
      double tmp2 = tmp1*tmp1;
 
3080
      
 
3081
      // Compute basisvalues.
 
3082
      basisvalues[0] = 1.000000000000000;
 
3083
      basisvalues[1] = tmp0;
 
3084
      for (unsigned int r = 1; r < 2; r++)
 
3085
      {
 
3086
        rr = (r + 1)*((r + 1) + 1)/2;
 
3087
        ss = r*(r + 1)/2;
 
3088
        tt = (r - 1)*((r - 1) + 1)/2;
 
3089
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
3090
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
3091
      }// end loop over 'r'
 
3092
      for (unsigned int r = 0; r < 2; r++)
 
3093
      {
 
3094
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
3095
        ss = r*(r + 1)/2;
 
3096
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
3097
      }// end loop over 'r'
 
3098
      for (unsigned int r = 0; r < 1; r++)
 
3099
      {
 
3100
        for (unsigned int s = 1; s < 2 - r; s++)
 
3101
        {
 
3102
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
3103
          ss = (r + s)*(r + s + 1)/2 + s;
 
3104
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
3105
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3106
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3107
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3108
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
3109
        }// end loop over 's'
 
3110
      }// end loop over 'r'
 
3111
      for (unsigned int r = 0; r < 3; r++)
 
3112
      {
 
3113
        for (unsigned int s = 0; s < 3 - r; s++)
 
3114
        {
 
3115
          rr = (r + s)*(r + s + 1)/2 + s;
 
3116
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
3117
        }// end loop over 's'
 
3118
      }// end loop over 'r'
 
3119
      
 
3120
      // Table(s) of coefficients.
 
3121
      static const double coefficients0[6] = \
 
3122
      {0.000000000000000, -0.173205080756888, -0.100000000000000, 0.121716123890037, 0.094280904158206, 0.054433105395182};
 
3123
      
 
3124
      // Tables of derivatives of the polynomial base (transpose).
 
3125
      static const double dmats0[6][6] = \
 
3126
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3127
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3128
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3129
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3130
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3131
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3132
      
 
3133
      static const double dmats1[6][6] = \
 
3134
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3135
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3136
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3137
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3138
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3139
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3140
      
 
3141
      // Compute reference derivatives.
 
3142
      // Declare pointer to array of derivatives on FIAT element.
 
3143
      double *derivatives = new double[num_derivatives];
 
3144
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3145
      {
 
3146
        derivatives[r] = 0.000000000000000;
 
3147
      }// end loop over 'r'
 
3148
      
 
3149
      // Declare derivative matrix (of polynomial basis).
 
3150
      double dmats[6][6] = \
 
3151
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3152
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3153
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3154
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3155
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3156
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3157
      
 
3158
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
3159
      double dmats_old[6][6] = \
 
3160
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3161
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3162
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3163
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3164
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3165
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3166
      
 
3167
      // Loop possible derivatives.
 
3168
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3169
      {
 
3170
        // Resetting dmats values to compute next derivative.
 
3171
        for (unsigned int t = 0; t < 6; t++)
 
3172
        {
 
3173
          for (unsigned int u = 0; u < 6; u++)
 
3174
          {
 
3175
            dmats[t][u] = 0.000000000000000;
 
3176
            if (t == u)
 
3177
            {
 
3178
            dmats[t][u] = 1.000000000000000;
 
3179
            }
 
3180
            
 
3181
          }// end loop over 'u'
 
3182
        }// end loop over 't'
 
3183
        
 
3184
        // Looping derivative order to generate dmats.
 
3185
        for (unsigned int s = 0; s < n; s++)
 
3186
        {
 
3187
          // Updating dmats_old with new values and resetting dmats.
 
3188
          for (unsigned int t = 0; t < 6; t++)
 
3189
          {
 
3190
            for (unsigned int u = 0; u < 6; u++)
 
3191
            {
 
3192
              dmats_old[t][u] = dmats[t][u];
 
3193
              dmats[t][u] = 0.000000000000000;
 
3194
            }// end loop over 'u'
 
3195
          }// end loop over 't'
 
3196
          
 
3197
          // Update dmats using an inner product.
 
3198
          if (combinations[r][s] == 0)
 
3199
          {
 
3200
          for (unsigned int t = 0; t < 6; t++)
 
3201
          {
 
3202
            for (unsigned int u = 0; u < 6; u++)
 
3203
            {
 
3204
              for (unsigned int tu = 0; tu < 6; tu++)
 
3205
              {
 
3206
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
3207
              }// end loop over 'tu'
 
3208
            }// end loop over 'u'
 
3209
          }// end loop over 't'
 
3210
          }
 
3211
          
 
3212
          if (combinations[r][s] == 1)
 
3213
          {
 
3214
          for (unsigned int t = 0; t < 6; t++)
 
3215
          {
 
3216
            for (unsigned int u = 0; u < 6; u++)
 
3217
            {
 
3218
              for (unsigned int tu = 0; tu < 6; tu++)
 
3219
              {
 
3220
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
3221
              }// end loop over 'tu'
 
3222
            }// end loop over 'u'
 
3223
          }// end loop over 't'
 
3224
          }
 
3225
          
 
3226
        }// end loop over 's'
 
3227
        for (unsigned int s = 0; s < 6; s++)
 
3228
        {
 
3229
          for (unsigned int t = 0; t < 6; t++)
 
3230
          {
 
3231
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
3232
          }// end loop over 't'
 
3233
        }// end loop over 's'
 
3234
      }// end loop over 'r'
 
3235
      
 
3236
      // Transform derivatives back to physical element
 
3237
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3238
      {
 
3239
        for (unsigned int s = 0; s < num_derivatives; s++)
 
3240
        {
 
3241
          values[r] += transform[r][s]*derivatives[s];
 
3242
        }// end loop over 's'
 
3243
      }// end loop over 'r'
 
3244
      
 
3245
      // Delete pointer to array of derivatives on FIAT element
 
3246
      delete [] derivatives;
 
3247
      
 
3248
      // Delete pointer to array of combinations of derivatives and transform
 
3249
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3250
      {
 
3251
        delete [] combinations[r];
 
3252
      }// end loop over 'r'
 
3253
      delete [] combinations;
 
3254
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3255
      {
 
3256
        delete [] transform[r];
 
3257
      }// end loop over 'r'
 
3258
      delete [] transform;
 
3259
        break;
 
3260
      }
 
3261
    case 1:
 
3262
      {
 
3263
        
 
3264
      // Array of basisvalues.
 
3265
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
3266
      
 
3267
      // Declare helper variables.
 
3268
      unsigned int rr = 0;
 
3269
      unsigned int ss = 0;
 
3270
      unsigned int tt = 0;
 
3271
      double tmp5 = 0.000000000000000;
 
3272
      double tmp6 = 0.000000000000000;
 
3273
      double tmp7 = 0.000000000000000;
 
3274
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
3275
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
3276
      double tmp2 = tmp1*tmp1;
 
3277
      
 
3278
      // Compute basisvalues.
 
3279
      basisvalues[0] = 1.000000000000000;
 
3280
      basisvalues[1] = tmp0;
 
3281
      for (unsigned int r = 1; r < 2; r++)
 
3282
      {
 
3283
        rr = (r + 1)*((r + 1) + 1)/2;
 
3284
        ss = r*(r + 1)/2;
 
3285
        tt = (r - 1)*((r - 1) + 1)/2;
 
3286
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
3287
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
3288
      }// end loop over 'r'
 
3289
      for (unsigned int r = 0; r < 2; r++)
 
3290
      {
 
3291
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
3292
        ss = r*(r + 1)/2;
 
3293
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
3294
      }// end loop over 'r'
 
3295
      for (unsigned int r = 0; r < 1; r++)
 
3296
      {
 
3297
        for (unsigned int s = 1; s < 2 - r; s++)
 
3298
        {
 
3299
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
3300
          ss = (r + s)*(r + s + 1)/2 + s;
 
3301
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
3302
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3303
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3304
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3305
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
3306
        }// end loop over 's'
 
3307
      }// end loop over 'r'
 
3308
      for (unsigned int r = 0; r < 3; r++)
 
3309
      {
 
3310
        for (unsigned int s = 0; s < 3 - r; s++)
 
3311
        {
 
3312
          rr = (r + s)*(r + s + 1)/2 + s;
 
3313
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
3314
        }// end loop over 's'
 
3315
      }// end loop over 'r'
 
3316
      
 
3317
      // Table(s) of coefficients.
 
3318
      static const double coefficients0[6] = \
 
3319
      {0.000000000000000, 0.173205080756888, -0.100000000000000, 0.121716123890037, -0.094280904158206, 0.054433105395182};
 
3320
      
 
3321
      // Tables of derivatives of the polynomial base (transpose).
 
3322
      static const double dmats0[6][6] = \
 
3323
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3324
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3325
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3326
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3327
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3328
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3329
      
 
3330
      static const double dmats1[6][6] = \
 
3331
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3332
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3333
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3334
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3335
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3336
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3337
      
 
3338
      // Compute reference derivatives.
 
3339
      // Declare pointer to array of derivatives on FIAT element.
 
3340
      double *derivatives = new double[num_derivatives];
 
3341
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3342
      {
 
3343
        derivatives[r] = 0.000000000000000;
 
3344
      }// end loop over 'r'
 
3345
      
 
3346
      // Declare derivative matrix (of polynomial basis).
 
3347
      double dmats[6][6] = \
 
3348
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3349
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3350
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3351
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3352
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3353
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3354
      
 
3355
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
3356
      double dmats_old[6][6] = \
 
3357
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3358
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3359
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3360
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3361
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3362
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3363
      
 
3364
      // Loop possible derivatives.
 
3365
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3366
      {
 
3367
        // Resetting dmats values to compute next derivative.
 
3368
        for (unsigned int t = 0; t < 6; t++)
 
3369
        {
 
3370
          for (unsigned int u = 0; u < 6; u++)
 
3371
          {
 
3372
            dmats[t][u] = 0.000000000000000;
 
3373
            if (t == u)
 
3374
            {
 
3375
            dmats[t][u] = 1.000000000000000;
 
3376
            }
 
3377
            
 
3378
          }// end loop over 'u'
 
3379
        }// end loop over 't'
 
3380
        
 
3381
        // Looping derivative order to generate dmats.
 
3382
        for (unsigned int s = 0; s < n; s++)
 
3383
        {
 
3384
          // Updating dmats_old with new values and resetting dmats.
 
3385
          for (unsigned int t = 0; t < 6; t++)
 
3386
          {
 
3387
            for (unsigned int u = 0; u < 6; u++)
 
3388
            {
 
3389
              dmats_old[t][u] = dmats[t][u];
 
3390
              dmats[t][u] = 0.000000000000000;
 
3391
            }// end loop over 'u'
 
3392
          }// end loop over 't'
 
3393
          
 
3394
          // Update dmats using an inner product.
 
3395
          if (combinations[r][s] == 0)
 
3396
          {
 
3397
          for (unsigned int t = 0; t < 6; t++)
 
3398
          {
 
3399
            for (unsigned int u = 0; u < 6; u++)
 
3400
            {
 
3401
              for (unsigned int tu = 0; tu < 6; tu++)
 
3402
              {
 
3403
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
3404
              }// end loop over 'tu'
 
3405
            }// end loop over 'u'
 
3406
          }// end loop over 't'
 
3407
          }
 
3408
          
 
3409
          if (combinations[r][s] == 1)
 
3410
          {
 
3411
          for (unsigned int t = 0; t < 6; t++)
 
3412
          {
 
3413
            for (unsigned int u = 0; u < 6; u++)
 
3414
            {
 
3415
              for (unsigned int tu = 0; tu < 6; tu++)
 
3416
              {
 
3417
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
3418
              }// end loop over 'tu'
 
3419
            }// end loop over 'u'
 
3420
          }// end loop over 't'
 
3421
          }
 
3422
          
 
3423
        }// end loop over 's'
 
3424
        for (unsigned int s = 0; s < 6; s++)
 
3425
        {
 
3426
          for (unsigned int t = 0; t < 6; t++)
 
3427
          {
 
3428
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
3429
          }// end loop over 't'
 
3430
        }// end loop over 's'
 
3431
      }// end loop over 'r'
 
3432
      
 
3433
      // Transform derivatives back to physical element
 
3434
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3435
      {
 
3436
        for (unsigned int s = 0; s < num_derivatives; s++)
 
3437
        {
 
3438
          values[r] += transform[r][s]*derivatives[s];
 
3439
        }// end loop over 's'
 
3440
      }// end loop over 'r'
 
3441
      
 
3442
      // Delete pointer to array of derivatives on FIAT element
 
3443
      delete [] derivatives;
 
3444
      
 
3445
      // Delete pointer to array of combinations of derivatives and transform
 
3446
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3447
      {
 
3448
        delete [] combinations[r];
 
3449
      }// end loop over 'r'
 
3450
      delete [] combinations;
 
3451
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3452
      {
 
3453
        delete [] transform[r];
 
3454
      }// end loop over 'r'
 
3455
      delete [] transform;
 
3456
        break;
 
3457
      }
 
3458
    case 2:
 
3459
      {
 
3460
        
 
3461
      // Array of basisvalues.
 
3462
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
3463
      
 
3464
      // Declare helper variables.
 
3465
      unsigned int rr = 0;
 
3466
      unsigned int ss = 0;
 
3467
      unsigned int tt = 0;
 
3468
      double tmp5 = 0.000000000000000;
 
3469
      double tmp6 = 0.000000000000000;
 
3470
      double tmp7 = 0.000000000000000;
 
3471
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
3472
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
3473
      double tmp2 = tmp1*tmp1;
 
3474
      
 
3475
      // Compute basisvalues.
 
3476
      basisvalues[0] = 1.000000000000000;
 
3477
      basisvalues[1] = tmp0;
 
3478
      for (unsigned int r = 1; r < 2; r++)
 
3479
      {
 
3480
        rr = (r + 1)*((r + 1) + 1)/2;
 
3481
        ss = r*(r + 1)/2;
 
3482
        tt = (r - 1)*((r - 1) + 1)/2;
 
3483
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
3484
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
3485
      }// end loop over 'r'
 
3486
      for (unsigned int r = 0; r < 2; r++)
 
3487
      {
 
3488
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
3489
        ss = r*(r + 1)/2;
 
3490
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
3491
      }// end loop over 'r'
 
3492
      for (unsigned int r = 0; r < 1; r++)
 
3493
      {
 
3494
        for (unsigned int s = 1; s < 2 - r; s++)
 
3495
        {
 
3496
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
3497
          ss = (r + s)*(r + s + 1)/2 + s;
 
3498
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
3499
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3500
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3501
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3502
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
3503
        }// end loop over 's'
 
3504
      }// end loop over 'r'
 
3505
      for (unsigned int r = 0; r < 3; r++)
 
3506
      {
 
3507
        for (unsigned int s = 0; s < 3 - r; s++)
 
3508
        {
 
3509
          rr = (r + s)*(r + s + 1)/2 + s;
 
3510
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
3511
        }// end loop over 's'
 
3512
      }// end loop over 'r'
 
3513
      
 
3514
      // Table(s) of coefficients.
 
3515
      static const double coefficients0[6] = \
 
3516
      {0.000000000000000, 0.000000000000000, 0.200000000000000, 0.000000000000000, 0.000000000000000, 0.163299316185545};
 
3517
      
 
3518
      // Tables of derivatives of the polynomial base (transpose).
 
3519
      static const double dmats0[6][6] = \
 
3520
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3521
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3522
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3523
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3524
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3525
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3526
      
 
3527
      static const double dmats1[6][6] = \
 
3528
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3529
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3530
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3531
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3532
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3533
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3534
      
 
3535
      // Compute reference derivatives.
 
3536
      // Declare pointer to array of derivatives on FIAT element.
 
3537
      double *derivatives = new double[num_derivatives];
 
3538
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3539
      {
 
3540
        derivatives[r] = 0.000000000000000;
 
3541
      }// end loop over 'r'
 
3542
      
 
3543
      // Declare derivative matrix (of polynomial basis).
 
3544
      double dmats[6][6] = \
 
3545
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3546
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3547
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3548
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3549
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3550
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3551
      
 
3552
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
3553
      double dmats_old[6][6] = \
 
3554
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3555
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3556
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3557
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3558
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3559
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3560
      
 
3561
      // Loop possible derivatives.
 
3562
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3563
      {
 
3564
        // Resetting dmats values to compute next derivative.
 
3565
        for (unsigned int t = 0; t < 6; t++)
 
3566
        {
 
3567
          for (unsigned int u = 0; u < 6; u++)
 
3568
          {
 
3569
            dmats[t][u] = 0.000000000000000;
 
3570
            if (t == u)
 
3571
            {
 
3572
            dmats[t][u] = 1.000000000000000;
 
3573
            }
 
3574
            
 
3575
          }// end loop over 'u'
 
3576
        }// end loop over 't'
 
3577
        
 
3578
        // Looping derivative order to generate dmats.
 
3579
        for (unsigned int s = 0; s < n; s++)
 
3580
        {
 
3581
          // Updating dmats_old with new values and resetting dmats.
 
3582
          for (unsigned int t = 0; t < 6; t++)
 
3583
          {
 
3584
            for (unsigned int u = 0; u < 6; u++)
 
3585
            {
 
3586
              dmats_old[t][u] = dmats[t][u];
 
3587
              dmats[t][u] = 0.000000000000000;
 
3588
            }// end loop over 'u'
 
3589
          }// end loop over 't'
 
3590
          
 
3591
          // Update dmats using an inner product.
 
3592
          if (combinations[r][s] == 0)
 
3593
          {
 
3594
          for (unsigned int t = 0; t < 6; t++)
 
3595
          {
 
3596
            for (unsigned int u = 0; u < 6; u++)
 
3597
            {
 
3598
              for (unsigned int tu = 0; tu < 6; tu++)
 
3599
              {
 
3600
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
3601
              }// end loop over 'tu'
 
3602
            }// end loop over 'u'
 
3603
          }// end loop over 't'
 
3604
          }
 
3605
          
 
3606
          if (combinations[r][s] == 1)
 
3607
          {
 
3608
          for (unsigned int t = 0; t < 6; t++)
 
3609
          {
 
3610
            for (unsigned int u = 0; u < 6; u++)
 
3611
            {
 
3612
              for (unsigned int tu = 0; tu < 6; tu++)
 
3613
              {
 
3614
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
3615
              }// end loop over 'tu'
 
3616
            }// end loop over 'u'
 
3617
          }// end loop over 't'
 
3618
          }
 
3619
          
 
3620
        }// end loop over 's'
 
3621
        for (unsigned int s = 0; s < 6; s++)
 
3622
        {
 
3623
          for (unsigned int t = 0; t < 6; t++)
 
3624
          {
 
3625
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
3626
          }// end loop over 't'
 
3627
        }// end loop over 's'
 
3628
      }// end loop over 'r'
 
3629
      
 
3630
      // Transform derivatives back to physical element
 
3631
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3632
      {
 
3633
        for (unsigned int s = 0; s < num_derivatives; s++)
 
3634
        {
 
3635
          values[r] += transform[r][s]*derivatives[s];
 
3636
        }// end loop over 's'
 
3637
      }// end loop over 'r'
 
3638
      
 
3639
      // Delete pointer to array of derivatives on FIAT element
 
3640
      delete [] derivatives;
 
3641
      
 
3642
      // Delete pointer to array of combinations of derivatives and transform
 
3643
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3644
      {
 
3645
        delete [] combinations[r];
 
3646
      }// end loop over 'r'
 
3647
      delete [] combinations;
 
3648
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3649
      {
 
3650
        delete [] transform[r];
 
3651
      }// end loop over 'r'
 
3652
      delete [] transform;
 
3653
        break;
 
3654
      }
 
3655
    case 3:
 
3656
      {
 
3657
        
 
3658
      // Array of basisvalues.
 
3659
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
3660
      
 
3661
      // Declare helper variables.
 
3662
      unsigned int rr = 0;
 
3663
      unsigned int ss = 0;
 
3664
      unsigned int tt = 0;
 
3665
      double tmp5 = 0.000000000000000;
 
3666
      double tmp6 = 0.000000000000000;
 
3667
      double tmp7 = 0.000000000000000;
 
3668
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
3669
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
3670
      double tmp2 = tmp1*tmp1;
 
3671
      
 
3672
      // Compute basisvalues.
 
3673
      basisvalues[0] = 1.000000000000000;
 
3674
      basisvalues[1] = tmp0;
 
3675
      for (unsigned int r = 1; r < 2; r++)
 
3676
      {
 
3677
        rr = (r + 1)*((r + 1) + 1)/2;
 
3678
        ss = r*(r + 1)/2;
 
3679
        tt = (r - 1)*((r - 1) + 1)/2;
 
3680
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
3681
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
3682
      }// end loop over 'r'
 
3683
      for (unsigned int r = 0; r < 2; r++)
 
3684
      {
 
3685
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
3686
        ss = r*(r + 1)/2;
 
3687
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
3688
      }// end loop over 'r'
 
3689
      for (unsigned int r = 0; r < 1; r++)
 
3690
      {
 
3691
        for (unsigned int s = 1; s < 2 - r; s++)
 
3692
        {
 
3693
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
3694
          ss = (r + s)*(r + s + 1)/2 + s;
 
3695
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
3696
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3697
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3698
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3699
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
3700
        }// end loop over 's'
 
3701
      }// end loop over 'r'
 
3702
      for (unsigned int r = 0; r < 3; r++)
 
3703
      {
 
3704
        for (unsigned int s = 0; s < 3 - r; s++)
 
3705
        {
 
3706
          rr = (r + s)*(r + s + 1)/2 + s;
 
3707
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
3708
        }// end loop over 's'
 
3709
      }// end loop over 'r'
 
3710
      
 
3711
      // Table(s) of coefficients.
 
3712
      static const double coefficients0[6] = \
 
3713
      {0.471404520791032, 0.230940107675850, 0.133333333333333, 0.000000000000000, 0.188561808316413, -0.163299316185545};
 
3714
      
 
3715
      // Tables of derivatives of the polynomial base (transpose).
 
3716
      static const double dmats0[6][6] = \
 
3717
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3718
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3719
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3720
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3721
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3722
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3723
      
 
3724
      static const double dmats1[6][6] = \
 
3725
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3726
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3727
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3728
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3729
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3730
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3731
      
 
3732
      // Compute reference derivatives.
 
3733
      // Declare pointer to array of derivatives on FIAT element.
 
3734
      double *derivatives = new double[num_derivatives];
 
3735
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3736
      {
 
3737
        derivatives[r] = 0.000000000000000;
 
3738
      }// end loop over 'r'
 
3739
      
 
3740
      // Declare derivative matrix (of polynomial basis).
 
3741
      double dmats[6][6] = \
 
3742
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3743
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3744
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3745
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3746
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3747
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3748
      
 
3749
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
3750
      double dmats_old[6][6] = \
 
3751
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3752
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3753
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3754
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3755
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3756
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3757
      
 
3758
      // Loop possible derivatives.
 
3759
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3760
      {
 
3761
        // Resetting dmats values to compute next derivative.
 
3762
        for (unsigned int t = 0; t < 6; t++)
 
3763
        {
 
3764
          for (unsigned int u = 0; u < 6; u++)
 
3765
          {
 
3766
            dmats[t][u] = 0.000000000000000;
 
3767
            if (t == u)
 
3768
            {
 
3769
            dmats[t][u] = 1.000000000000000;
 
3770
            }
 
3771
            
 
3772
          }// end loop over 'u'
 
3773
        }// end loop over 't'
 
3774
        
 
3775
        // Looping derivative order to generate dmats.
 
3776
        for (unsigned int s = 0; s < n; s++)
 
3777
        {
 
3778
          // Updating dmats_old with new values and resetting dmats.
 
3779
          for (unsigned int t = 0; t < 6; t++)
 
3780
          {
 
3781
            for (unsigned int u = 0; u < 6; u++)
 
3782
            {
 
3783
              dmats_old[t][u] = dmats[t][u];
 
3784
              dmats[t][u] = 0.000000000000000;
 
3785
            }// end loop over 'u'
 
3786
          }// end loop over 't'
 
3787
          
 
3788
          // Update dmats using an inner product.
 
3789
          if (combinations[r][s] == 0)
 
3790
          {
 
3791
          for (unsigned int t = 0; t < 6; t++)
 
3792
          {
 
3793
            for (unsigned int u = 0; u < 6; u++)
 
3794
            {
 
3795
              for (unsigned int tu = 0; tu < 6; tu++)
 
3796
              {
 
3797
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
3798
              }// end loop over 'tu'
 
3799
            }// end loop over 'u'
 
3800
          }// end loop over 't'
 
3801
          }
 
3802
          
 
3803
          if (combinations[r][s] == 1)
 
3804
          {
 
3805
          for (unsigned int t = 0; t < 6; t++)
 
3806
          {
 
3807
            for (unsigned int u = 0; u < 6; u++)
 
3808
            {
 
3809
              for (unsigned int tu = 0; tu < 6; tu++)
 
3810
              {
 
3811
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
3812
              }// end loop over 'tu'
 
3813
            }// end loop over 'u'
 
3814
          }// end loop over 't'
 
3815
          }
 
3816
          
 
3817
        }// end loop over 's'
 
3818
        for (unsigned int s = 0; s < 6; s++)
 
3819
        {
 
3820
          for (unsigned int t = 0; t < 6; t++)
 
3821
          {
 
3822
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
3823
          }// end loop over 't'
 
3824
        }// end loop over 's'
 
3825
      }// end loop over 'r'
 
3826
      
 
3827
      // Transform derivatives back to physical element
 
3828
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3829
      {
 
3830
        for (unsigned int s = 0; s < num_derivatives; s++)
 
3831
        {
 
3832
          values[r] += transform[r][s]*derivatives[s];
 
3833
        }// end loop over 's'
 
3834
      }// end loop over 'r'
 
3835
      
 
3836
      // Delete pointer to array of derivatives on FIAT element
 
3837
      delete [] derivatives;
 
3838
      
 
3839
      // Delete pointer to array of combinations of derivatives and transform
 
3840
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3841
      {
 
3842
        delete [] combinations[r];
 
3843
      }// end loop over 'r'
 
3844
      delete [] combinations;
 
3845
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3846
      {
 
3847
        delete [] transform[r];
 
3848
      }// end loop over 'r'
 
3849
      delete [] transform;
 
3850
        break;
 
3851
      }
 
3852
    case 4:
 
3853
      {
 
3854
        
 
3855
      // Array of basisvalues.
 
3856
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
3857
      
 
3858
      // Declare helper variables.
 
3859
      unsigned int rr = 0;
 
3860
      unsigned int ss = 0;
 
3861
      unsigned int tt = 0;
 
3862
      double tmp5 = 0.000000000000000;
 
3863
      double tmp6 = 0.000000000000000;
 
3864
      double tmp7 = 0.000000000000000;
 
3865
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
3866
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
3867
      double tmp2 = tmp1*tmp1;
 
3868
      
 
3869
      // Compute basisvalues.
 
3870
      basisvalues[0] = 1.000000000000000;
 
3871
      basisvalues[1] = tmp0;
 
3872
      for (unsigned int r = 1; r < 2; r++)
 
3873
      {
 
3874
        rr = (r + 1)*((r + 1) + 1)/2;
 
3875
        ss = r*(r + 1)/2;
 
3876
        tt = (r - 1)*((r - 1) + 1)/2;
 
3877
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
3878
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
3879
      }// end loop over 'r'
 
3880
      for (unsigned int r = 0; r < 2; r++)
 
3881
      {
 
3882
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
3883
        ss = r*(r + 1)/2;
 
3884
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
3885
      }// end loop over 'r'
 
3886
      for (unsigned int r = 0; r < 1; r++)
 
3887
      {
 
3888
        for (unsigned int s = 1; s < 2 - r; s++)
 
3889
        {
 
3890
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
3891
          ss = (r + s)*(r + s + 1)/2 + s;
 
3892
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
3893
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3894
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3895
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
3896
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
3897
        }// end loop over 's'
 
3898
      }// end loop over 'r'
 
3899
      for (unsigned int r = 0; r < 3; r++)
 
3900
      {
 
3901
        for (unsigned int s = 0; s < 3 - r; s++)
 
3902
        {
 
3903
          rr = (r + s)*(r + s + 1)/2 + s;
 
3904
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
3905
        }// end loop over 's'
 
3906
      }// end loop over 'r'
 
3907
      
 
3908
      // Table(s) of coefficients.
 
3909
      static const double coefficients0[6] = \
 
3910
      {0.471404520791032, -0.230940107675850, 0.133333333333333, 0.000000000000000, -0.188561808316413, -0.163299316185545};
 
3911
      
 
3912
      // Tables of derivatives of the polynomial base (transpose).
 
3913
      static const double dmats0[6][6] = \
 
3914
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3915
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3916
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3917
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3918
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3919
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3920
      
 
3921
      static const double dmats1[6][6] = \
 
3922
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3923
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3924
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3925
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3926
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3927
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
3928
      
 
3929
      // Compute reference derivatives.
 
3930
      // Declare pointer to array of derivatives on FIAT element.
 
3931
      double *derivatives = new double[num_derivatives];
 
3932
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3933
      {
 
3934
        derivatives[r] = 0.000000000000000;
 
3935
      }// end loop over 'r'
 
3936
      
 
3937
      // Declare derivative matrix (of polynomial basis).
 
3938
      double dmats[6][6] = \
 
3939
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3940
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3941
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3942
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3943
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3944
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3945
      
 
3946
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
3947
      double dmats_old[6][6] = \
 
3948
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3949
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3950
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
3951
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
3952
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
3953
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
3954
      
 
3955
      // Loop possible derivatives.
 
3956
      for (unsigned int r = 0; r < num_derivatives; r++)
 
3957
      {
 
3958
        // Resetting dmats values to compute next derivative.
 
3959
        for (unsigned int t = 0; t < 6; t++)
 
3960
        {
 
3961
          for (unsigned int u = 0; u < 6; u++)
 
3962
          {
 
3963
            dmats[t][u] = 0.000000000000000;
 
3964
            if (t == u)
 
3965
            {
 
3966
            dmats[t][u] = 1.000000000000000;
 
3967
            }
 
3968
            
 
3969
          }// end loop over 'u'
 
3970
        }// end loop over 't'
 
3971
        
 
3972
        // Looping derivative order to generate dmats.
 
3973
        for (unsigned int s = 0; s < n; s++)
 
3974
        {
 
3975
          // Updating dmats_old with new values and resetting dmats.
 
3976
          for (unsigned int t = 0; t < 6; t++)
 
3977
          {
 
3978
            for (unsigned int u = 0; u < 6; u++)
 
3979
            {
 
3980
              dmats_old[t][u] = dmats[t][u];
 
3981
              dmats[t][u] = 0.000000000000000;
 
3982
            }// end loop over 'u'
 
3983
          }// end loop over 't'
 
3984
          
 
3985
          // Update dmats using an inner product.
 
3986
          if (combinations[r][s] == 0)
 
3987
          {
 
3988
          for (unsigned int t = 0; t < 6; t++)
 
3989
          {
 
3990
            for (unsigned int u = 0; u < 6; u++)
 
3991
            {
 
3992
              for (unsigned int tu = 0; tu < 6; tu++)
 
3993
              {
 
3994
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
3995
              }// end loop over 'tu'
 
3996
            }// end loop over 'u'
 
3997
          }// end loop over 't'
 
3998
          }
 
3999
          
 
4000
          if (combinations[r][s] == 1)
 
4001
          {
 
4002
          for (unsigned int t = 0; t < 6; t++)
 
4003
          {
 
4004
            for (unsigned int u = 0; u < 6; u++)
 
4005
            {
 
4006
              for (unsigned int tu = 0; tu < 6; tu++)
 
4007
              {
 
4008
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
4009
              }// end loop over 'tu'
 
4010
            }// end loop over 'u'
 
4011
          }// end loop over 't'
 
4012
          }
 
4013
          
 
4014
        }// end loop over 's'
 
4015
        for (unsigned int s = 0; s < 6; s++)
 
4016
        {
 
4017
          for (unsigned int t = 0; t < 6; t++)
 
4018
          {
 
4019
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
4020
          }// end loop over 't'
 
4021
        }// end loop over 's'
 
4022
      }// end loop over 'r'
 
4023
      
 
4024
      // Transform derivatives back to physical element
 
4025
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4026
      {
 
4027
        for (unsigned int s = 0; s < num_derivatives; s++)
 
4028
        {
 
4029
          values[r] += transform[r][s]*derivatives[s];
 
4030
        }// end loop over 's'
 
4031
      }// end loop over 'r'
 
4032
      
 
4033
      // Delete pointer to array of derivatives on FIAT element
 
4034
      delete [] derivatives;
 
4035
      
 
4036
      // Delete pointer to array of combinations of derivatives and transform
 
4037
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4038
      {
 
4039
        delete [] combinations[r];
 
4040
      }// end loop over 'r'
 
4041
      delete [] combinations;
 
4042
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4043
      {
 
4044
        delete [] transform[r];
 
4045
      }// end loop over 'r'
 
4046
      delete [] transform;
 
4047
        break;
 
4048
      }
 
4049
    case 5:
 
4050
      {
 
4051
        
 
4052
      // Array of basisvalues.
 
4053
      double basisvalues[6] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
4054
      
 
4055
      // Declare helper variables.
 
4056
      unsigned int rr = 0;
 
4057
      unsigned int ss = 0;
 
4058
      unsigned int tt = 0;
 
4059
      double tmp5 = 0.000000000000000;
 
4060
      double tmp6 = 0.000000000000000;
 
4061
      double tmp7 = 0.000000000000000;
 
4062
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
4063
      double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
4064
      double tmp2 = tmp1*tmp1;
 
4065
      
 
4066
      // Compute basisvalues.
 
4067
      basisvalues[0] = 1.000000000000000;
 
4068
      basisvalues[1] = tmp0;
 
4069
      for (unsigned int r = 1; r < 2; r++)
 
4070
      {
 
4071
        rr = (r + 1)*((r + 1) + 1)/2;
 
4072
        ss = r*(r + 1)/2;
 
4073
        tt = (r - 1)*((r - 1) + 1)/2;
 
4074
        tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
4075
        basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
4076
      }// end loop over 'r'
 
4077
      for (unsigned int r = 0; r < 2; r++)
 
4078
      {
 
4079
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
4080
        ss = r*(r + 1)/2;
 
4081
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
4082
      }// end loop over 'r'
 
4083
      for (unsigned int r = 0; r < 1; r++)
 
4084
      {
 
4085
        for (unsigned int s = 1; s < 2 - r; s++)
 
4086
        {
 
4087
          rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
4088
          ss = (r + s)*(r + s + 1)/2 + s;
 
4089
          tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
4090
          tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4091
          tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4092
          tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4093
          basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
4094
        }// end loop over 's'
 
4095
      }// end loop over 'r'
 
4096
      for (unsigned int r = 0; r < 3; r++)
 
4097
      {
 
4098
        for (unsigned int s = 0; s < 3 - r; s++)
 
4099
        {
 
4100
          rr = (r + s)*(r + s + 1)/2 + s;
 
4101
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
4102
        }// end loop over 's'
 
4103
      }// end loop over 'r'
 
4104
      
 
4105
      // Table(s) of coefficients.
 
4106
      static const double coefficients0[6] = \
 
4107
      {0.471404520791032, 0.000000000000000, -0.266666666666667, -0.243432247780074, 0.000000000000000, 0.054433105395182};
 
4108
      
 
4109
      // Tables of derivatives of the polynomial base (transpose).
 
4110
      static const double dmats0[6][6] = \
 
4111
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4112
      {4.898979485566355, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4113
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4114
      {0.000000000000000, 9.486832980505138, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4115
      {3.999999999999999, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4116
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
4117
      
 
4118
      static const double dmats1[6][6] = \
 
4119
      {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4120
      {2.449489742783177, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4121
      {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4122
      {2.581988897471611, 4.743416490252570, -0.912870929175278, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4123
      {1.999999999999999, 6.123724356957944, 3.535533905932737, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4124
      {-2.309401076758502, 0.000000000000000, 8.164965809277259, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
4125
      
 
4126
      // Compute reference derivatives.
 
4127
      // Declare pointer to array of derivatives on FIAT element.
 
4128
      double *derivatives = new double[num_derivatives];
 
4129
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4130
      {
 
4131
        derivatives[r] = 0.000000000000000;
 
4132
      }// end loop over 'r'
 
4133
      
 
4134
      // Declare derivative matrix (of polynomial basis).
 
4135
      double dmats[6][6] = \
 
4136
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4137
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4138
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4139
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
4140
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
4141
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
4142
      
 
4143
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
4144
      double dmats_old[6][6] = \
 
4145
      {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4146
      {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4147
      {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4148
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
4149
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
4150
      {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
4151
      
 
4152
      // Loop possible derivatives.
 
4153
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4154
      {
 
4155
        // Resetting dmats values to compute next derivative.
 
4156
        for (unsigned int t = 0; t < 6; t++)
 
4157
        {
 
4158
          for (unsigned int u = 0; u < 6; u++)
 
4159
          {
 
4160
            dmats[t][u] = 0.000000000000000;
 
4161
            if (t == u)
 
4162
            {
 
4163
            dmats[t][u] = 1.000000000000000;
 
4164
            }
 
4165
            
 
4166
          }// end loop over 'u'
 
4167
        }// end loop over 't'
 
4168
        
 
4169
        // Looping derivative order to generate dmats.
 
4170
        for (unsigned int s = 0; s < n; s++)
 
4171
        {
 
4172
          // Updating dmats_old with new values and resetting dmats.
 
4173
          for (unsigned int t = 0; t < 6; t++)
 
4174
          {
 
4175
            for (unsigned int u = 0; u < 6; u++)
 
4176
            {
 
4177
              dmats_old[t][u] = dmats[t][u];
 
4178
              dmats[t][u] = 0.000000000000000;
 
4179
            }// end loop over 'u'
 
4180
          }// end loop over 't'
 
4181
          
 
4182
          // Update dmats using an inner product.
 
4183
          if (combinations[r][s] == 0)
 
4184
          {
 
4185
          for (unsigned int t = 0; t < 6; t++)
 
4186
          {
 
4187
            for (unsigned int u = 0; u < 6; u++)
 
4188
            {
 
4189
              for (unsigned int tu = 0; tu < 6; tu++)
 
4190
              {
 
4191
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
4192
              }// end loop over 'tu'
 
4193
            }// end loop over 'u'
 
4194
          }// end loop over 't'
 
4195
          }
 
4196
          
 
4197
          if (combinations[r][s] == 1)
 
4198
          {
 
4199
          for (unsigned int t = 0; t < 6; t++)
 
4200
          {
 
4201
            for (unsigned int u = 0; u < 6; u++)
 
4202
            {
 
4203
              for (unsigned int tu = 0; tu < 6; tu++)
 
4204
              {
 
4205
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
4206
              }// end loop over 'tu'
 
4207
            }// end loop over 'u'
 
4208
          }// end loop over 't'
 
4209
          }
 
4210
          
 
4211
        }// end loop over 's'
 
4212
        for (unsigned int s = 0; s < 6; s++)
 
4213
        {
 
4214
          for (unsigned int t = 0; t < 6; t++)
 
4215
          {
 
4216
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
4217
          }// end loop over 't'
 
4218
        }// end loop over 's'
 
4219
      }// end loop over 'r'
 
4220
      
 
4221
      // Transform derivatives back to physical element
 
4222
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4223
      {
 
4224
        for (unsigned int s = 0; s < num_derivatives; s++)
 
4225
        {
 
4226
          values[r] += transform[r][s]*derivatives[s];
 
4227
        }// end loop over 's'
 
4228
      }// end loop over 'r'
 
4229
      
 
4230
      // Delete pointer to array of derivatives on FIAT element
 
4231
      delete [] derivatives;
 
4232
      
 
4233
      // Delete pointer to array of combinations of derivatives and transform
 
4234
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4235
      {
 
4236
        delete [] combinations[r];
 
4237
      }// end loop over 'r'
 
4238
      delete [] combinations;
 
4239
      for (unsigned int r = 0; r < num_derivatives; r++)
 
4240
      {
 
4241
        delete [] transform[r];
 
4242
      }// end loop over 'r'
 
4243
      delete [] transform;
 
4244
        break;
 
4245
      }
 
4246
    }
 
4247
    
 
4248
  }
 
4249
 
 
4250
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
4251
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
4252
                                              double* values,
 
4253
                                              const double* coordinates,
 
4254
                                              const ufc::cell& c) const
 
4255
  {
 
4256
    // Compute number of derivatives.
 
4257
    unsigned int num_derivatives = 1;
 
4258
    for (unsigned int r = 0; r < n; r++)
 
4259
    {
 
4260
      num_derivatives *= 2;
 
4261
    }// end loop over 'r'
 
4262
    
 
4263
    // Helper variable to hold values of a single dof.
 
4264
    double *dof_values = new double[num_derivatives];
 
4265
    for (unsigned int r = 0; r < num_derivatives; r++)
 
4266
    {
 
4267
      dof_values[r] = 0.000000000000000;
 
4268
    }// end loop over 'r'
 
4269
    
 
4270
    // Loop dofs and call evaluate_basis_derivatives.
 
4271
    for (unsigned int r = 0; r < 6; r++)
 
4272
    {
 
4273
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
4274
      for (unsigned int s = 0; s < num_derivatives; s++)
 
4275
      {
 
4276
        values[r*num_derivatives + s] = dof_values[s];
 
4277
      }// end loop over 's'
 
4278
    }// end loop over 'r'
 
4279
    
 
4280
    // Delete pointer.
 
4281
    delete [] dof_values;
 
4282
  }
 
4283
 
 
4284
  /// Evaluate linear functional for dof i on the function f
 
4285
  virtual double evaluate_dof(unsigned int i,
 
4286
                              const ufc::function& f,
 
4287
                              const ufc::cell& c) const
 
4288
  {
 
4289
    // Declare variables for result of evaluation.
 
4290
    double vals[1];
 
4291
    
 
4292
    // Declare variable for physical coordinates.
 
4293
    double y[2];
 
4294
    const double * const * x = c.coordinates;
 
4295
    switch (i)
 
4296
    {
 
4297
    case 0:
 
4298
      {
 
4299
        y[0] = x[0][0];
 
4300
      y[1] = x[0][1];
 
4301
      f.evaluate(vals, y, c);
 
4302
      return vals[0];
 
4303
        break;
 
4304
      }
 
4305
    case 1:
 
4306
      {
 
4307
        y[0] = x[1][0];
 
4308
      y[1] = x[1][1];
 
4309
      f.evaluate(vals, y, c);
 
4310
      return vals[0];
 
4311
        break;
 
4312
      }
 
4313
    case 2:
 
4314
      {
 
4315
        y[0] = x[2][0];
 
4316
      y[1] = x[2][1];
 
4317
      f.evaluate(vals, y, c);
 
4318
      return vals[0];
 
4319
        break;
 
4320
      }
 
4321
    case 3:
 
4322
      {
 
4323
        y[0] = 0.500000000000000*x[1][0] + 0.500000000000000*x[2][0];
 
4324
      y[1] = 0.500000000000000*x[1][1] + 0.500000000000000*x[2][1];
 
4325
      f.evaluate(vals, y, c);
 
4326
      return vals[0];
 
4327
        break;
 
4328
      }
 
4329
    case 4:
 
4330
      {
 
4331
        y[0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[2][0];
 
4332
      y[1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[2][1];
 
4333
      f.evaluate(vals, y, c);
 
4334
      return vals[0];
 
4335
        break;
 
4336
      }
 
4337
    case 5:
 
4338
      {
 
4339
        y[0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[1][0];
 
4340
      y[1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[1][1];
 
4341
      f.evaluate(vals, y, c);
 
4342
      return vals[0];
 
4343
        break;
 
4344
      }
 
4345
    }
 
4346
    
 
4347
    return 0.000000000000000;
 
4348
  }
 
4349
 
 
4350
  /// Evaluate linear functionals for all dofs on the function f
 
4351
  virtual void evaluate_dofs(double* values,
 
4352
                             const ufc::function& f,
 
4353
                             const ufc::cell& c) const
 
4354
  {
 
4355
    // Declare variables for result of evaluation.
 
4356
    double vals[1];
 
4357
    
 
4358
    // Declare variable for physical coordinates.
 
4359
    double y[2];
 
4360
    const double * const * x = c.coordinates;
 
4361
    y[0] = x[0][0];
 
4362
    y[1] = x[0][1];
 
4363
    f.evaluate(vals, y, c);
 
4364
    values[0] = vals[0];
 
4365
    y[0] = x[1][0];
 
4366
    y[1] = x[1][1];
 
4367
    f.evaluate(vals, y, c);
 
4368
    values[1] = vals[0];
 
4369
    y[0] = x[2][0];
 
4370
    y[1] = x[2][1];
 
4371
    f.evaluate(vals, y, c);
 
4372
    values[2] = vals[0];
 
4373
    y[0] = 0.500000000000000*x[1][0] + 0.500000000000000*x[2][0];
 
4374
    y[1] = 0.500000000000000*x[1][1] + 0.500000000000000*x[2][1];
 
4375
    f.evaluate(vals, y, c);
 
4376
    values[3] = vals[0];
 
4377
    y[0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[2][0];
 
4378
    y[1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[2][1];
 
4379
    f.evaluate(vals, y, c);
 
4380
    values[4] = vals[0];
 
4381
    y[0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[1][0];
 
4382
    y[1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[1][1];
 
4383
    f.evaluate(vals, y, c);
 
4384
    values[5] = vals[0];
 
4385
  }
 
4386
 
 
4387
  /// Interpolate vertex values from dof values
 
4388
  virtual void interpolate_vertex_values(double* vertex_values,
 
4389
                                         const double* dof_values,
 
4390
                                         const ufc::cell& c) const
 
4391
  {
 
4392
    // Evaluate function and change variables
 
4393
    vertex_values[0] = dof_values[0];
 
4394
    vertex_values[1] = dof_values[1];
 
4395
    vertex_values[2] = dof_values[2];
 
4396
  }
 
4397
 
 
4398
  /// Map coordinate xhat from reference cell to coordinate x in cell
 
4399
  virtual void map_from_reference_cell(double* x,
 
4400
                                       const double* xhat,
 
4401
                                       const ufc::cell& c)
 
4402
  {
 
4403
    throw std::runtime_error("map_from_reference_cell not yet implemented (introduced in UFC 2.0).");
 
4404
  }
 
4405
 
 
4406
  /// Map from coordinate x in cell to coordinate xhat in reference cell
 
4407
  virtual void map_to_reference_cell(double* xhat,
 
4408
                                     const double* x,
 
4409
                                     const ufc::cell& c)
 
4410
  {
 
4411
    throw std::runtime_error("map_to_reference_cell not yet implemented (introduced in UFC 2.0).");
 
4412
  }
 
4413
 
 
4414
  /// Return the number of sub elements (for a mixed element)
 
4415
  virtual unsigned int num_sub_elements() const
 
4416
  {
 
4417
    return 0;
 
4418
  }
 
4419
 
 
4420
  /// Create a new finite element for sub element i (for a mixed element)
 
4421
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
4422
  {
 
4423
    return 0;
 
4424
  }
 
4425
 
 
4426
  /// Create a new class instance
 
4427
  virtual ufc::finite_element* create() const
 
4428
  {
 
4429
    return new adaptivepoisson_finite_element_2();
 
4430
  }
 
4431
 
 
4432
};
 
4433
 
 
4434
/// This class defines the interface for a finite element.
 
4435
 
 
4436
class adaptivepoisson_finite_element_3: public ufc::finite_element
 
4437
{
 
4438
public:
 
4439
 
 
4440
  /// Constructor
 
4441
  adaptivepoisson_finite_element_3() : ufc::finite_element()
 
4442
  {
 
4443
    // Do nothing
 
4444
  }
 
4445
 
 
4446
  /// Destructor
 
4447
  virtual ~adaptivepoisson_finite_element_3()
 
4448
  {
 
4449
    // Do nothing
 
4450
  }
 
4451
 
 
4452
  /// Return a string identifying the finite element
 
4453
  virtual const char* signature() const
 
4454
  {
 
4455
    return "FiniteElement('Bubble', Cell('triangle', 1, Space(2)), 3)";
 
4456
  }
 
4457
 
 
4458
  /// Return the cell shape
 
4459
  virtual ufc::shape cell_shape() const
 
4460
  {
 
4461
    return ufc::triangle;
 
4462
  }
 
4463
 
 
4464
  /// Return the topological dimension of the cell shape
 
4465
  virtual unsigned int topological_dimension() const
 
4466
  {
 
4467
    return 2;
 
4468
  }
 
4469
 
 
4470
  /// Return the geometric dimension of the cell shape
 
4471
  virtual unsigned int geometric_dimension() const
 
4472
  {
 
4473
    return 2;
 
4474
  }
 
4475
 
 
4476
  /// Return the dimension of the finite element function space
 
4477
  virtual unsigned int space_dimension() const
 
4478
  {
 
4479
    return 1;
 
4480
  }
 
4481
 
 
4482
  /// Return the rank of the value space
 
4483
  virtual unsigned int value_rank() const
 
4484
  {
 
4485
    return 0;
 
4486
  }
 
4487
 
 
4488
  /// Return the dimension of the value space for axis i
 
4489
  virtual unsigned int value_dimension(unsigned int i) const
 
4490
  {
 
4491
    return 1;
 
4492
  }
 
4493
 
 
4494
  /// Evaluate basis function i at given point in cell
 
4495
  virtual void evaluate_basis(unsigned int i,
 
4496
                              double* values,
 
4497
                              const double* coordinates,
 
4498
                              const ufc::cell& c) const
 
4499
  {
 
4500
    // Extract vertex coordinates
 
4501
    const double * const * x = c.coordinates;
 
4502
    
 
4503
    // Compute Jacobian of affine map from reference cell
 
4504
    const double J_00 = x[1][0] - x[0][0];
 
4505
    const double J_01 = x[2][0] - x[0][0];
 
4506
    const double J_10 = x[1][1] - x[0][1];
 
4507
    const double J_11 = x[2][1] - x[0][1];
 
4508
    
 
4509
    // Compute determinant of Jacobian
 
4510
    double detJ = J_00*J_11 - J_01*J_10;
 
4511
    
 
4512
    // Compute inverse of Jacobian
 
4513
    
 
4514
    // Compute constants
 
4515
    const double C0 = x[1][0] + x[2][0];
 
4516
    const double C1 = x[1][1] + x[2][1];
 
4517
    
 
4518
    // Get coordinates and map to the reference (FIAT) element
 
4519
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
4520
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
4521
    
 
4522
    // Reset values.
 
4523
    *values = 0.000000000000000;
 
4524
    
 
4525
    // Array of basisvalues.
 
4526
    double basisvalues[10] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
4527
    
 
4528
    // Declare helper variables.
 
4529
    unsigned int rr = 0;
 
4530
    unsigned int ss = 0;
 
4531
    unsigned int tt = 0;
 
4532
    double tmp5 = 0.000000000000000;
 
4533
    double tmp6 = 0.000000000000000;
 
4534
    double tmp7 = 0.000000000000000;
 
4535
    double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
4536
    double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
4537
    double tmp2 = tmp1*tmp1;
 
4538
    
 
4539
    // Compute basisvalues.
 
4540
    basisvalues[0] = 1.000000000000000;
 
4541
    basisvalues[1] = tmp0;
 
4542
    for (unsigned int r = 1; r < 3; r++)
 
4543
    {
 
4544
      rr = (r + 1)*((r + 1) + 1)/2;
 
4545
      ss = r*(r + 1)/2;
 
4546
      tt = (r - 1)*((r - 1) + 1)/2;
 
4547
      tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
4548
      basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
4549
    }// end loop over 'r'
 
4550
    for (unsigned int r = 0; r < 3; r++)
 
4551
    {
 
4552
      rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
4553
      ss = r*(r + 1)/2;
 
4554
      basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
4555
    }// end loop over 'r'
 
4556
    for (unsigned int r = 0; r < 2; r++)
 
4557
    {
 
4558
      for (unsigned int s = 1; s < 3 - r; s++)
 
4559
      {
 
4560
        rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
4561
        ss = (r + s)*(r + s + 1)/2 + s;
 
4562
        tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
4563
        tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4564
        tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4565
        tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4566
        basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
4567
      }// end loop over 's'
 
4568
    }// end loop over 'r'
 
4569
    for (unsigned int r = 0; r < 4; r++)
 
4570
    {
 
4571
      for (unsigned int s = 0; s < 4 - r; s++)
 
4572
      {
 
4573
        rr = (r + s)*(r + s + 1)/2 + s;
 
4574
        basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
4575
      }// end loop over 's'
 
4576
    }// end loop over 'r'
 
4577
    
 
4578
    // Table(s) of coefficients.
 
4579
    static const double coefficients0[10] = \
 
4580
    {0.636396103067893, 0.000000000000000, 0.000000000000000, -0.234738238930786, 0.000000000000000, -0.262445329583912, 0.000000000000000, -0.203289278153682, 0.000000000000000, 0.090913729009699};
 
4581
    
 
4582
    // Compute value(s).
 
4583
    for (unsigned int r = 0; r < 10; r++)
 
4584
    {
 
4585
      *values += coefficients0[r]*basisvalues[r];
 
4586
    }// end loop over 'r'
 
4587
  }
 
4588
 
 
4589
  /// Evaluate all basis functions at given point in cell
 
4590
  virtual void evaluate_basis_all(double* values,
 
4591
                                  const double* coordinates,
 
4592
                                  const ufc::cell& c) const
 
4593
  {
 
4594
    // Element is constant, calling evaluate_basis.
 
4595
    evaluate_basis(0, values, coordinates, c);
 
4596
  }
 
4597
 
 
4598
  /// Evaluate order n derivatives of basis function i at given point in cell
 
4599
  virtual void evaluate_basis_derivatives(unsigned int i,
 
4600
                                          unsigned int n,
 
4601
                                          double* values,
 
4602
                                          const double* coordinates,
 
4603
                                          const ufc::cell& c) const
 
4604
  {
 
4605
    // Extract vertex coordinates
 
4606
    const double * const * x = c.coordinates;
 
4607
    
 
4608
    // Compute Jacobian of affine map from reference cell
 
4609
    const double J_00 = x[1][0] - x[0][0];
 
4610
    const double J_01 = x[2][0] - x[0][0];
 
4611
    const double J_10 = x[1][1] - x[0][1];
 
4612
    const double J_11 = x[2][1] - x[0][1];
 
4613
    
 
4614
    // Compute determinant of Jacobian
 
4615
    double detJ = J_00*J_11 - J_01*J_10;
 
4616
    
 
4617
    // Compute inverse of Jacobian
 
4618
    const double K_00 =  J_11 / detJ;
 
4619
    const double K_01 = -J_01 / detJ;
 
4620
    const double K_10 = -J_10 / detJ;
 
4621
    const double K_11 =  J_00 / detJ;
 
4622
    
 
4623
    // Compute constants
 
4624
    const double C0 = x[1][0] + x[2][0];
 
4625
    const double C1 = x[1][1] + x[2][1];
 
4626
    
 
4627
    // Get coordinates and map to the reference (FIAT) element
 
4628
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
4629
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
4630
    
 
4631
    // Compute number of derivatives.
 
4632
    unsigned int num_derivatives = 1;
 
4633
    for (unsigned int r = 0; r < n; r++)
 
4634
    {
 
4635
      num_derivatives *= 2;
 
4636
    }// end loop over 'r'
 
4637
    
 
4638
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
4639
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
4640
    for (unsigned int row = 0; row < num_derivatives; row++)
 
4641
    {
 
4642
      combinations[row] = new unsigned int [n];
 
4643
      for (unsigned int col = 0; col < n; col++)
 
4644
        combinations[row][col] = 0;
 
4645
    }
 
4646
    
 
4647
    // Generate combinations of derivatives
 
4648
    for (unsigned int row = 1; row < num_derivatives; row++)
 
4649
    {
 
4650
      for (unsigned int num = 0; num < row; num++)
 
4651
      {
 
4652
        for (unsigned int col = n-1; col+1 > 0; col--)
 
4653
        {
 
4654
          if (combinations[row][col] + 1 > 1)
 
4655
            combinations[row][col] = 0;
 
4656
          else
 
4657
          {
 
4658
            combinations[row][col] += 1;
 
4659
            break;
 
4660
          }
 
4661
        }
 
4662
      }
 
4663
    }
 
4664
    
 
4665
    // Compute inverse of Jacobian
 
4666
    const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
 
4667
    
 
4668
    // Declare transformation matrix
 
4669
    // Declare pointer to two dimensional array and initialise
 
4670
    double **transform = new double *[num_derivatives];
 
4671
    
 
4672
    for (unsigned int j = 0; j < num_derivatives; j++)
 
4673
    {
 
4674
      transform[j] = new double [num_derivatives];
 
4675
      for (unsigned int k = 0; k < num_derivatives; k++)
 
4676
        transform[j][k] = 1;
 
4677
    }
 
4678
    
 
4679
    // Construct transformation matrix
 
4680
    for (unsigned int row = 0; row < num_derivatives; row++)
 
4681
    {
 
4682
      for (unsigned int col = 0; col < num_derivatives; col++)
 
4683
      {
 
4684
        for (unsigned int k = 0; k < n; k++)
 
4685
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
4686
      }
 
4687
    }
 
4688
    
 
4689
    // Reset values. Assuming that values is always an array.
 
4690
    for (unsigned int r = 0; r < num_derivatives; r++)
 
4691
    {
 
4692
      values[r] = 0.000000000000000;
 
4693
    }// end loop over 'r'
 
4694
    
 
4695
    
 
4696
    // Array of basisvalues.
 
4697
    double basisvalues[10] = {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000};
 
4698
    
 
4699
    // Declare helper variables.
 
4700
    unsigned int rr = 0;
 
4701
    unsigned int ss = 0;
 
4702
    unsigned int tt = 0;
 
4703
    double tmp5 = 0.000000000000000;
 
4704
    double tmp6 = 0.000000000000000;
 
4705
    double tmp7 = 0.000000000000000;
 
4706
    double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
4707
    double tmp1 = (1.000000000000000 - Y)/2.000000000000000;
 
4708
    double tmp2 = tmp1*tmp1;
 
4709
    
 
4710
    // Compute basisvalues.
 
4711
    basisvalues[0] = 1.000000000000000;
 
4712
    basisvalues[1] = tmp0;
 
4713
    for (unsigned int r = 1; r < 3; r++)
 
4714
    {
 
4715
      rr = (r + 1)*((r + 1) + 1)/2;
 
4716
      ss = r*(r + 1)/2;
 
4717
      tt = (r - 1)*((r - 1) + 1)/2;
 
4718
      tmp5 = (1.000000000000000 + 2.000000000000000*r)/(1.000000000000000 + r);
 
4719
      basisvalues[rr] = (basisvalues[ss]*tmp0*tmp5 - basisvalues[tt]*tmp2*r/(1.000000000000000 + r));
 
4720
    }// end loop over 'r'
 
4721
    for (unsigned int r = 0; r < 3; r++)
 
4722
    {
 
4723
      rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
4724
      ss = r*(r + 1)/2;
 
4725
      basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
4726
    }// end loop over 'r'
 
4727
    for (unsigned int r = 0; r < 2; r++)
 
4728
    {
 
4729
      for (unsigned int s = 1; s < 3 - r; s++)
 
4730
      {
 
4731
        rr = (r + s + 1)*(r + s + 1 + 1)/2 + s + 1;
 
4732
        ss = (r + s)*(r + s + 1)/2 + s;
 
4733
        tt = (r + s - 1)*(r + s - 1 + 1)/2 + s - 1;
 
4734
        tmp5 = (2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4735
        tmp6 = (1.000000000000000 + 4.000000000000000*r*r + 4.000000000000000*r)*(2.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)/(2.000000000000000*(1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4736
        tmp7 = (1.000000000000000 + s + 2.000000000000000*r)*(3.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*s/((1.000000000000000 + 2.000000000000000*r + 2.000000000000000*s)*(1.000000000000000 + s)*(2.000000000000000 + s + 2.000000000000000*r));
 
4737
        basisvalues[rr] = (basisvalues[ss]*(tmp6 + Y*tmp5) - basisvalues[tt]*tmp7);
 
4738
      }// end loop over 's'
 
4739
    }// end loop over 'r'
 
4740
    for (unsigned int r = 0; r < 4; r++)
 
4741
    {
 
4742
      for (unsigned int s = 0; s < 4 - r; s++)
 
4743
      {
 
4744
        rr = (r + s)*(r + s + 1)/2 + s;
 
4745
        basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
4746
      }// end loop over 's'
 
4747
    }// end loop over 'r'
 
4748
    
 
4749
    // Table(s) of coefficients.
 
4750
    static const double coefficients0[10] = \
 
4751
    {0.636396103067893, 0.000000000000000, 0.000000000000000, -0.234738238930786, 0.000000000000000, -0.262445329583912, 0.000000000000000, -0.203289278153682, 0.000000000000000, 0.090913729009699};
 
4752
    
 
4753
    // Tables of derivatives of the polynomial base (transpose).
 
4754
    static const double dmats0[10][10] = \
 
4755
    {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4756
    {4.898979485566356, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4757
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4758
    {0.000000000000000, 9.486832980505140, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4759
    {3.999999999999998, 0.000000000000000, 7.071067811865476, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4760
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4761
    {5.291502622129178, 0.000000000000000, -2.993325909419151, 13.662601021279462, 0.000000000000000, 0.611010092660779, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4762
    {0.000000000000000, 4.381780460041330, 0.000000000000000, 0.000000000000000, 12.521980673998824, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4763
    {3.464101615137755, 0.000000000000000, 7.838367176906168, 0.000000000000000, 0.000000000000000, 8.400000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4764
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
4765
    
 
4766
    static const double dmats1[10][10] = \
 
4767
    {{0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4768
    {2.449489742783178, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4769
    {4.242640687119285, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4770
    {2.581988897471611, 4.743416490252570, -0.912870929175277, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4771
    {1.999999999999999, 6.123724356957946, 3.535533905932738, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4772
    {-2.309401076758503, 0.000000000000000, 8.164965809277261, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4773
    {2.645751311064590, 5.184592558726288, -1.496662954709576, 6.831300510639732, -1.058300524425836, 0.305505046330390, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4774
    {2.236067977499788, 2.190890230020664, 2.529822128134706, 8.082903768654761, 6.260990336999411, -1.807392228230128, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4775
    {1.732050807568876, -5.091168824543143, 3.919183588453085, 0.000000000000000, 9.699484522385713, 4.200000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4776
    {5.000000000000002, 0.000000000000000, -2.828427124746193, 0.000000000000000, 0.000000000000000, 12.124355652982144, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
4777
    
 
4778
    // Compute reference derivatives.
 
4779
    // Declare pointer to array of derivatives on FIAT element.
 
4780
    double *derivatives = new double[num_derivatives];
 
4781
    for (unsigned int r = 0; r < num_derivatives; r++)
 
4782
    {
 
4783
      derivatives[r] = 0.000000000000000;
 
4784
    }// end loop over 'r'
 
4785
    
 
4786
    // Declare derivative matrix (of polynomial basis).
 
4787
    double dmats[10][10] = \
 
4788
    {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4789
    {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4790
    {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4791
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4792
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4793
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4794
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4795
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
4796
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
4797
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
4798
    
 
4799
    // Declare (auxiliary) derivative matrix (of polynomial basis).
 
4800
    double dmats_old[10][10] = \
 
4801
    {{1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4802
    {0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4803
    {0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4804
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4805
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4806
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4807
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000},
 
4808
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000, 0.000000000000000},
 
4809
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000, 0.000000000000000},
 
4810
    {0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
4811
    
 
4812
    // Loop possible derivatives.
 
4813
    for (unsigned int r = 0; r < num_derivatives; r++)
 
4814
    {
 
4815
      // Resetting dmats values to compute next derivative.
 
4816
      for (unsigned int t = 0; t < 10; t++)
 
4817
      {
 
4818
        for (unsigned int u = 0; u < 10; u++)
 
4819
        {
 
4820
          dmats[t][u] = 0.000000000000000;
 
4821
          if (t == u)
 
4822
          {
 
4823
          dmats[t][u] = 1.000000000000000;
 
4824
          }
 
4825
          
 
4826
        }// end loop over 'u'
 
4827
      }// end loop over 't'
 
4828
      
 
4829
      // Looping derivative order to generate dmats.
 
4830
      for (unsigned int s = 0; s < n; s++)
 
4831
      {
 
4832
        // Updating dmats_old with new values and resetting dmats.
 
4833
        for (unsigned int t = 0; t < 10; t++)
 
4834
        {
 
4835
          for (unsigned int u = 0; u < 10; u++)
 
4836
          {
 
4837
            dmats_old[t][u] = dmats[t][u];
 
4838
            dmats[t][u] = 0.000000000000000;
 
4839
          }// end loop over 'u'
 
4840
        }// end loop over 't'
 
4841
        
 
4842
        // Update dmats using an inner product.
 
4843
        if (combinations[r][s] == 0)
 
4844
        {
 
4845
        for (unsigned int t = 0; t < 10; t++)
 
4846
        {
 
4847
          for (unsigned int u = 0; u < 10; u++)
 
4848
          {
 
4849
            for (unsigned int tu = 0; tu < 10; tu++)
 
4850
            {
 
4851
              dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
4852
            }// end loop over 'tu'
 
4853
          }// end loop over 'u'
 
4854
        }// end loop over 't'
 
4855
        }
 
4856
        
 
4857
        if (combinations[r][s] == 1)
 
4858
        {
 
4859
        for (unsigned int t = 0; t < 10; t++)
 
4860
        {
 
4861
          for (unsigned int u = 0; u < 10; u++)
 
4862
          {
 
4863
            for (unsigned int tu = 0; tu < 10; tu++)
 
4864
            {
 
4865
              dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
4866
            }// end loop over 'tu'
 
4867
          }// end loop over 'u'
 
4868
        }// end loop over 't'
 
4869
        }
 
4870
        
 
4871
      }// end loop over 's'
 
4872
      for (unsigned int s = 0; s < 10; s++)
 
4873
      {
 
4874
        for (unsigned int t = 0; t < 10; t++)
 
4875
        {
 
4876
          derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
4877
        }// end loop over 't'
 
4878
      }// end loop over 's'
 
4879
    }// end loop over 'r'
 
4880
    
 
4881
    // Transform derivatives back to physical element
 
4882
    for (unsigned int r = 0; r < num_derivatives; r++)
 
4883
    {
 
4884
      for (unsigned int s = 0; s < num_derivatives; s++)
 
4885
      {
 
4886
        values[r] += transform[r][s]*derivatives[s];
 
4887
      }// end loop over 's'
 
4888
    }// end loop over 'r'
 
4889
    
 
4890
    // Delete pointer to array of derivatives on FIAT element
 
4891
    delete [] derivatives;
 
4892
    
 
4893
    // Delete pointer to array of combinations of derivatives and transform
 
4894
    for (unsigned int r = 0; r < num_derivatives; r++)
 
4895
    {
 
4896
      delete [] combinations[r];
 
4897
    }// end loop over 'r'
 
4898
    delete [] combinations;
 
4899
    for (unsigned int r = 0; r < num_derivatives; r++)
 
4900
    {
 
4901
      delete [] transform[r];
 
4902
    }// end loop over 'r'
 
4903
    delete [] transform;
 
4904
  }
 
4905
 
 
4906
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
4907
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
4908
                                              double* values,
 
4909
                                              const double* coordinates,
 
4910
                                              const ufc::cell& c) const
 
4911
  {
 
4912
    // Element is constant, calling evaluate_basis_derivatives.
 
4913
    evaluate_basis_derivatives(0, n, values, coordinates, c);
 
4914
  }
 
4915
 
 
4916
  /// Evaluate linear functional for dof i on the function f
 
4917
  virtual double evaluate_dof(unsigned int i,
 
4918
                              const ufc::function& f,
 
4919
                              const ufc::cell& c) const
 
4920
  {
 
4921
    // Declare variables for result of evaluation.
 
4922
    double vals[1];
 
4923
    
 
4924
    // Declare variable for physical coordinates.
 
4925
    double y[2];
 
4926
    const double * const * x = c.coordinates;
 
4927
    switch (i)
 
4928
    {
 
4929
    case 0:
 
4930
      {
 
4931
        y[0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
 
4932
      y[1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
 
4933
      f.evaluate(vals, y, c);
 
4934
      return vals[0];
 
4935
        break;
 
4936
      }
 
4937
    }
 
4938
    
 
4939
    return 0.000000000000000;
 
4940
  }
 
4941
 
 
4942
  /// Evaluate linear functionals for all dofs on the function f
 
4943
  virtual void evaluate_dofs(double* values,
 
4944
                             const ufc::function& f,
 
4945
                             const ufc::cell& c) const
 
4946
  {
 
4947
    // Declare variables for result of evaluation.
 
4948
    double vals[1];
 
4949
    
 
4950
    // Declare variable for physical coordinates.
 
4951
    double y[2];
 
4952
    const double * const * x = c.coordinates;
 
4953
    y[0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
 
4954
    y[1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
 
4955
    f.evaluate(vals, y, c);
 
4956
    values[0] = vals[0];
 
4957
  }
 
4958
 
 
4959
  /// Interpolate vertex values from dof values
 
4960
  virtual void interpolate_vertex_values(double* vertex_values,
 
4961
                                         const double* dof_values,
 
4962
                                         const ufc::cell& c) const
 
4963
  {
 
4964
    // Evaluate function and change variables
 
4965
    vertex_values[0] = 0;
 
4966
    vertex_values[1] = 0;
 
4967
    vertex_values[2] = 0;
 
4968
  }
 
4969
 
 
4970
  /// Map coordinate xhat from reference cell to coordinate x in cell
 
4971
  virtual void map_from_reference_cell(double* x,
 
4972
                                       const double* xhat,
 
4973
                                       const ufc::cell& c)
 
4974
  {
 
4975
    throw std::runtime_error("map_from_reference_cell not yet implemented (introduced in UFC 2.0).");
 
4976
  }
 
4977
 
 
4978
  /// Map from coordinate x in cell to coordinate xhat in reference cell
 
4979
  virtual void map_to_reference_cell(double* xhat,
 
4980
                                     const double* x,
 
4981
                                     const ufc::cell& c)
 
4982
  {
 
4983
    throw std::runtime_error("map_to_reference_cell not yet implemented (introduced in UFC 2.0).");
 
4984
  }
 
4985
 
 
4986
  /// Return the number of sub elements (for a mixed element)
 
4987
  virtual unsigned int num_sub_elements() const
 
4988
  {
 
4989
    return 0;
 
4990
  }
 
4991
 
 
4992
  /// Create a new finite element for sub element i (for a mixed element)
 
4993
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
4994
  {
 
4995
    return 0;
 
4996
  }
 
4997
 
 
4998
  /// Create a new class instance
 
4999
  virtual ufc::finite_element* create() const
 
5000
  {
 
5001
    return new adaptivepoisson_finite_element_3();
 
5002
  }
 
5003
 
 
5004
};
 
5005
 
 
5006
/// This class defines the interface for a finite element.
 
5007
 
 
5008
class adaptivepoisson_finite_element_4: public ufc::finite_element
 
5009
{
 
5010
public:
 
5011
 
 
5012
  /// Constructor
 
5013
  adaptivepoisson_finite_element_4() : ufc::finite_element()
 
5014
  {
 
5015
    // Do nothing
 
5016
  }
 
5017
 
 
5018
  /// Destructor
 
5019
  virtual ~adaptivepoisson_finite_element_4()
 
5020
  {
 
5021
    // Do nothing
 
5022
  }
 
5023
 
 
5024
  /// Return a string identifying the finite element
 
5025
  virtual const char* signature() const
 
5026
  {
 
5027
    return "FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1)";
 
5028
  }
 
5029
 
 
5030
  /// Return the cell shape
 
5031
  virtual ufc::shape cell_shape() const
 
5032
  {
 
5033
    return ufc::triangle;
 
5034
  }
 
5035
 
 
5036
  /// Return the topological dimension of the cell shape
 
5037
  virtual unsigned int topological_dimension() const
 
5038
  {
 
5039
    return 2;
 
5040
  }
 
5041
 
 
5042
  /// Return the geometric dimension of the cell shape
 
5043
  virtual unsigned int geometric_dimension() const
 
5044
  {
 
5045
    return 2;
 
5046
  }
 
5047
 
 
5048
  /// Return the dimension of the finite element function space
 
5049
  virtual unsigned int space_dimension() const
 
5050
  {
 
5051
    return 3;
 
5052
  }
 
5053
 
 
5054
  /// Return the rank of the value space
 
5055
  virtual unsigned int value_rank() const
 
5056
  {
 
5057
    return 0;
 
5058
  }
 
5059
 
 
5060
  /// Return the dimension of the value space for axis i
 
5061
  virtual unsigned int value_dimension(unsigned int i) const
 
5062
  {
 
5063
    return 1;
 
5064
  }
 
5065
 
 
5066
  /// Evaluate basis function i at given point in cell
 
5067
  virtual void evaluate_basis(unsigned int i,
 
5068
                              double* values,
 
5069
                              const double* coordinates,
 
5070
                              const ufc::cell& c) const
 
5071
  {
 
5072
    // Extract vertex coordinates
 
5073
    const double * const * x = c.coordinates;
 
5074
    
 
5075
    // Compute Jacobian of affine map from reference cell
 
5076
    const double J_00 = x[1][0] - x[0][0];
 
5077
    const double J_01 = x[2][0] - x[0][0];
 
5078
    const double J_10 = x[1][1] - x[0][1];
 
5079
    const double J_11 = x[2][1] - x[0][1];
 
5080
    
 
5081
    // Compute determinant of Jacobian
 
5082
    double detJ = J_00*J_11 - J_01*J_10;
 
5083
    
 
5084
    // Compute inverse of Jacobian
 
5085
    
 
5086
    // Compute constants
 
5087
    const double C0 = x[1][0] + x[2][0];
 
5088
    const double C1 = x[1][1] + x[2][1];
 
5089
    
 
5090
    // Get coordinates and map to the reference (FIAT) element
 
5091
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
5092
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
5093
    
 
5094
    // Reset values.
 
5095
    *values = 0.000000000000000;
 
5096
    switch (i)
 
5097
    {
 
5098
    case 0:
 
5099
      {
 
5100
        
 
5101
      // Array of basisvalues.
 
5102
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
5103
      
 
5104
      // Declare helper variables.
 
5105
      unsigned int rr = 0;
 
5106
      unsigned int ss = 0;
 
5107
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
5108
      
 
5109
      // Compute basisvalues.
 
5110
      basisvalues[0] = 1.000000000000000;
 
5111
      basisvalues[1] = tmp0;
 
5112
      for (unsigned int r = 0; r < 1; r++)
 
5113
      {
 
5114
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
5115
        ss = r*(r + 1)/2;
 
5116
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
5117
      }// end loop over 'r'
 
5118
      for (unsigned int r = 0; r < 2; r++)
 
5119
      {
 
5120
        for (unsigned int s = 0; s < 2 - r; s++)
 
5121
        {
 
5122
          rr = (r + s)*(r + s + 1)/2 + s;
 
5123
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
5124
        }// end loop over 's'
 
5125
      }// end loop over 'r'
 
5126
      
 
5127
      // Table(s) of coefficients.
 
5128
      static const double coefficients0[3] = \
 
5129
      {0.471404520791032, -0.288675134594813, -0.166666666666667};
 
5130
      
 
5131
      // Compute value(s).
 
5132
      for (unsigned int r = 0; r < 3; r++)
 
5133
      {
 
5134
        *values += coefficients0[r]*basisvalues[r];
 
5135
      }// end loop over 'r'
 
5136
        break;
 
5137
      }
 
5138
    case 1:
 
5139
      {
 
5140
        
 
5141
      // Array of basisvalues.
 
5142
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
5143
      
 
5144
      // Declare helper variables.
 
5145
      unsigned int rr = 0;
 
5146
      unsigned int ss = 0;
 
5147
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
5148
      
 
5149
      // Compute basisvalues.
 
5150
      basisvalues[0] = 1.000000000000000;
 
5151
      basisvalues[1] = tmp0;
 
5152
      for (unsigned int r = 0; r < 1; r++)
 
5153
      {
 
5154
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
5155
        ss = r*(r + 1)/2;
 
5156
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
5157
      }// end loop over 'r'
 
5158
      for (unsigned int r = 0; r < 2; r++)
 
5159
      {
 
5160
        for (unsigned int s = 0; s < 2 - r; s++)
 
5161
        {
 
5162
          rr = (r + s)*(r + s + 1)/2 + s;
 
5163
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
5164
        }// end loop over 's'
 
5165
      }// end loop over 'r'
 
5166
      
 
5167
      // Table(s) of coefficients.
 
5168
      static const double coefficients0[3] = \
 
5169
      {0.471404520791032, 0.288675134594813, -0.166666666666667};
 
5170
      
 
5171
      // Compute value(s).
 
5172
      for (unsigned int r = 0; r < 3; r++)
 
5173
      {
 
5174
        *values += coefficients0[r]*basisvalues[r];
 
5175
      }// end loop over 'r'
 
5176
        break;
 
5177
      }
 
5178
    case 2:
 
5179
      {
 
5180
        
 
5181
      // Array of basisvalues.
 
5182
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
5183
      
 
5184
      // Declare helper variables.
 
5185
      unsigned int rr = 0;
 
5186
      unsigned int ss = 0;
 
5187
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
5188
      
 
5189
      // Compute basisvalues.
 
5190
      basisvalues[0] = 1.000000000000000;
 
5191
      basisvalues[1] = tmp0;
 
5192
      for (unsigned int r = 0; r < 1; r++)
 
5193
      {
 
5194
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
5195
        ss = r*(r + 1)/2;
 
5196
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
5197
      }// end loop over 'r'
 
5198
      for (unsigned int r = 0; r < 2; r++)
 
5199
      {
 
5200
        for (unsigned int s = 0; s < 2 - r; s++)
 
5201
        {
 
5202
          rr = (r + s)*(r + s + 1)/2 + s;
 
5203
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
5204
        }// end loop over 's'
 
5205
      }// end loop over 'r'
 
5206
      
 
5207
      // Table(s) of coefficients.
 
5208
      static const double coefficients0[3] = \
 
5209
      {0.471404520791032, 0.000000000000000, 0.333333333333333};
 
5210
      
 
5211
      // Compute value(s).
 
5212
      for (unsigned int r = 0; r < 3; r++)
 
5213
      {
 
5214
        *values += coefficients0[r]*basisvalues[r];
 
5215
      }// end loop over 'r'
 
5216
        break;
 
5217
      }
 
5218
    }
 
5219
    
 
5220
  }
 
5221
 
 
5222
  /// Evaluate all basis functions at given point in cell
 
5223
  virtual void evaluate_basis_all(double* values,
 
5224
                                  const double* coordinates,
 
5225
                                  const ufc::cell& c) const
 
5226
  {
 
5227
    // Helper variable to hold values of a single dof.
 
5228
    double dof_values = 0.000000000000000;
 
5229
    
 
5230
    // Loop dofs and call evaluate_basis.
 
5231
    for (unsigned int r = 0; r < 3; r++)
 
5232
    {
 
5233
      evaluate_basis(r, &dof_values, coordinates, c);
 
5234
      values[r] = dof_values;
 
5235
    }// end loop over 'r'
 
5236
  }
 
5237
 
 
5238
  /// Evaluate order n derivatives of basis function i at given point in cell
 
5239
  virtual void evaluate_basis_derivatives(unsigned int i,
 
5240
                                          unsigned int n,
 
5241
                                          double* values,
 
5242
                                          const double* coordinates,
 
5243
                                          const ufc::cell& c) const
 
5244
  {
 
5245
    // Extract vertex coordinates
 
5246
    const double * const * x = c.coordinates;
 
5247
    
 
5248
    // Compute Jacobian of affine map from reference cell
 
5249
    const double J_00 = x[1][0] - x[0][0];
 
5250
    const double J_01 = x[2][0] - x[0][0];
 
5251
    const double J_10 = x[1][1] - x[0][1];
 
5252
    const double J_11 = x[2][1] - x[0][1];
 
5253
    
 
5254
    // Compute determinant of Jacobian
 
5255
    double detJ = J_00*J_11 - J_01*J_10;
 
5256
    
 
5257
    // Compute inverse of Jacobian
 
5258
    const double K_00 =  J_11 / detJ;
 
5259
    const double K_01 = -J_01 / detJ;
 
5260
    const double K_10 = -J_10 / detJ;
 
5261
    const double K_11 =  J_00 / detJ;
 
5262
    
 
5263
    // Compute constants
 
5264
    const double C0 = x[1][0] + x[2][0];
 
5265
    const double C1 = x[1][1] + x[2][1];
 
5266
    
 
5267
    // Get coordinates and map to the reference (FIAT) element
 
5268
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
5269
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
5270
    
 
5271
    // Compute number of derivatives.
 
5272
    unsigned int num_derivatives = 1;
 
5273
    for (unsigned int r = 0; r < n; r++)
 
5274
    {
 
5275
      num_derivatives *= 2;
 
5276
    }// end loop over 'r'
 
5277
    
 
5278
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
5279
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
5280
    for (unsigned int row = 0; row < num_derivatives; row++)
 
5281
    {
 
5282
      combinations[row] = new unsigned int [n];
 
5283
      for (unsigned int col = 0; col < n; col++)
 
5284
        combinations[row][col] = 0;
 
5285
    }
 
5286
    
 
5287
    // Generate combinations of derivatives
 
5288
    for (unsigned int row = 1; row < num_derivatives; row++)
 
5289
    {
 
5290
      for (unsigned int num = 0; num < row; num++)
 
5291
      {
 
5292
        for (unsigned int col = n-1; col+1 > 0; col--)
 
5293
        {
 
5294
          if (combinations[row][col] + 1 > 1)
 
5295
            combinations[row][col] = 0;
 
5296
          else
 
5297
          {
 
5298
            combinations[row][col] += 1;
 
5299
            break;
 
5300
          }
 
5301
        }
 
5302
      }
 
5303
    }
 
5304
    
 
5305
    // Compute inverse of Jacobian
 
5306
    const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
 
5307
    
 
5308
    // Declare transformation matrix
 
5309
    // Declare pointer to two dimensional array and initialise
 
5310
    double **transform = new double *[num_derivatives];
 
5311
    
 
5312
    for (unsigned int j = 0; j < num_derivatives; j++)
 
5313
    {
 
5314
      transform[j] = new double [num_derivatives];
 
5315
      for (unsigned int k = 0; k < num_derivatives; k++)
 
5316
        transform[j][k] = 1;
 
5317
    }
 
5318
    
 
5319
    // Construct transformation matrix
 
5320
    for (unsigned int row = 0; row < num_derivatives; row++)
 
5321
    {
 
5322
      for (unsigned int col = 0; col < num_derivatives; col++)
 
5323
      {
 
5324
        for (unsigned int k = 0; k < n; k++)
 
5325
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
5326
      }
 
5327
    }
 
5328
    
 
5329
    // Reset values. Assuming that values is always an array.
 
5330
    for (unsigned int r = 0; r < num_derivatives; r++)
 
5331
    {
 
5332
      values[r] = 0.000000000000000;
 
5333
    }// end loop over 'r'
 
5334
    
 
5335
    switch (i)
 
5336
    {
 
5337
    case 0:
 
5338
      {
 
5339
        
 
5340
      // Array of basisvalues.
 
5341
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
5342
      
 
5343
      // Declare helper variables.
 
5344
      unsigned int rr = 0;
 
5345
      unsigned int ss = 0;
 
5346
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
5347
      
 
5348
      // Compute basisvalues.
 
5349
      basisvalues[0] = 1.000000000000000;
 
5350
      basisvalues[1] = tmp0;
 
5351
      for (unsigned int r = 0; r < 1; r++)
 
5352
      {
 
5353
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
5354
        ss = r*(r + 1)/2;
 
5355
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
5356
      }// end loop over 'r'
 
5357
      for (unsigned int r = 0; r < 2; r++)
 
5358
      {
 
5359
        for (unsigned int s = 0; s < 2 - r; s++)
 
5360
        {
 
5361
          rr = (r + s)*(r + s + 1)/2 + s;
 
5362
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
5363
        }// end loop over 's'
 
5364
      }// end loop over 'r'
 
5365
      
 
5366
      // Table(s) of coefficients.
 
5367
      static const double coefficients0[3] = \
 
5368
      {0.471404520791032, -0.288675134594813, -0.166666666666667};
 
5369
      
 
5370
      // Tables of derivatives of the polynomial base (transpose).
 
5371
      static const double dmats0[3][3] = \
 
5372
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
5373
      {4.898979485566356, 0.000000000000000, 0.000000000000000},
 
5374
      {0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
5375
      
 
5376
      static const double dmats1[3][3] = \
 
5377
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
5378
      {2.449489742783178, 0.000000000000000, 0.000000000000000},
 
5379
      {4.242640687119285, 0.000000000000000, 0.000000000000000}};
 
5380
      
 
5381
      // Compute reference derivatives.
 
5382
      // Declare pointer to array of derivatives on FIAT element.
 
5383
      double *derivatives = new double[num_derivatives];
 
5384
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5385
      {
 
5386
        derivatives[r] = 0.000000000000000;
 
5387
      }// end loop over 'r'
 
5388
      
 
5389
      // Declare derivative matrix (of polynomial basis).
 
5390
      double dmats[3][3] = \
 
5391
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
5392
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
5393
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
5394
      
 
5395
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
5396
      double dmats_old[3][3] = \
 
5397
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
5398
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
5399
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
5400
      
 
5401
      // Loop possible derivatives.
 
5402
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5403
      {
 
5404
        // Resetting dmats values to compute next derivative.
 
5405
        for (unsigned int t = 0; t < 3; t++)
 
5406
        {
 
5407
          for (unsigned int u = 0; u < 3; u++)
 
5408
          {
 
5409
            dmats[t][u] = 0.000000000000000;
 
5410
            if (t == u)
 
5411
            {
 
5412
            dmats[t][u] = 1.000000000000000;
 
5413
            }
 
5414
            
 
5415
          }// end loop over 'u'
 
5416
        }// end loop over 't'
 
5417
        
 
5418
        // Looping derivative order to generate dmats.
 
5419
        for (unsigned int s = 0; s < n; s++)
 
5420
        {
 
5421
          // Updating dmats_old with new values and resetting dmats.
 
5422
          for (unsigned int t = 0; t < 3; t++)
 
5423
          {
 
5424
            for (unsigned int u = 0; u < 3; u++)
 
5425
            {
 
5426
              dmats_old[t][u] = dmats[t][u];
 
5427
              dmats[t][u] = 0.000000000000000;
 
5428
            }// end loop over 'u'
 
5429
          }// end loop over 't'
 
5430
          
 
5431
          // Update dmats using an inner product.
 
5432
          if (combinations[r][s] == 0)
 
5433
          {
 
5434
          for (unsigned int t = 0; t < 3; t++)
 
5435
          {
 
5436
            for (unsigned int u = 0; u < 3; u++)
 
5437
            {
 
5438
              for (unsigned int tu = 0; tu < 3; tu++)
 
5439
              {
 
5440
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
5441
              }// end loop over 'tu'
 
5442
            }// end loop over 'u'
 
5443
          }// end loop over 't'
 
5444
          }
 
5445
          
 
5446
          if (combinations[r][s] == 1)
 
5447
          {
 
5448
          for (unsigned int t = 0; t < 3; t++)
 
5449
          {
 
5450
            for (unsigned int u = 0; u < 3; u++)
 
5451
            {
 
5452
              for (unsigned int tu = 0; tu < 3; tu++)
 
5453
              {
 
5454
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
5455
              }// end loop over 'tu'
 
5456
            }// end loop over 'u'
 
5457
          }// end loop over 't'
 
5458
          }
 
5459
          
 
5460
        }// end loop over 's'
 
5461
        for (unsigned int s = 0; s < 3; s++)
 
5462
        {
 
5463
          for (unsigned int t = 0; t < 3; t++)
 
5464
          {
 
5465
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
5466
          }// end loop over 't'
 
5467
        }// end loop over 's'
 
5468
      }// end loop over 'r'
 
5469
      
 
5470
      // Transform derivatives back to physical element
 
5471
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5472
      {
 
5473
        for (unsigned int s = 0; s < num_derivatives; s++)
 
5474
        {
 
5475
          values[r] += transform[r][s]*derivatives[s];
 
5476
        }// end loop over 's'
 
5477
      }// end loop over 'r'
 
5478
      
 
5479
      // Delete pointer to array of derivatives on FIAT element
 
5480
      delete [] derivatives;
 
5481
      
 
5482
      // Delete pointer to array of combinations of derivatives and transform
 
5483
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5484
      {
 
5485
        delete [] combinations[r];
 
5486
      }// end loop over 'r'
 
5487
      delete [] combinations;
 
5488
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5489
      {
 
5490
        delete [] transform[r];
 
5491
      }// end loop over 'r'
 
5492
      delete [] transform;
 
5493
        break;
 
5494
      }
 
5495
    case 1:
 
5496
      {
 
5497
        
 
5498
      // Array of basisvalues.
 
5499
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
5500
      
 
5501
      // Declare helper variables.
 
5502
      unsigned int rr = 0;
 
5503
      unsigned int ss = 0;
 
5504
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
5505
      
 
5506
      // Compute basisvalues.
 
5507
      basisvalues[0] = 1.000000000000000;
 
5508
      basisvalues[1] = tmp0;
 
5509
      for (unsigned int r = 0; r < 1; r++)
 
5510
      {
 
5511
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
5512
        ss = r*(r + 1)/2;
 
5513
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
5514
      }// end loop over 'r'
 
5515
      for (unsigned int r = 0; r < 2; r++)
 
5516
      {
 
5517
        for (unsigned int s = 0; s < 2 - r; s++)
 
5518
        {
 
5519
          rr = (r + s)*(r + s + 1)/2 + s;
 
5520
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
5521
        }// end loop over 's'
 
5522
      }// end loop over 'r'
 
5523
      
 
5524
      // Table(s) of coefficients.
 
5525
      static const double coefficients0[3] = \
 
5526
      {0.471404520791032, 0.288675134594813, -0.166666666666667};
 
5527
      
 
5528
      // Tables of derivatives of the polynomial base (transpose).
 
5529
      static const double dmats0[3][3] = \
 
5530
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
5531
      {4.898979485566356, 0.000000000000000, 0.000000000000000},
 
5532
      {0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
5533
      
 
5534
      static const double dmats1[3][3] = \
 
5535
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
5536
      {2.449489742783178, 0.000000000000000, 0.000000000000000},
 
5537
      {4.242640687119285, 0.000000000000000, 0.000000000000000}};
 
5538
      
 
5539
      // Compute reference derivatives.
 
5540
      // Declare pointer to array of derivatives on FIAT element.
 
5541
      double *derivatives = new double[num_derivatives];
 
5542
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5543
      {
 
5544
        derivatives[r] = 0.000000000000000;
 
5545
      }// end loop over 'r'
 
5546
      
 
5547
      // Declare derivative matrix (of polynomial basis).
 
5548
      double dmats[3][3] = \
 
5549
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
5550
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
5551
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
5552
      
 
5553
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
5554
      double dmats_old[3][3] = \
 
5555
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
5556
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
5557
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
5558
      
 
5559
      // Loop possible derivatives.
 
5560
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5561
      {
 
5562
        // Resetting dmats values to compute next derivative.
 
5563
        for (unsigned int t = 0; t < 3; t++)
 
5564
        {
 
5565
          for (unsigned int u = 0; u < 3; u++)
 
5566
          {
 
5567
            dmats[t][u] = 0.000000000000000;
 
5568
            if (t == u)
 
5569
            {
 
5570
            dmats[t][u] = 1.000000000000000;
 
5571
            }
 
5572
            
 
5573
          }// end loop over 'u'
 
5574
        }// end loop over 't'
 
5575
        
 
5576
        // Looping derivative order to generate dmats.
 
5577
        for (unsigned int s = 0; s < n; s++)
 
5578
        {
 
5579
          // Updating dmats_old with new values and resetting dmats.
 
5580
          for (unsigned int t = 0; t < 3; t++)
 
5581
          {
 
5582
            for (unsigned int u = 0; u < 3; u++)
 
5583
            {
 
5584
              dmats_old[t][u] = dmats[t][u];
 
5585
              dmats[t][u] = 0.000000000000000;
 
5586
            }// end loop over 'u'
 
5587
          }// end loop over 't'
 
5588
          
 
5589
          // Update dmats using an inner product.
 
5590
          if (combinations[r][s] == 0)
 
5591
          {
 
5592
          for (unsigned int t = 0; t < 3; t++)
 
5593
          {
 
5594
            for (unsigned int u = 0; u < 3; u++)
 
5595
            {
 
5596
              for (unsigned int tu = 0; tu < 3; tu++)
 
5597
              {
 
5598
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
5599
              }// end loop over 'tu'
 
5600
            }// end loop over 'u'
 
5601
          }// end loop over 't'
 
5602
          }
 
5603
          
 
5604
          if (combinations[r][s] == 1)
 
5605
          {
 
5606
          for (unsigned int t = 0; t < 3; t++)
 
5607
          {
 
5608
            for (unsigned int u = 0; u < 3; u++)
 
5609
            {
 
5610
              for (unsigned int tu = 0; tu < 3; tu++)
 
5611
              {
 
5612
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
5613
              }// end loop over 'tu'
 
5614
            }// end loop over 'u'
 
5615
          }// end loop over 't'
 
5616
          }
 
5617
          
 
5618
        }// end loop over 's'
 
5619
        for (unsigned int s = 0; s < 3; s++)
 
5620
        {
 
5621
          for (unsigned int t = 0; t < 3; t++)
 
5622
          {
 
5623
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
5624
          }// end loop over 't'
 
5625
        }// end loop over 's'
 
5626
      }// end loop over 'r'
 
5627
      
 
5628
      // Transform derivatives back to physical element
 
5629
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5630
      {
 
5631
        for (unsigned int s = 0; s < num_derivatives; s++)
 
5632
        {
 
5633
          values[r] += transform[r][s]*derivatives[s];
 
5634
        }// end loop over 's'
 
5635
      }// end loop over 'r'
 
5636
      
 
5637
      // Delete pointer to array of derivatives on FIAT element
 
5638
      delete [] derivatives;
 
5639
      
 
5640
      // Delete pointer to array of combinations of derivatives and transform
 
5641
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5642
      {
 
5643
        delete [] combinations[r];
 
5644
      }// end loop over 'r'
 
5645
      delete [] combinations;
 
5646
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5647
      {
 
5648
        delete [] transform[r];
 
5649
      }// end loop over 'r'
 
5650
      delete [] transform;
 
5651
        break;
 
5652
      }
 
5653
    case 2:
 
5654
      {
 
5655
        
 
5656
      // Array of basisvalues.
 
5657
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
5658
      
 
5659
      // Declare helper variables.
 
5660
      unsigned int rr = 0;
 
5661
      unsigned int ss = 0;
 
5662
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
5663
      
 
5664
      // Compute basisvalues.
 
5665
      basisvalues[0] = 1.000000000000000;
 
5666
      basisvalues[1] = tmp0;
 
5667
      for (unsigned int r = 0; r < 1; r++)
 
5668
      {
 
5669
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
5670
        ss = r*(r + 1)/2;
 
5671
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
5672
      }// end loop over 'r'
 
5673
      for (unsigned int r = 0; r < 2; r++)
 
5674
      {
 
5675
        for (unsigned int s = 0; s < 2 - r; s++)
 
5676
        {
 
5677
          rr = (r + s)*(r + s + 1)/2 + s;
 
5678
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
5679
        }// end loop over 's'
 
5680
      }// end loop over 'r'
 
5681
      
 
5682
      // Table(s) of coefficients.
 
5683
      static const double coefficients0[3] = \
 
5684
      {0.471404520791032, 0.000000000000000, 0.333333333333333};
 
5685
      
 
5686
      // Tables of derivatives of the polynomial base (transpose).
 
5687
      static const double dmats0[3][3] = \
 
5688
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
5689
      {4.898979485566356, 0.000000000000000, 0.000000000000000},
 
5690
      {0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
5691
      
 
5692
      static const double dmats1[3][3] = \
 
5693
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
5694
      {2.449489742783178, 0.000000000000000, 0.000000000000000},
 
5695
      {4.242640687119285, 0.000000000000000, 0.000000000000000}};
 
5696
      
 
5697
      // Compute reference derivatives.
 
5698
      // Declare pointer to array of derivatives on FIAT element.
 
5699
      double *derivatives = new double[num_derivatives];
 
5700
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5701
      {
 
5702
        derivatives[r] = 0.000000000000000;
 
5703
      }// end loop over 'r'
 
5704
      
 
5705
      // Declare derivative matrix (of polynomial basis).
 
5706
      double dmats[3][3] = \
 
5707
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
5708
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
5709
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
5710
      
 
5711
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
5712
      double dmats_old[3][3] = \
 
5713
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
5714
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
5715
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
5716
      
 
5717
      // Loop possible derivatives.
 
5718
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5719
      {
 
5720
        // Resetting dmats values to compute next derivative.
 
5721
        for (unsigned int t = 0; t < 3; t++)
 
5722
        {
 
5723
          for (unsigned int u = 0; u < 3; u++)
 
5724
          {
 
5725
            dmats[t][u] = 0.000000000000000;
 
5726
            if (t == u)
 
5727
            {
 
5728
            dmats[t][u] = 1.000000000000000;
 
5729
            }
 
5730
            
 
5731
          }// end loop over 'u'
 
5732
        }// end loop over 't'
 
5733
        
 
5734
        // Looping derivative order to generate dmats.
 
5735
        for (unsigned int s = 0; s < n; s++)
 
5736
        {
 
5737
          // Updating dmats_old with new values and resetting dmats.
 
5738
          for (unsigned int t = 0; t < 3; t++)
 
5739
          {
 
5740
            for (unsigned int u = 0; u < 3; u++)
 
5741
            {
 
5742
              dmats_old[t][u] = dmats[t][u];
 
5743
              dmats[t][u] = 0.000000000000000;
 
5744
            }// end loop over 'u'
 
5745
          }// end loop over 't'
 
5746
          
 
5747
          // Update dmats using an inner product.
 
5748
          if (combinations[r][s] == 0)
 
5749
          {
 
5750
          for (unsigned int t = 0; t < 3; t++)
 
5751
          {
 
5752
            for (unsigned int u = 0; u < 3; u++)
 
5753
            {
 
5754
              for (unsigned int tu = 0; tu < 3; tu++)
 
5755
              {
 
5756
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
5757
              }// end loop over 'tu'
 
5758
            }// end loop over 'u'
 
5759
          }// end loop over 't'
 
5760
          }
 
5761
          
 
5762
          if (combinations[r][s] == 1)
 
5763
          {
 
5764
          for (unsigned int t = 0; t < 3; t++)
 
5765
          {
 
5766
            for (unsigned int u = 0; u < 3; u++)
 
5767
            {
 
5768
              for (unsigned int tu = 0; tu < 3; tu++)
 
5769
              {
 
5770
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
5771
              }// end loop over 'tu'
 
5772
            }// end loop over 'u'
 
5773
          }// end loop over 't'
 
5774
          }
 
5775
          
 
5776
        }// end loop over 's'
 
5777
        for (unsigned int s = 0; s < 3; s++)
 
5778
        {
 
5779
          for (unsigned int t = 0; t < 3; t++)
 
5780
          {
 
5781
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
5782
          }// end loop over 't'
 
5783
        }// end loop over 's'
 
5784
      }// end loop over 'r'
 
5785
      
 
5786
      // Transform derivatives back to physical element
 
5787
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5788
      {
 
5789
        for (unsigned int s = 0; s < num_derivatives; s++)
 
5790
        {
 
5791
          values[r] += transform[r][s]*derivatives[s];
 
5792
        }// end loop over 's'
 
5793
      }// end loop over 'r'
 
5794
      
 
5795
      // Delete pointer to array of derivatives on FIAT element
 
5796
      delete [] derivatives;
 
5797
      
 
5798
      // Delete pointer to array of combinations of derivatives and transform
 
5799
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5800
      {
 
5801
        delete [] combinations[r];
 
5802
      }// end loop over 'r'
 
5803
      delete [] combinations;
 
5804
      for (unsigned int r = 0; r < num_derivatives; r++)
 
5805
      {
 
5806
        delete [] transform[r];
 
5807
      }// end loop over 'r'
 
5808
      delete [] transform;
 
5809
        break;
 
5810
      }
 
5811
    }
 
5812
    
 
5813
  }
 
5814
 
 
5815
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
5816
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
5817
                                              double* values,
 
5818
                                              const double* coordinates,
 
5819
                                              const ufc::cell& c) const
 
5820
  {
 
5821
    // Compute number of derivatives.
 
5822
    unsigned int num_derivatives = 1;
 
5823
    for (unsigned int r = 0; r < n; r++)
 
5824
    {
 
5825
      num_derivatives *= 2;
 
5826
    }// end loop over 'r'
 
5827
    
 
5828
    // Helper variable to hold values of a single dof.
 
5829
    double *dof_values = new double[num_derivatives];
 
5830
    for (unsigned int r = 0; r < num_derivatives; r++)
 
5831
    {
 
5832
      dof_values[r] = 0.000000000000000;
 
5833
    }// end loop over 'r'
 
5834
    
 
5835
    // Loop dofs and call evaluate_basis_derivatives.
 
5836
    for (unsigned int r = 0; r < 3; r++)
 
5837
    {
 
5838
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
5839
      for (unsigned int s = 0; s < num_derivatives; s++)
 
5840
      {
 
5841
        values[r*num_derivatives + s] = dof_values[s];
 
5842
      }// end loop over 's'
 
5843
    }// end loop over 'r'
 
5844
    
 
5845
    // Delete pointer.
 
5846
    delete [] dof_values;
 
5847
  }
 
5848
 
 
5849
  /// Evaluate linear functional for dof i on the function f
 
5850
  virtual double evaluate_dof(unsigned int i,
 
5851
                              const ufc::function& f,
 
5852
                              const ufc::cell& c) const
 
5853
  {
 
5854
    // Declare variables for result of evaluation.
 
5855
    double vals[1];
 
5856
    
 
5857
    // Declare variable for physical coordinates.
 
5858
    double y[2];
 
5859
    const double * const * x = c.coordinates;
 
5860
    switch (i)
 
5861
    {
 
5862
    case 0:
 
5863
      {
 
5864
        y[0] = x[0][0];
 
5865
      y[1] = x[0][1];
 
5866
      f.evaluate(vals, y, c);
 
5867
      return vals[0];
 
5868
        break;
 
5869
      }
 
5870
    case 1:
 
5871
      {
 
5872
        y[0] = x[1][0];
 
5873
      y[1] = x[1][1];
 
5874
      f.evaluate(vals, y, c);
 
5875
      return vals[0];
 
5876
        break;
 
5877
      }
 
5878
    case 2:
 
5879
      {
 
5880
        y[0] = x[2][0];
 
5881
      y[1] = x[2][1];
 
5882
      f.evaluate(vals, y, c);
 
5883
      return vals[0];
 
5884
        break;
 
5885
      }
 
5886
    }
 
5887
    
 
5888
    return 0.000000000000000;
 
5889
  }
 
5890
 
 
5891
  /// Evaluate linear functionals for all dofs on the function f
 
5892
  virtual void evaluate_dofs(double* values,
 
5893
                             const ufc::function& f,
 
5894
                             const ufc::cell& c) const
 
5895
  {
 
5896
    // Declare variables for result of evaluation.
 
5897
    double vals[1];
 
5898
    
 
5899
    // Declare variable for physical coordinates.
 
5900
    double y[2];
 
5901
    const double * const * x = c.coordinates;
 
5902
    y[0] = x[0][0];
 
5903
    y[1] = x[0][1];
 
5904
    f.evaluate(vals, y, c);
 
5905
    values[0] = vals[0];
 
5906
    y[0] = x[1][0];
 
5907
    y[1] = x[1][1];
 
5908
    f.evaluate(vals, y, c);
 
5909
    values[1] = vals[0];
 
5910
    y[0] = x[2][0];
 
5911
    y[1] = x[2][1];
 
5912
    f.evaluate(vals, y, c);
 
5913
    values[2] = vals[0];
 
5914
  }
 
5915
 
 
5916
  /// Interpolate vertex values from dof values
 
5917
  virtual void interpolate_vertex_values(double* vertex_values,
 
5918
                                         const double* dof_values,
 
5919
                                         const ufc::cell& c) const
 
5920
  {
 
5921
    // Evaluate function and change variables
 
5922
    vertex_values[0] = dof_values[0];
 
5923
    vertex_values[1] = dof_values[1];
 
5924
    vertex_values[2] = dof_values[2];
 
5925
  }
 
5926
 
 
5927
  /// Map coordinate xhat from reference cell to coordinate x in cell
 
5928
  virtual void map_from_reference_cell(double* x,
 
5929
                                       const double* xhat,
 
5930
                                       const ufc::cell& c)
 
5931
  {
 
5932
    throw std::runtime_error("map_from_reference_cell not yet implemented (introduced in UFC 2.0).");
 
5933
  }
 
5934
 
 
5935
  /// Map from coordinate x in cell to coordinate xhat in reference cell
 
5936
  virtual void map_to_reference_cell(double* xhat,
 
5937
                                     const double* x,
 
5938
                                     const ufc::cell& c)
 
5939
  {
 
5940
    throw std::runtime_error("map_to_reference_cell not yet implemented (introduced in UFC 2.0).");
 
5941
  }
 
5942
 
 
5943
  /// Return the number of sub elements (for a mixed element)
 
5944
  virtual unsigned int num_sub_elements() const
 
5945
  {
 
5946
    return 0;
 
5947
  }
 
5948
 
 
5949
  /// Create a new finite element for sub element i (for a mixed element)
 
5950
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
5951
  {
 
5952
    return 0;
 
5953
  }
 
5954
 
 
5955
  /// Create a new class instance
 
5956
  virtual ufc::finite_element* create() const
 
5957
  {
 
5958
    return new adaptivepoisson_finite_element_4();
 
5959
  }
 
5960
 
 
5961
};
 
5962
 
 
5963
/// This class defines the interface for a finite element.
 
5964
 
 
5965
class adaptivepoisson_finite_element_5: public ufc::finite_element
 
5966
{
 
5967
public:
 
5968
 
 
5969
  /// Constructor
 
5970
  adaptivepoisson_finite_element_5() : ufc::finite_element()
 
5971
  {
 
5972
    // Do nothing
 
5973
  }
 
5974
 
 
5975
  /// Destructor
 
5976
  virtual ~adaptivepoisson_finite_element_5()
 
5977
  {
 
5978
    // Do nothing
 
5979
  }
 
5980
 
 
5981
  /// Return a string identifying the finite element
 
5982
  virtual const char* signature() const
 
5983
  {
 
5984
    return "FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1)";
 
5985
  }
 
5986
 
 
5987
  /// Return the cell shape
 
5988
  virtual ufc::shape cell_shape() const
 
5989
  {
 
5990
    return ufc::triangle;
 
5991
  }
 
5992
 
 
5993
  /// Return the topological dimension of the cell shape
 
5994
  virtual unsigned int topological_dimension() const
 
5995
  {
 
5996
    return 2;
 
5997
  }
 
5998
 
 
5999
  /// Return the geometric dimension of the cell shape
 
6000
  virtual unsigned int geometric_dimension() const
 
6001
  {
 
6002
    return 2;
 
6003
  }
 
6004
 
 
6005
  /// Return the dimension of the finite element function space
 
6006
  virtual unsigned int space_dimension() const
 
6007
  {
 
6008
    return 3;
 
6009
  }
 
6010
 
 
6011
  /// Return the rank of the value space
 
6012
  virtual unsigned int value_rank() const
 
6013
  {
 
6014
    return 0;
 
6015
  }
 
6016
 
 
6017
  /// Return the dimension of the value space for axis i
 
6018
  virtual unsigned int value_dimension(unsigned int i) const
 
6019
  {
 
6020
    return 1;
 
6021
  }
 
6022
 
 
6023
  /// Evaluate basis function i at given point in cell
 
6024
  virtual void evaluate_basis(unsigned int i,
 
6025
                              double* values,
 
6026
                              const double* coordinates,
 
6027
                              const ufc::cell& c) const
 
6028
  {
 
6029
    // Extract vertex coordinates
 
6030
    const double * const * x = c.coordinates;
 
6031
    
 
6032
    // Compute Jacobian of affine map from reference cell
 
6033
    const double J_00 = x[1][0] - x[0][0];
 
6034
    const double J_01 = x[2][0] - x[0][0];
 
6035
    const double J_10 = x[1][1] - x[0][1];
 
6036
    const double J_11 = x[2][1] - x[0][1];
 
6037
    
 
6038
    // Compute determinant of Jacobian
 
6039
    double detJ = J_00*J_11 - J_01*J_10;
 
6040
    
 
6041
    // Compute inverse of Jacobian
 
6042
    
 
6043
    // Compute constants
 
6044
    const double C0 = x[1][0] + x[2][0];
 
6045
    const double C1 = x[1][1] + x[2][1];
 
6046
    
 
6047
    // Get coordinates and map to the reference (FIAT) element
 
6048
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
6049
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
6050
    
 
6051
    // Reset values.
 
6052
    *values = 0.000000000000000;
 
6053
    switch (i)
 
6054
    {
 
6055
    case 0:
 
6056
      {
 
6057
        
 
6058
      // Array of basisvalues.
 
6059
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
6060
      
 
6061
      // Declare helper variables.
 
6062
      unsigned int rr = 0;
 
6063
      unsigned int ss = 0;
 
6064
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
6065
      
 
6066
      // Compute basisvalues.
 
6067
      basisvalues[0] = 1.000000000000000;
 
6068
      basisvalues[1] = tmp0;
 
6069
      for (unsigned int r = 0; r < 1; r++)
 
6070
      {
 
6071
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
6072
        ss = r*(r + 1)/2;
 
6073
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
6074
      }// end loop over 'r'
 
6075
      for (unsigned int r = 0; r < 2; r++)
 
6076
      {
 
6077
        for (unsigned int s = 0; s < 2 - r; s++)
 
6078
        {
 
6079
          rr = (r + s)*(r + s + 1)/2 + s;
 
6080
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
6081
        }// end loop over 's'
 
6082
      }// end loop over 'r'
 
6083
      
 
6084
      // Table(s) of coefficients.
 
6085
      static const double coefficients0[3] = \
 
6086
      {0.471404520791032, -0.288675134594813, -0.166666666666667};
 
6087
      
 
6088
      // Compute value(s).
 
6089
      for (unsigned int r = 0; r < 3; r++)
 
6090
      {
 
6091
        *values += coefficients0[r]*basisvalues[r];
 
6092
      }// end loop over 'r'
 
6093
        break;
 
6094
      }
 
6095
    case 1:
 
6096
      {
 
6097
        
 
6098
      // Array of basisvalues.
 
6099
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
6100
      
 
6101
      // Declare helper variables.
 
6102
      unsigned int rr = 0;
 
6103
      unsigned int ss = 0;
 
6104
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
6105
      
 
6106
      // Compute basisvalues.
 
6107
      basisvalues[0] = 1.000000000000000;
 
6108
      basisvalues[1] = tmp0;
 
6109
      for (unsigned int r = 0; r < 1; r++)
 
6110
      {
 
6111
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
6112
        ss = r*(r + 1)/2;
 
6113
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
6114
      }// end loop over 'r'
 
6115
      for (unsigned int r = 0; r < 2; r++)
 
6116
      {
 
6117
        for (unsigned int s = 0; s < 2 - r; s++)
 
6118
        {
 
6119
          rr = (r + s)*(r + s + 1)/2 + s;
 
6120
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
6121
        }// end loop over 's'
 
6122
      }// end loop over 'r'
 
6123
      
 
6124
      // Table(s) of coefficients.
 
6125
      static const double coefficients0[3] = \
 
6126
      {0.471404520791032, 0.288675134594813, -0.166666666666667};
 
6127
      
 
6128
      // Compute value(s).
 
6129
      for (unsigned int r = 0; r < 3; r++)
 
6130
      {
 
6131
        *values += coefficients0[r]*basisvalues[r];
 
6132
      }// end loop over 'r'
 
6133
        break;
 
6134
      }
 
6135
    case 2:
 
6136
      {
 
6137
        
 
6138
      // Array of basisvalues.
 
6139
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
6140
      
 
6141
      // Declare helper variables.
 
6142
      unsigned int rr = 0;
 
6143
      unsigned int ss = 0;
 
6144
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
6145
      
 
6146
      // Compute basisvalues.
 
6147
      basisvalues[0] = 1.000000000000000;
 
6148
      basisvalues[1] = tmp0;
 
6149
      for (unsigned int r = 0; r < 1; r++)
 
6150
      {
 
6151
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
6152
        ss = r*(r + 1)/2;
 
6153
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
6154
      }// end loop over 'r'
 
6155
      for (unsigned int r = 0; r < 2; r++)
 
6156
      {
 
6157
        for (unsigned int s = 0; s < 2 - r; s++)
 
6158
        {
 
6159
          rr = (r + s)*(r + s + 1)/2 + s;
 
6160
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
6161
        }// end loop over 's'
 
6162
      }// end loop over 'r'
 
6163
      
 
6164
      // Table(s) of coefficients.
 
6165
      static const double coefficients0[3] = \
 
6166
      {0.471404520791032, 0.000000000000000, 0.333333333333333};
 
6167
      
 
6168
      // Compute value(s).
 
6169
      for (unsigned int r = 0; r < 3; r++)
 
6170
      {
 
6171
        *values += coefficients0[r]*basisvalues[r];
 
6172
      }// end loop over 'r'
 
6173
        break;
 
6174
      }
 
6175
    }
 
6176
    
 
6177
  }
 
6178
 
 
6179
  /// Evaluate all basis functions at given point in cell
 
6180
  virtual void evaluate_basis_all(double* values,
 
6181
                                  const double* coordinates,
 
6182
                                  const ufc::cell& c) const
 
6183
  {
 
6184
    // Helper variable to hold values of a single dof.
 
6185
    double dof_values = 0.000000000000000;
 
6186
    
 
6187
    // Loop dofs and call evaluate_basis.
 
6188
    for (unsigned int r = 0; r < 3; r++)
 
6189
    {
 
6190
      evaluate_basis(r, &dof_values, coordinates, c);
 
6191
      values[r] = dof_values;
 
6192
    }// end loop over 'r'
 
6193
  }
 
6194
 
 
6195
  /// Evaluate order n derivatives of basis function i at given point in cell
 
6196
  virtual void evaluate_basis_derivatives(unsigned int i,
 
6197
                                          unsigned int n,
 
6198
                                          double* values,
 
6199
                                          const double* coordinates,
 
6200
                                          const ufc::cell& c) const
 
6201
  {
 
6202
    // Extract vertex coordinates
 
6203
    const double * const * x = c.coordinates;
 
6204
    
 
6205
    // Compute Jacobian of affine map from reference cell
 
6206
    const double J_00 = x[1][0] - x[0][0];
 
6207
    const double J_01 = x[2][0] - x[0][0];
 
6208
    const double J_10 = x[1][1] - x[0][1];
 
6209
    const double J_11 = x[2][1] - x[0][1];
 
6210
    
 
6211
    // Compute determinant of Jacobian
 
6212
    double detJ = J_00*J_11 - J_01*J_10;
 
6213
    
 
6214
    // Compute inverse of Jacobian
 
6215
    const double K_00 =  J_11 / detJ;
 
6216
    const double K_01 = -J_01 / detJ;
 
6217
    const double K_10 = -J_10 / detJ;
 
6218
    const double K_11 =  J_00 / detJ;
 
6219
    
 
6220
    // Compute constants
 
6221
    const double C0 = x[1][0] + x[2][0];
 
6222
    const double C1 = x[1][1] + x[2][1];
 
6223
    
 
6224
    // Get coordinates and map to the reference (FIAT) element
 
6225
    double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
 
6226
    double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
 
6227
    
 
6228
    // Compute number of derivatives.
 
6229
    unsigned int num_derivatives = 1;
 
6230
    for (unsigned int r = 0; r < n; r++)
 
6231
    {
 
6232
      num_derivatives *= 2;
 
6233
    }// end loop over 'r'
 
6234
    
 
6235
    // Declare pointer to two dimensional array that holds combinations of derivatives and initialise
 
6236
    unsigned int **combinations = new unsigned int *[num_derivatives];
 
6237
    for (unsigned int row = 0; row < num_derivatives; row++)
 
6238
    {
 
6239
      combinations[row] = new unsigned int [n];
 
6240
      for (unsigned int col = 0; col < n; col++)
 
6241
        combinations[row][col] = 0;
 
6242
    }
 
6243
    
 
6244
    // Generate combinations of derivatives
 
6245
    for (unsigned int row = 1; row < num_derivatives; row++)
 
6246
    {
 
6247
      for (unsigned int num = 0; num < row; num++)
 
6248
      {
 
6249
        for (unsigned int col = n-1; col+1 > 0; col--)
 
6250
        {
 
6251
          if (combinations[row][col] + 1 > 1)
 
6252
            combinations[row][col] = 0;
 
6253
          else
 
6254
          {
 
6255
            combinations[row][col] += 1;
 
6256
            break;
 
6257
          }
 
6258
        }
 
6259
      }
 
6260
    }
 
6261
    
 
6262
    // Compute inverse of Jacobian
 
6263
    const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
 
6264
    
 
6265
    // Declare transformation matrix
 
6266
    // Declare pointer to two dimensional array and initialise
 
6267
    double **transform = new double *[num_derivatives];
 
6268
    
 
6269
    for (unsigned int j = 0; j < num_derivatives; j++)
 
6270
    {
 
6271
      transform[j] = new double [num_derivatives];
 
6272
      for (unsigned int k = 0; k < num_derivatives; k++)
 
6273
        transform[j][k] = 1;
 
6274
    }
 
6275
    
 
6276
    // Construct transformation matrix
 
6277
    for (unsigned int row = 0; row < num_derivatives; row++)
 
6278
    {
 
6279
      for (unsigned int col = 0; col < num_derivatives; col++)
 
6280
      {
 
6281
        for (unsigned int k = 0; k < n; k++)
 
6282
          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
 
6283
      }
 
6284
    }
 
6285
    
 
6286
    // Reset values. Assuming that values is always an array.
 
6287
    for (unsigned int r = 0; r < num_derivatives; r++)
 
6288
    {
 
6289
      values[r] = 0.000000000000000;
 
6290
    }// end loop over 'r'
 
6291
    
 
6292
    switch (i)
 
6293
    {
 
6294
    case 0:
 
6295
      {
 
6296
        
 
6297
      // Array of basisvalues.
 
6298
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
6299
      
 
6300
      // Declare helper variables.
 
6301
      unsigned int rr = 0;
 
6302
      unsigned int ss = 0;
 
6303
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
6304
      
 
6305
      // Compute basisvalues.
 
6306
      basisvalues[0] = 1.000000000000000;
 
6307
      basisvalues[1] = tmp0;
 
6308
      for (unsigned int r = 0; r < 1; r++)
 
6309
      {
 
6310
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
6311
        ss = r*(r + 1)/2;
 
6312
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
6313
      }// end loop over 'r'
 
6314
      for (unsigned int r = 0; r < 2; r++)
 
6315
      {
 
6316
        for (unsigned int s = 0; s < 2 - r; s++)
 
6317
        {
 
6318
          rr = (r + s)*(r + s + 1)/2 + s;
 
6319
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
6320
        }// end loop over 's'
 
6321
      }// end loop over 'r'
 
6322
      
 
6323
      // Table(s) of coefficients.
 
6324
      static const double coefficients0[3] = \
 
6325
      {0.471404520791032, -0.288675134594813, -0.166666666666667};
 
6326
      
 
6327
      // Tables of derivatives of the polynomial base (transpose).
 
6328
      static const double dmats0[3][3] = \
 
6329
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
6330
      {4.898979485566356, 0.000000000000000, 0.000000000000000},
 
6331
      {0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
6332
      
 
6333
      static const double dmats1[3][3] = \
 
6334
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
6335
      {2.449489742783178, 0.000000000000000, 0.000000000000000},
 
6336
      {4.242640687119285, 0.000000000000000, 0.000000000000000}};
 
6337
      
 
6338
      // Compute reference derivatives.
 
6339
      // Declare pointer to array of derivatives on FIAT element.
 
6340
      double *derivatives = new double[num_derivatives];
 
6341
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6342
      {
 
6343
        derivatives[r] = 0.000000000000000;
 
6344
      }// end loop over 'r'
 
6345
      
 
6346
      // Declare derivative matrix (of polynomial basis).
 
6347
      double dmats[3][3] = \
 
6348
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
6349
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
6350
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
6351
      
 
6352
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
6353
      double dmats_old[3][3] = \
 
6354
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
6355
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
6356
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
6357
      
 
6358
      // Loop possible derivatives.
 
6359
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6360
      {
 
6361
        // Resetting dmats values to compute next derivative.
 
6362
        for (unsigned int t = 0; t < 3; t++)
 
6363
        {
 
6364
          for (unsigned int u = 0; u < 3; u++)
 
6365
          {
 
6366
            dmats[t][u] = 0.000000000000000;
 
6367
            if (t == u)
 
6368
            {
 
6369
            dmats[t][u] = 1.000000000000000;
 
6370
            }
 
6371
            
 
6372
          }// end loop over 'u'
 
6373
        }// end loop over 't'
 
6374
        
 
6375
        // Looping derivative order to generate dmats.
 
6376
        for (unsigned int s = 0; s < n; s++)
 
6377
        {
 
6378
          // Updating dmats_old with new values and resetting dmats.
 
6379
          for (unsigned int t = 0; t < 3; t++)
 
6380
          {
 
6381
            for (unsigned int u = 0; u < 3; u++)
 
6382
            {
 
6383
              dmats_old[t][u] = dmats[t][u];
 
6384
              dmats[t][u] = 0.000000000000000;
 
6385
            }// end loop over 'u'
 
6386
          }// end loop over 't'
 
6387
          
 
6388
          // Update dmats using an inner product.
 
6389
          if (combinations[r][s] == 0)
 
6390
          {
 
6391
          for (unsigned int t = 0; t < 3; t++)
 
6392
          {
 
6393
            for (unsigned int u = 0; u < 3; u++)
 
6394
            {
 
6395
              for (unsigned int tu = 0; tu < 3; tu++)
 
6396
              {
 
6397
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
6398
              }// end loop over 'tu'
 
6399
            }// end loop over 'u'
 
6400
          }// end loop over 't'
 
6401
          }
 
6402
          
 
6403
          if (combinations[r][s] == 1)
 
6404
          {
 
6405
          for (unsigned int t = 0; t < 3; t++)
 
6406
          {
 
6407
            for (unsigned int u = 0; u < 3; u++)
 
6408
            {
 
6409
              for (unsigned int tu = 0; tu < 3; tu++)
 
6410
              {
 
6411
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
6412
              }// end loop over 'tu'
 
6413
            }// end loop over 'u'
 
6414
          }// end loop over 't'
 
6415
          }
 
6416
          
 
6417
        }// end loop over 's'
 
6418
        for (unsigned int s = 0; s < 3; s++)
 
6419
        {
 
6420
          for (unsigned int t = 0; t < 3; t++)
 
6421
          {
 
6422
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
6423
          }// end loop over 't'
 
6424
        }// end loop over 's'
 
6425
      }// end loop over 'r'
 
6426
      
 
6427
      // Transform derivatives back to physical element
 
6428
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6429
      {
 
6430
        for (unsigned int s = 0; s < num_derivatives; s++)
 
6431
        {
 
6432
          values[r] += transform[r][s]*derivatives[s];
 
6433
        }// end loop over 's'
 
6434
      }// end loop over 'r'
 
6435
      
 
6436
      // Delete pointer to array of derivatives on FIAT element
 
6437
      delete [] derivatives;
 
6438
      
 
6439
      // Delete pointer to array of combinations of derivatives and transform
 
6440
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6441
      {
 
6442
        delete [] combinations[r];
 
6443
      }// end loop over 'r'
 
6444
      delete [] combinations;
 
6445
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6446
      {
 
6447
        delete [] transform[r];
 
6448
      }// end loop over 'r'
 
6449
      delete [] transform;
 
6450
        break;
 
6451
      }
 
6452
    case 1:
 
6453
      {
 
6454
        
 
6455
      // Array of basisvalues.
 
6456
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
6457
      
 
6458
      // Declare helper variables.
 
6459
      unsigned int rr = 0;
 
6460
      unsigned int ss = 0;
 
6461
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
6462
      
 
6463
      // Compute basisvalues.
 
6464
      basisvalues[0] = 1.000000000000000;
 
6465
      basisvalues[1] = tmp0;
 
6466
      for (unsigned int r = 0; r < 1; r++)
 
6467
      {
 
6468
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
6469
        ss = r*(r + 1)/2;
 
6470
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
6471
      }// end loop over 'r'
 
6472
      for (unsigned int r = 0; r < 2; r++)
 
6473
      {
 
6474
        for (unsigned int s = 0; s < 2 - r; s++)
 
6475
        {
 
6476
          rr = (r + s)*(r + s + 1)/2 + s;
 
6477
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
6478
        }// end loop over 's'
 
6479
      }// end loop over 'r'
 
6480
      
 
6481
      // Table(s) of coefficients.
 
6482
      static const double coefficients0[3] = \
 
6483
      {0.471404520791032, 0.288675134594813, -0.166666666666667};
 
6484
      
 
6485
      // Tables of derivatives of the polynomial base (transpose).
 
6486
      static const double dmats0[3][3] = \
 
6487
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
6488
      {4.898979485566356, 0.000000000000000, 0.000000000000000},
 
6489
      {0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
6490
      
 
6491
      static const double dmats1[3][3] = \
 
6492
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
6493
      {2.449489742783178, 0.000000000000000, 0.000000000000000},
 
6494
      {4.242640687119285, 0.000000000000000, 0.000000000000000}};
 
6495
      
 
6496
      // Compute reference derivatives.
 
6497
      // Declare pointer to array of derivatives on FIAT element.
 
6498
      double *derivatives = new double[num_derivatives];
 
6499
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6500
      {
 
6501
        derivatives[r] = 0.000000000000000;
 
6502
      }// end loop over 'r'
 
6503
      
 
6504
      // Declare derivative matrix (of polynomial basis).
 
6505
      double dmats[3][3] = \
 
6506
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
6507
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
6508
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
6509
      
 
6510
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
6511
      double dmats_old[3][3] = \
 
6512
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
6513
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
6514
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
6515
      
 
6516
      // Loop possible derivatives.
 
6517
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6518
      {
 
6519
        // Resetting dmats values to compute next derivative.
 
6520
        for (unsigned int t = 0; t < 3; t++)
 
6521
        {
 
6522
          for (unsigned int u = 0; u < 3; u++)
 
6523
          {
 
6524
            dmats[t][u] = 0.000000000000000;
 
6525
            if (t == u)
 
6526
            {
 
6527
            dmats[t][u] = 1.000000000000000;
 
6528
            }
 
6529
            
 
6530
          }// end loop over 'u'
 
6531
        }// end loop over 't'
 
6532
        
 
6533
        // Looping derivative order to generate dmats.
 
6534
        for (unsigned int s = 0; s < n; s++)
 
6535
        {
 
6536
          // Updating dmats_old with new values and resetting dmats.
 
6537
          for (unsigned int t = 0; t < 3; t++)
 
6538
          {
 
6539
            for (unsigned int u = 0; u < 3; u++)
 
6540
            {
 
6541
              dmats_old[t][u] = dmats[t][u];
 
6542
              dmats[t][u] = 0.000000000000000;
 
6543
            }// end loop over 'u'
 
6544
          }// end loop over 't'
 
6545
          
 
6546
          // Update dmats using an inner product.
 
6547
          if (combinations[r][s] == 0)
 
6548
          {
 
6549
          for (unsigned int t = 0; t < 3; t++)
 
6550
          {
 
6551
            for (unsigned int u = 0; u < 3; u++)
 
6552
            {
 
6553
              for (unsigned int tu = 0; tu < 3; tu++)
 
6554
              {
 
6555
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
6556
              }// end loop over 'tu'
 
6557
            }// end loop over 'u'
 
6558
          }// end loop over 't'
 
6559
          }
 
6560
          
 
6561
          if (combinations[r][s] == 1)
 
6562
          {
 
6563
          for (unsigned int t = 0; t < 3; t++)
 
6564
          {
 
6565
            for (unsigned int u = 0; u < 3; u++)
 
6566
            {
 
6567
              for (unsigned int tu = 0; tu < 3; tu++)
 
6568
              {
 
6569
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
6570
              }// end loop over 'tu'
 
6571
            }// end loop over 'u'
 
6572
          }// end loop over 't'
 
6573
          }
 
6574
          
 
6575
        }// end loop over 's'
 
6576
        for (unsigned int s = 0; s < 3; s++)
 
6577
        {
 
6578
          for (unsigned int t = 0; t < 3; t++)
 
6579
          {
 
6580
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
6581
          }// end loop over 't'
 
6582
        }// end loop over 's'
 
6583
      }// end loop over 'r'
 
6584
      
 
6585
      // Transform derivatives back to physical element
 
6586
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6587
      {
 
6588
        for (unsigned int s = 0; s < num_derivatives; s++)
 
6589
        {
 
6590
          values[r] += transform[r][s]*derivatives[s];
 
6591
        }// end loop over 's'
 
6592
      }// end loop over 'r'
 
6593
      
 
6594
      // Delete pointer to array of derivatives on FIAT element
 
6595
      delete [] derivatives;
 
6596
      
 
6597
      // Delete pointer to array of combinations of derivatives and transform
 
6598
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6599
      {
 
6600
        delete [] combinations[r];
 
6601
      }// end loop over 'r'
 
6602
      delete [] combinations;
 
6603
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6604
      {
 
6605
        delete [] transform[r];
 
6606
      }// end loop over 'r'
 
6607
      delete [] transform;
 
6608
        break;
 
6609
      }
 
6610
    case 2:
 
6611
      {
 
6612
        
 
6613
      // Array of basisvalues.
 
6614
      double basisvalues[3] = {0.000000000000000, 0.000000000000000, 0.000000000000000};
 
6615
      
 
6616
      // Declare helper variables.
 
6617
      unsigned int rr = 0;
 
6618
      unsigned int ss = 0;
 
6619
      double tmp0 = (1.000000000000000 + Y + 2.000000000000000*X)/2.000000000000000;
 
6620
      
 
6621
      // Compute basisvalues.
 
6622
      basisvalues[0] = 1.000000000000000;
 
6623
      basisvalues[1] = tmp0;
 
6624
      for (unsigned int r = 0; r < 1; r++)
 
6625
      {
 
6626
        rr = (r + 1)*(r + 1 + 1)/2 + 1;
 
6627
        ss = r*(r + 1)/2;
 
6628
        basisvalues[rr] = basisvalues[ss]*(0.500000000000000 + r + Y*(1.500000000000000 + r));
 
6629
      }// end loop over 'r'
 
6630
      for (unsigned int r = 0; r < 2; r++)
 
6631
      {
 
6632
        for (unsigned int s = 0; s < 2 - r; s++)
 
6633
        {
 
6634
          rr = (r + s)*(r + s + 1)/2 + s;
 
6635
          basisvalues[rr] *= std::sqrt((0.500000000000000 + r)*(1.000000000000000 + r + s));
 
6636
        }// end loop over 's'
 
6637
      }// end loop over 'r'
 
6638
      
 
6639
      // Table(s) of coefficients.
 
6640
      static const double coefficients0[3] = \
 
6641
      {0.471404520791032, 0.000000000000000, 0.333333333333333};
 
6642
      
 
6643
      // Tables of derivatives of the polynomial base (transpose).
 
6644
      static const double dmats0[3][3] = \
 
6645
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
6646
      {4.898979485566356, 0.000000000000000, 0.000000000000000},
 
6647
      {0.000000000000000, 0.000000000000000, 0.000000000000000}};
 
6648
      
 
6649
      static const double dmats1[3][3] = \
 
6650
      {{0.000000000000000, 0.000000000000000, 0.000000000000000},
 
6651
      {2.449489742783178, 0.000000000000000, 0.000000000000000},
 
6652
      {4.242640687119285, 0.000000000000000, 0.000000000000000}};
 
6653
      
 
6654
      // Compute reference derivatives.
 
6655
      // Declare pointer to array of derivatives on FIAT element.
 
6656
      double *derivatives = new double[num_derivatives];
 
6657
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6658
      {
 
6659
        derivatives[r] = 0.000000000000000;
 
6660
      }// end loop over 'r'
 
6661
      
 
6662
      // Declare derivative matrix (of polynomial basis).
 
6663
      double dmats[3][3] = \
 
6664
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
6665
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
6666
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
6667
      
 
6668
      // Declare (auxiliary) derivative matrix (of polynomial basis).
 
6669
      double dmats_old[3][3] = \
 
6670
      {{1.000000000000000, 0.000000000000000, 0.000000000000000},
 
6671
      {0.000000000000000, 1.000000000000000, 0.000000000000000},
 
6672
      {0.000000000000000, 0.000000000000000, 1.000000000000000}};
 
6673
      
 
6674
      // Loop possible derivatives.
 
6675
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6676
      {
 
6677
        // Resetting dmats values to compute next derivative.
 
6678
        for (unsigned int t = 0; t < 3; t++)
 
6679
        {
 
6680
          for (unsigned int u = 0; u < 3; u++)
 
6681
          {
 
6682
            dmats[t][u] = 0.000000000000000;
 
6683
            if (t == u)
 
6684
            {
 
6685
            dmats[t][u] = 1.000000000000000;
 
6686
            }
 
6687
            
 
6688
          }// end loop over 'u'
 
6689
        }// end loop over 't'
 
6690
        
 
6691
        // Looping derivative order to generate dmats.
 
6692
        for (unsigned int s = 0; s < n; s++)
 
6693
        {
 
6694
          // Updating dmats_old with new values and resetting dmats.
 
6695
          for (unsigned int t = 0; t < 3; t++)
 
6696
          {
 
6697
            for (unsigned int u = 0; u < 3; u++)
 
6698
            {
 
6699
              dmats_old[t][u] = dmats[t][u];
 
6700
              dmats[t][u] = 0.000000000000000;
 
6701
            }// end loop over 'u'
 
6702
          }// end loop over 't'
 
6703
          
 
6704
          // Update dmats using an inner product.
 
6705
          if (combinations[r][s] == 0)
 
6706
          {
 
6707
          for (unsigned int t = 0; t < 3; t++)
 
6708
          {
 
6709
            for (unsigned int u = 0; u < 3; u++)
 
6710
            {
 
6711
              for (unsigned int tu = 0; tu < 3; tu++)
 
6712
              {
 
6713
                dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
 
6714
              }// end loop over 'tu'
 
6715
            }// end loop over 'u'
 
6716
          }// end loop over 't'
 
6717
          }
 
6718
          
 
6719
          if (combinations[r][s] == 1)
 
6720
          {
 
6721
          for (unsigned int t = 0; t < 3; t++)
 
6722
          {
 
6723
            for (unsigned int u = 0; u < 3; u++)
 
6724
            {
 
6725
              for (unsigned int tu = 0; tu < 3; tu++)
 
6726
              {
 
6727
                dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
 
6728
              }// end loop over 'tu'
 
6729
            }// end loop over 'u'
 
6730
          }// end loop over 't'
 
6731
          }
 
6732
          
 
6733
        }// end loop over 's'
 
6734
        for (unsigned int s = 0; s < 3; s++)
 
6735
        {
 
6736
          for (unsigned int t = 0; t < 3; t++)
 
6737
          {
 
6738
            derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
 
6739
          }// end loop over 't'
 
6740
        }// end loop over 's'
 
6741
      }// end loop over 'r'
 
6742
      
 
6743
      // Transform derivatives back to physical element
 
6744
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6745
      {
 
6746
        for (unsigned int s = 0; s < num_derivatives; s++)
 
6747
        {
 
6748
          values[r] += transform[r][s]*derivatives[s];
 
6749
        }// end loop over 's'
 
6750
      }// end loop over 'r'
 
6751
      
 
6752
      // Delete pointer to array of derivatives on FIAT element
 
6753
      delete [] derivatives;
 
6754
      
 
6755
      // Delete pointer to array of combinations of derivatives and transform
 
6756
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6757
      {
 
6758
        delete [] combinations[r];
 
6759
      }// end loop over 'r'
 
6760
      delete [] combinations;
 
6761
      for (unsigned int r = 0; r < num_derivatives; r++)
 
6762
      {
 
6763
        delete [] transform[r];
 
6764
      }// end loop over 'r'
 
6765
      delete [] transform;
 
6766
        break;
 
6767
      }
 
6768
    }
 
6769
    
 
6770
  }
 
6771
 
 
6772
  /// Evaluate order n derivatives of all basis functions at given point in cell
 
6773
  virtual void evaluate_basis_derivatives_all(unsigned int n,
 
6774
                                              double* values,
 
6775
                                              const double* coordinates,
 
6776
                                              const ufc::cell& c) const
 
6777
  {
 
6778
    // Compute number of derivatives.
 
6779
    unsigned int num_derivatives = 1;
 
6780
    for (unsigned int r = 0; r < n; r++)
 
6781
    {
 
6782
      num_derivatives *= 2;
 
6783
    }// end loop over 'r'
 
6784
    
 
6785
    // Helper variable to hold values of a single dof.
 
6786
    double *dof_values = new double[num_derivatives];
 
6787
    for (unsigned int r = 0; r < num_derivatives; r++)
 
6788
    {
 
6789
      dof_values[r] = 0.000000000000000;
 
6790
    }// end loop over 'r'
 
6791
    
 
6792
    // Loop dofs and call evaluate_basis_derivatives.
 
6793
    for (unsigned int r = 0; r < 3; r++)
 
6794
    {
 
6795
      evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
 
6796
      for (unsigned int s = 0; s < num_derivatives; s++)
 
6797
      {
 
6798
        values[r*num_derivatives + s] = dof_values[s];
 
6799
      }// end loop over 's'
 
6800
    }// end loop over 'r'
 
6801
    
 
6802
    // Delete pointer.
 
6803
    delete [] dof_values;
 
6804
  }
 
6805
 
 
6806
  /// Evaluate linear functional for dof i on the function f
 
6807
  virtual double evaluate_dof(unsigned int i,
 
6808
                              const ufc::function& f,
 
6809
                              const ufc::cell& c) const
 
6810
  {
 
6811
    // Declare variables for result of evaluation.
 
6812
    double vals[1];
 
6813
    
 
6814
    // Declare variable for physical coordinates.
 
6815
    double y[2];
 
6816
    const double * const * x = c.coordinates;
 
6817
    switch (i)
 
6818
    {
 
6819
    case 0:
 
6820
      {
 
6821
        y[0] = x[0][0];
 
6822
      y[1] = x[0][1];
 
6823
      f.evaluate(vals, y, c);
 
6824
      return vals[0];
 
6825
        break;
 
6826
      }
 
6827
    case 1:
 
6828
      {
 
6829
        y[0] = x[1][0];
 
6830
      y[1] = x[1][1];
 
6831
      f.evaluate(vals, y, c);
 
6832
      return vals[0];
 
6833
        break;
 
6834
      }
 
6835
    case 2:
 
6836
      {
 
6837
        y[0] = x[2][0];
 
6838
      y[1] = x[2][1];
 
6839
      f.evaluate(vals, y, c);
 
6840
      return vals[0];
 
6841
        break;
 
6842
      }
 
6843
    }
 
6844
    
 
6845
    return 0.000000000000000;
 
6846
  }
 
6847
 
 
6848
  /// Evaluate linear functionals for all dofs on the function f
 
6849
  virtual void evaluate_dofs(double* values,
 
6850
                             const ufc::function& f,
 
6851
                             const ufc::cell& c) const
 
6852
  {
 
6853
    // Declare variables for result of evaluation.
 
6854
    double vals[1];
 
6855
    
 
6856
    // Declare variable for physical coordinates.
 
6857
    double y[2];
 
6858
    const double * const * x = c.coordinates;
 
6859
    y[0] = x[0][0];
 
6860
    y[1] = x[0][1];
 
6861
    f.evaluate(vals, y, c);
 
6862
    values[0] = vals[0];
 
6863
    y[0] = x[1][0];
 
6864
    y[1] = x[1][1];
 
6865
    f.evaluate(vals, y, c);
 
6866
    values[1] = vals[0];
 
6867
    y[0] = x[2][0];
 
6868
    y[1] = x[2][1];
 
6869
    f.evaluate(vals, y, c);
 
6870
    values[2] = vals[0];
 
6871
  }
 
6872
 
 
6873
  /// Interpolate vertex values from dof values
 
6874
  virtual void interpolate_vertex_values(double* vertex_values,
 
6875
                                         const double* dof_values,
 
6876
                                         const ufc::cell& c) const
 
6877
  {
 
6878
    // Evaluate function and change variables
 
6879
    vertex_values[0] = dof_values[0];
 
6880
    vertex_values[1] = dof_values[1];
 
6881
    vertex_values[2] = dof_values[2];
 
6882
  }
 
6883
 
 
6884
  /// Map coordinate xhat from reference cell to coordinate x in cell
 
6885
  virtual void map_from_reference_cell(double* x,
 
6886
                                       const double* xhat,
 
6887
                                       const ufc::cell& c)
 
6888
  {
 
6889
    throw std::runtime_error("map_from_reference_cell not yet implemented (introduced in UFC 2.0).");
 
6890
  }
 
6891
 
 
6892
  /// Map from coordinate x in cell to coordinate xhat in reference cell
 
6893
  virtual void map_to_reference_cell(double* xhat,
 
6894
                                     const double* x,
 
6895
                                     const ufc::cell& c)
 
6896
  {
 
6897
    throw std::runtime_error("map_to_reference_cell not yet implemented (introduced in UFC 2.0).");
 
6898
  }
 
6899
 
 
6900
  /// Return the number of sub elements (for a mixed element)
 
6901
  virtual unsigned int num_sub_elements() const
 
6902
  {
 
6903
    return 0;
 
6904
  }
 
6905
 
 
6906
  /// Create a new finite element for sub element i (for a mixed element)
 
6907
  virtual ufc::finite_element* create_sub_element(unsigned int i) const
 
6908
  {
 
6909
    return 0;
 
6910
  }
 
6911
 
 
6912
  /// Create a new class instance
 
6913
  virtual ufc::finite_element* create() const
 
6914
  {
 
6915
    return new adaptivepoisson_finite_element_5();
 
6916
  }
 
6917
 
 
6918
};
 
6919
 
 
6920
/// This class defines the interface for a local-to-global mapping of
 
6921
/// degrees of freedom (dofs).
 
6922
 
 
6923
class adaptivepoisson_dofmap_0: public ufc::dofmap
 
6924
{
 
6925
private:
 
6926
 
 
6927
  unsigned int _global_dimension;
 
6928
public:
 
6929
 
 
6930
  /// Constructor
 
6931
  adaptivepoisson_dofmap_0() : ufc::dofmap()
 
6932
  {
 
6933
    _global_dimension = 0;
 
6934
  }
 
6935
 
 
6936
  /// Destructor
 
6937
  virtual ~adaptivepoisson_dofmap_0()
 
6938
  {
 
6939
    // Do nothing
 
6940
  }
 
6941
 
 
6942
  /// Return a string identifying the dofmap
 
6943
  virtual const char* signature() const
 
6944
  {
 
6945
    return "FFC dofmap for FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0)";
 
6946
  }
 
6947
 
 
6948
  /// Return true iff mesh entities of topological dimension d are needed
 
6949
  virtual bool needs_mesh_entities(unsigned int d) const
 
6950
  {
 
6951
    switch (d)
 
6952
    {
 
6953
    case 0:
 
6954
      {
 
6955
        return false;
 
6956
        break;
 
6957
      }
 
6958
    case 1:
 
6959
      {
 
6960
        return false;
 
6961
        break;
 
6962
      }
 
6963
    case 2:
 
6964
      {
 
6965
        return true;
 
6966
        break;
 
6967
      }
 
6968
    }
 
6969
    
 
6970
    return false;
 
6971
  }
 
6972
 
 
6973
  /// Initialize dofmap for mesh (return true iff init_cell() is needed)
 
6974
  virtual bool init_mesh(const ufc::mesh& m)
 
6975
  {
 
6976
    _global_dimension = m.num_entities[2];
 
6977
    return false;
 
6978
  }
 
6979
 
 
6980
  /// Initialize dofmap for given cell
 
6981
  virtual void init_cell(const ufc::mesh& m,
 
6982
                         const ufc::cell& c)
 
6983
  {
 
6984
    // Do nothing
 
6985
  }
 
6986
 
 
6987
  /// Finish initialization of dofmap for cells
 
6988
  virtual void init_cell_finalize()
 
6989
  {
 
6990
    // Do nothing
 
6991
  }
 
6992
 
 
6993
  /// Return the topological dimension of the associated cell shape
 
6994
  virtual unsigned int topological_dimension() const
 
6995
  {
 
6996
    return 2;
 
6997
  }
 
6998
 
 
6999
  /// Return the geometric dimension of the associated cell shape
 
7000
  virtual unsigned int geometric_dimension() const
 
7001
  {
 
7002
    return 2;
 
7003
  }
 
7004
 
 
7005
  /// Return the dimension of the global finite element function space
 
7006
  virtual unsigned int global_dimension() const
 
7007
  {
 
7008
    return _global_dimension;
 
7009
  }
 
7010
 
 
7011
  /// Return the dimension of the local finite element function space for a cell
 
7012
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
7013
  {
 
7014
    return 1;
 
7015
  }
 
7016
 
 
7017
  /// Return the maximum dimension of the local finite element function space
 
7018
  virtual unsigned int max_local_dimension() const
 
7019
  {
 
7020
    return 1;
 
7021
  }
 
7022
 
 
7023
  /// Return the number of dofs on each cell facet
 
7024
  virtual unsigned int num_facet_dofs() const
 
7025
  {
 
7026
    return 0;
 
7027
  }
 
7028
 
 
7029
  /// Return the number of dofs associated with each cell entity of dimension d
 
7030
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
7031
  {
 
7032
    switch (d)
 
7033
    {
 
7034
    case 0:
 
7035
      {
 
7036
        return 0;
 
7037
        break;
 
7038
      }
 
7039
    case 1:
 
7040
      {
 
7041
        return 0;
 
7042
        break;
 
7043
      }
 
7044
    case 2:
 
7045
      {
 
7046
        return 1;
 
7047
        break;
 
7048
      }
 
7049
    }
 
7050
    
 
7051
    return 0;
 
7052
  }
 
7053
 
 
7054
  /// Tabulate the local-to-global mapping of dofs on a cell
 
7055
  virtual void tabulate_dofs(unsigned int* dofs,
 
7056
                             const ufc::mesh& m,
 
7057
                             const ufc::cell& c) const
 
7058
  {
 
7059
    dofs[0] = c.entity_indices[2][0];
 
7060
  }
 
7061
 
 
7062
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
7063
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
7064
                                   unsigned int facet) const
 
7065
  {
 
7066
    switch (facet)
 
7067
    {
 
7068
    case 0:
 
7069
      {
 
7070
        
 
7071
        break;
 
7072
      }
 
7073
    case 1:
 
7074
      {
 
7075
        
 
7076
        break;
 
7077
      }
 
7078
    case 2:
 
7079
      {
 
7080
        
 
7081
        break;
 
7082
      }
 
7083
    }
 
7084
    
 
7085
  }
 
7086
 
 
7087
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
7088
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
7089
                                    unsigned int d, unsigned int i) const
 
7090
  {
 
7091
    if (d > 2)
 
7092
    {
 
7093
    throw std::runtime_error("d is larger than dimension (2)");
 
7094
    }
 
7095
    
 
7096
    switch (d)
 
7097
    {
 
7098
    case 0:
 
7099
      {
 
7100
        
 
7101
        break;
 
7102
      }
 
7103
    case 1:
 
7104
      {
 
7105
        
 
7106
        break;
 
7107
      }
 
7108
    case 2:
 
7109
      {
 
7110
        if (i > 0)
 
7111
      {
 
7112
      throw std::runtime_error("i is larger than number of entities (0)");
 
7113
      }
 
7114
      
 
7115
      dofs[0] = 0;
 
7116
        break;
 
7117
      }
 
7118
    }
 
7119
    
 
7120
  }
 
7121
 
 
7122
  /// Tabulate the coordinates of all dofs on a cell
 
7123
  virtual void tabulate_coordinates(double** coordinates,
 
7124
                                    const ufc::cell& c) const
 
7125
  {
 
7126
    const double * const * x = c.coordinates;
 
7127
    
 
7128
    coordinates[0][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
 
7129
    coordinates[0][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
 
7130
  }
 
7131
 
 
7132
  /// Return the number of sub dofmaps (for a mixed element)
 
7133
  virtual unsigned int num_sub_dofmaps() const
 
7134
  {
 
7135
    return 0;
 
7136
  }
 
7137
 
 
7138
  /// Create a new dofmap for sub dofmap i (for a mixed element)
 
7139
  virtual ufc::dofmap* create_sub_dofmap(unsigned int i) const
 
7140
  {
 
7141
    return 0;
 
7142
  }
 
7143
 
 
7144
  /// Create a new class instance
 
7145
  virtual ufc::dofmap* create() const
 
7146
  {
 
7147
    return new adaptivepoisson_dofmap_0();
 
7148
  }
 
7149
 
 
7150
};
 
7151
 
 
7152
/// This class defines the interface for a local-to-global mapping of
 
7153
/// degrees of freedom (dofs).
 
7154
 
 
7155
class adaptivepoisson_dofmap_1: public ufc::dofmap
 
7156
{
 
7157
private:
 
7158
 
 
7159
  unsigned int _global_dimension;
 
7160
public:
 
7161
 
 
7162
  /// Constructor
 
7163
  adaptivepoisson_dofmap_1() : ufc::dofmap()
 
7164
  {
 
7165
    _global_dimension = 0;
 
7166
  }
 
7167
 
 
7168
  /// Destructor
 
7169
  virtual ~adaptivepoisson_dofmap_1()
 
7170
  {
 
7171
    // Do nothing
 
7172
  }
 
7173
 
 
7174
  /// Return a string identifying the dofmap
 
7175
  virtual const char* signature() const
 
7176
  {
 
7177
    return "FFC dofmap for FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2)";
 
7178
  }
 
7179
 
 
7180
  /// Return true iff mesh entities of topological dimension d are needed
 
7181
  virtual bool needs_mesh_entities(unsigned int d) const
 
7182
  {
 
7183
    switch (d)
 
7184
    {
 
7185
    case 0:
 
7186
      {
 
7187
        return true;
 
7188
        break;
 
7189
      }
 
7190
    case 1:
 
7191
      {
 
7192
        return true;
 
7193
        break;
 
7194
      }
 
7195
    case 2:
 
7196
      {
 
7197
        return false;
 
7198
        break;
 
7199
      }
 
7200
    }
 
7201
    
 
7202
    return false;
 
7203
  }
 
7204
 
 
7205
  /// Initialize dofmap for mesh (return true iff init_cell() is needed)
 
7206
  virtual bool init_mesh(const ufc::mesh& m)
 
7207
  {
 
7208
    _global_dimension = m.num_entities[0] + m.num_entities[1];
 
7209
    return false;
 
7210
  }
 
7211
 
 
7212
  /// Initialize dofmap for given cell
 
7213
  virtual void init_cell(const ufc::mesh& m,
 
7214
                         const ufc::cell& c)
 
7215
  {
 
7216
    // Do nothing
 
7217
  }
 
7218
 
 
7219
  /// Finish initialization of dofmap for cells
 
7220
  virtual void init_cell_finalize()
 
7221
  {
 
7222
    // Do nothing
 
7223
  }
 
7224
 
 
7225
  /// Return the topological dimension of the associated cell shape
 
7226
  virtual unsigned int topological_dimension() const
 
7227
  {
 
7228
    return 2;
 
7229
  }
 
7230
 
 
7231
  /// Return the geometric dimension of the associated cell shape
 
7232
  virtual unsigned int geometric_dimension() const
 
7233
  {
 
7234
    return 2;
 
7235
  }
 
7236
 
 
7237
  /// Return the dimension of the global finite element function space
 
7238
  virtual unsigned int global_dimension() const
 
7239
  {
 
7240
    return _global_dimension;
 
7241
  }
 
7242
 
 
7243
  /// Return the dimension of the local finite element function space for a cell
 
7244
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
7245
  {
 
7246
    return 6;
 
7247
  }
 
7248
 
 
7249
  /// Return the maximum dimension of the local finite element function space
 
7250
  virtual unsigned int max_local_dimension() const
 
7251
  {
 
7252
    return 6;
 
7253
  }
 
7254
 
 
7255
  /// Return the number of dofs on each cell facet
 
7256
  virtual unsigned int num_facet_dofs() const
 
7257
  {
 
7258
    return 3;
 
7259
  }
 
7260
 
 
7261
  /// Return the number of dofs associated with each cell entity of dimension d
 
7262
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
7263
  {
 
7264
    switch (d)
 
7265
    {
 
7266
    case 0:
 
7267
      {
 
7268
        return 1;
 
7269
        break;
 
7270
      }
 
7271
    case 1:
 
7272
      {
 
7273
        return 1;
 
7274
        break;
 
7275
      }
 
7276
    case 2:
 
7277
      {
 
7278
        return 0;
 
7279
        break;
 
7280
      }
 
7281
    }
 
7282
    
 
7283
    return 0;
 
7284
  }
 
7285
 
 
7286
  /// Tabulate the local-to-global mapping of dofs on a cell
 
7287
  virtual void tabulate_dofs(unsigned int* dofs,
 
7288
                             const ufc::mesh& m,
 
7289
                             const ufc::cell& c) const
 
7290
  {
 
7291
    unsigned int offset = 0;
 
7292
    dofs[0] = offset + c.entity_indices[0][0];
 
7293
    dofs[1] = offset + c.entity_indices[0][1];
 
7294
    dofs[2] = offset + c.entity_indices[0][2];
 
7295
    offset += m.num_entities[0];
 
7296
    dofs[3] = offset + c.entity_indices[1][0];
 
7297
    dofs[4] = offset + c.entity_indices[1][1];
 
7298
    dofs[5] = offset + c.entity_indices[1][2];
 
7299
    offset += m.num_entities[1];
 
7300
  }
 
7301
 
 
7302
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
7303
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
7304
                                   unsigned int facet) const
 
7305
  {
 
7306
    switch (facet)
 
7307
    {
 
7308
    case 0:
 
7309
      {
 
7310
        dofs[0] = 1;
 
7311
      dofs[1] = 2;
 
7312
      dofs[2] = 3;
 
7313
        break;
 
7314
      }
 
7315
    case 1:
 
7316
      {
 
7317
        dofs[0] = 0;
 
7318
      dofs[1] = 2;
 
7319
      dofs[2] = 4;
 
7320
        break;
 
7321
      }
 
7322
    case 2:
 
7323
      {
 
7324
        dofs[0] = 0;
 
7325
      dofs[1] = 1;
 
7326
      dofs[2] = 5;
 
7327
        break;
 
7328
      }
 
7329
    }
 
7330
    
 
7331
  }
 
7332
 
 
7333
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
7334
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
7335
                                    unsigned int d, unsigned int i) const
 
7336
  {
 
7337
    if (d > 2)
 
7338
    {
 
7339
    throw std::runtime_error("d is larger than dimension (2)");
 
7340
    }
 
7341
    
 
7342
    switch (d)
 
7343
    {
 
7344
    case 0:
 
7345
      {
 
7346
        if (i > 2)
 
7347
      {
 
7348
      throw std::runtime_error("i is larger than number of entities (2)");
 
7349
      }
 
7350
      
 
7351
      switch (i)
 
7352
      {
 
7353
      case 0:
 
7354
        {
 
7355
          dofs[0] = 0;
 
7356
          break;
 
7357
        }
 
7358
      case 1:
 
7359
        {
 
7360
          dofs[0] = 1;
 
7361
          break;
 
7362
        }
 
7363
      case 2:
 
7364
        {
 
7365
          dofs[0] = 2;
 
7366
          break;
 
7367
        }
 
7368
      }
 
7369
      
 
7370
        break;
 
7371
      }
 
7372
    case 1:
 
7373
      {
 
7374
        if (i > 2)
 
7375
      {
 
7376
      throw std::runtime_error("i is larger than number of entities (2)");
 
7377
      }
 
7378
      
 
7379
      switch (i)
 
7380
      {
 
7381
      case 0:
 
7382
        {
 
7383
          dofs[0] = 3;
 
7384
          break;
 
7385
        }
 
7386
      case 1:
 
7387
        {
 
7388
          dofs[0] = 4;
 
7389
          break;
 
7390
        }
 
7391
      case 2:
 
7392
        {
 
7393
          dofs[0] = 5;
 
7394
          break;
 
7395
        }
 
7396
      }
 
7397
      
 
7398
        break;
 
7399
      }
 
7400
    case 2:
 
7401
      {
 
7402
        
 
7403
        break;
 
7404
      }
 
7405
    }
 
7406
    
 
7407
  }
 
7408
 
 
7409
  /// Tabulate the coordinates of all dofs on a cell
 
7410
  virtual void tabulate_coordinates(double** coordinates,
 
7411
                                    const ufc::cell& c) const
 
7412
  {
 
7413
    const double * const * x = c.coordinates;
 
7414
    
 
7415
    coordinates[0][0] = x[0][0];
 
7416
    coordinates[0][1] = x[0][1];
 
7417
    coordinates[1][0] = x[1][0];
 
7418
    coordinates[1][1] = x[1][1];
 
7419
    coordinates[2][0] = x[2][0];
 
7420
    coordinates[2][1] = x[2][1];
 
7421
    coordinates[3][0] = 0.500000000000000*x[1][0] + 0.500000000000000*x[2][0];
 
7422
    coordinates[3][1] = 0.500000000000000*x[1][1] + 0.500000000000000*x[2][1];
 
7423
    coordinates[4][0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[2][0];
 
7424
    coordinates[4][1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[2][1];
 
7425
    coordinates[5][0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[1][0];
 
7426
    coordinates[5][1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[1][1];
 
7427
  }
 
7428
 
 
7429
  /// Return the number of sub dofmaps (for a mixed element)
 
7430
  virtual unsigned int num_sub_dofmaps() const
 
7431
  {
 
7432
    return 0;
 
7433
  }
 
7434
 
 
7435
  /// Create a new dofmap for sub dofmap i (for a mixed element)
 
7436
  virtual ufc::dofmap* create_sub_dofmap(unsigned int i) const
 
7437
  {
 
7438
    return 0;
 
7439
  }
 
7440
 
 
7441
  /// Create a new class instance
 
7442
  virtual ufc::dofmap* create() const
 
7443
  {
 
7444
    return new adaptivepoisson_dofmap_1();
 
7445
  }
 
7446
 
 
7447
};
 
7448
 
 
7449
/// This class defines the interface for a local-to-global mapping of
 
7450
/// degrees of freedom (dofs).
 
7451
 
 
7452
class adaptivepoisson_dofmap_2: public ufc::dofmap
 
7453
{
 
7454
private:
 
7455
 
 
7456
  unsigned int _global_dimension;
 
7457
public:
 
7458
 
 
7459
  /// Constructor
 
7460
  adaptivepoisson_dofmap_2() : ufc::dofmap()
 
7461
  {
 
7462
    _global_dimension = 0;
 
7463
  }
 
7464
 
 
7465
  /// Destructor
 
7466
  virtual ~adaptivepoisson_dofmap_2()
 
7467
  {
 
7468
    // Do nothing
 
7469
  }
 
7470
 
 
7471
  /// Return a string identifying the dofmap
 
7472
  virtual const char* signature() const
 
7473
  {
 
7474
    return "FFC dofmap for FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2)";
 
7475
  }
 
7476
 
 
7477
  /// Return true iff mesh entities of topological dimension d are needed
 
7478
  virtual bool needs_mesh_entities(unsigned int d) const
 
7479
  {
 
7480
    switch (d)
 
7481
    {
 
7482
    case 0:
 
7483
      {
 
7484
        return false;
 
7485
        break;
 
7486
      }
 
7487
    case 1:
 
7488
      {
 
7489
        return false;
 
7490
        break;
 
7491
      }
 
7492
    case 2:
 
7493
      {
 
7494
        return true;
 
7495
        break;
 
7496
      }
 
7497
    }
 
7498
    
 
7499
    return false;
 
7500
  }
 
7501
 
 
7502
  /// Initialize dofmap for mesh (return true iff init_cell() is needed)
 
7503
  virtual bool init_mesh(const ufc::mesh& m)
 
7504
  {
 
7505
    _global_dimension = 6.000000000000000*m.num_entities[2];
 
7506
    return false;
 
7507
  }
 
7508
 
 
7509
  /// Initialize dofmap for given cell
 
7510
  virtual void init_cell(const ufc::mesh& m,
 
7511
                         const ufc::cell& c)
 
7512
  {
 
7513
    // Do nothing
 
7514
  }
 
7515
 
 
7516
  /// Finish initialization of dofmap for cells
 
7517
  virtual void init_cell_finalize()
 
7518
  {
 
7519
    // Do nothing
 
7520
  }
 
7521
 
 
7522
  /// Return the topological dimension of the associated cell shape
 
7523
  virtual unsigned int topological_dimension() const
 
7524
  {
 
7525
    return 2;
 
7526
  }
 
7527
 
 
7528
  /// Return the geometric dimension of the associated cell shape
 
7529
  virtual unsigned int geometric_dimension() const
 
7530
  {
 
7531
    return 2;
 
7532
  }
 
7533
 
 
7534
  /// Return the dimension of the global finite element function space
 
7535
  virtual unsigned int global_dimension() const
 
7536
  {
 
7537
    return _global_dimension;
 
7538
  }
 
7539
 
 
7540
  /// Return the dimension of the local finite element function space for a cell
 
7541
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
7542
  {
 
7543
    return 6;
 
7544
  }
 
7545
 
 
7546
  /// Return the maximum dimension of the local finite element function space
 
7547
  virtual unsigned int max_local_dimension() const
 
7548
  {
 
7549
    return 6;
 
7550
  }
 
7551
 
 
7552
  /// Return the number of dofs on each cell facet
 
7553
  virtual unsigned int num_facet_dofs() const
 
7554
  {
 
7555
    return 0;
 
7556
  }
 
7557
 
 
7558
  /// Return the number of dofs associated with each cell entity of dimension d
 
7559
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
7560
  {
 
7561
    switch (d)
 
7562
    {
 
7563
    case 0:
 
7564
      {
 
7565
        return 0;
 
7566
        break;
 
7567
      }
 
7568
    case 1:
 
7569
      {
 
7570
        return 0;
 
7571
        break;
 
7572
      }
 
7573
    case 2:
 
7574
      {
 
7575
        return 6;
 
7576
        break;
 
7577
      }
 
7578
    }
 
7579
    
 
7580
    return 0;
 
7581
  }
 
7582
 
 
7583
  /// Tabulate the local-to-global mapping of dofs on a cell
 
7584
  virtual void tabulate_dofs(unsigned int* dofs,
 
7585
                             const ufc::mesh& m,
 
7586
                             const ufc::cell& c) const
 
7587
  {
 
7588
    dofs[0] = 6*c.entity_indices[2][0];
 
7589
    dofs[1] = 6*c.entity_indices[2][0] + 1;
 
7590
    dofs[2] = 6*c.entity_indices[2][0] + 2;
 
7591
    dofs[3] = 6*c.entity_indices[2][0] + 3;
 
7592
    dofs[4] = 6*c.entity_indices[2][0] + 4;
 
7593
    dofs[5] = 6*c.entity_indices[2][0] + 5;
 
7594
  }
 
7595
 
 
7596
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
7597
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
7598
                                   unsigned int facet) const
 
7599
  {
 
7600
    switch (facet)
 
7601
    {
 
7602
    case 0:
 
7603
      {
 
7604
        
 
7605
        break;
 
7606
      }
 
7607
    case 1:
 
7608
      {
 
7609
        
 
7610
        break;
 
7611
      }
 
7612
    case 2:
 
7613
      {
 
7614
        
 
7615
        break;
 
7616
      }
 
7617
    }
 
7618
    
 
7619
  }
 
7620
 
 
7621
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
7622
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
7623
                                    unsigned int d, unsigned int i) const
 
7624
  {
 
7625
    if (d > 2)
 
7626
    {
 
7627
    throw std::runtime_error("d is larger than dimension (2)");
 
7628
    }
 
7629
    
 
7630
    switch (d)
 
7631
    {
 
7632
    case 0:
 
7633
      {
 
7634
        
 
7635
        break;
 
7636
      }
 
7637
    case 1:
 
7638
      {
 
7639
        
 
7640
        break;
 
7641
      }
 
7642
    case 2:
 
7643
      {
 
7644
        if (i > 0)
 
7645
      {
 
7646
      throw std::runtime_error("i is larger than number of entities (0)");
 
7647
      }
 
7648
      
 
7649
      dofs[0] = 0;
 
7650
      dofs[1] = 1;
 
7651
      dofs[2] = 2;
 
7652
      dofs[3] = 3;
 
7653
      dofs[4] = 4;
 
7654
      dofs[5] = 5;
 
7655
        break;
 
7656
      }
 
7657
    }
 
7658
    
 
7659
  }
 
7660
 
 
7661
  /// Tabulate the coordinates of all dofs on a cell
 
7662
  virtual void tabulate_coordinates(double** coordinates,
 
7663
                                    const ufc::cell& c) const
 
7664
  {
 
7665
    const double * const * x = c.coordinates;
 
7666
    
 
7667
    coordinates[0][0] = x[0][0];
 
7668
    coordinates[0][1] = x[0][1];
 
7669
    coordinates[1][0] = x[1][0];
 
7670
    coordinates[1][1] = x[1][1];
 
7671
    coordinates[2][0] = x[2][0];
 
7672
    coordinates[2][1] = x[2][1];
 
7673
    coordinates[3][0] = 0.500000000000000*x[1][0] + 0.500000000000000*x[2][0];
 
7674
    coordinates[3][1] = 0.500000000000000*x[1][1] + 0.500000000000000*x[2][1];
 
7675
    coordinates[4][0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[2][0];
 
7676
    coordinates[4][1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[2][1];
 
7677
    coordinates[5][0] = 0.500000000000000*x[0][0] + 0.500000000000000*x[1][0];
 
7678
    coordinates[5][1] = 0.500000000000000*x[0][1] + 0.500000000000000*x[1][1];
 
7679
  }
 
7680
 
 
7681
  /// Return the number of sub dofmaps (for a mixed element)
 
7682
  virtual unsigned int num_sub_dofmaps() const
 
7683
  {
 
7684
    return 0;
 
7685
  }
 
7686
 
 
7687
  /// Create a new dofmap for sub dofmap i (for a mixed element)
 
7688
  virtual ufc::dofmap* create_sub_dofmap(unsigned int i) const
 
7689
  {
 
7690
    return 0;
 
7691
  }
 
7692
 
 
7693
  /// Create a new class instance
 
7694
  virtual ufc::dofmap* create() const
 
7695
  {
 
7696
    return new adaptivepoisson_dofmap_2();
 
7697
  }
 
7698
 
 
7699
};
 
7700
 
 
7701
/// This class defines the interface for a local-to-global mapping of
 
7702
/// degrees of freedom (dofs).
 
7703
 
 
7704
class adaptivepoisson_dofmap_3: public ufc::dofmap
 
7705
{
 
7706
private:
 
7707
 
 
7708
  unsigned int _global_dimension;
 
7709
public:
 
7710
 
 
7711
  /// Constructor
 
7712
  adaptivepoisson_dofmap_3() : ufc::dofmap()
 
7713
  {
 
7714
    _global_dimension = 0;
 
7715
  }
 
7716
 
 
7717
  /// Destructor
 
7718
  virtual ~adaptivepoisson_dofmap_3()
 
7719
  {
 
7720
    // Do nothing
 
7721
  }
 
7722
 
 
7723
  /// Return a string identifying the dofmap
 
7724
  virtual const char* signature() const
 
7725
  {
 
7726
    return "FFC dofmap for FiniteElement('Bubble', Cell('triangle', 1, Space(2)), 3)";
 
7727
  }
 
7728
 
 
7729
  /// Return true iff mesh entities of topological dimension d are needed
 
7730
  virtual bool needs_mesh_entities(unsigned int d) const
 
7731
  {
 
7732
    switch (d)
 
7733
    {
 
7734
    case 0:
 
7735
      {
 
7736
        return false;
 
7737
        break;
 
7738
      }
 
7739
    case 1:
 
7740
      {
 
7741
        return false;
 
7742
        break;
 
7743
      }
 
7744
    case 2:
 
7745
      {
 
7746
        return true;
 
7747
        break;
 
7748
      }
 
7749
    }
 
7750
    
 
7751
    return false;
 
7752
  }
 
7753
 
 
7754
  /// Initialize dofmap for mesh (return true iff init_cell() is needed)
 
7755
  virtual bool init_mesh(const ufc::mesh& m)
 
7756
  {
 
7757
    _global_dimension = m.num_entities[2];
 
7758
    return false;
 
7759
  }
 
7760
 
 
7761
  /// Initialize dofmap for given cell
 
7762
  virtual void init_cell(const ufc::mesh& m,
 
7763
                         const ufc::cell& c)
 
7764
  {
 
7765
    // Do nothing
 
7766
  }
 
7767
 
 
7768
  /// Finish initialization of dofmap for cells
 
7769
  virtual void init_cell_finalize()
 
7770
  {
 
7771
    // Do nothing
 
7772
  }
 
7773
 
 
7774
  /// Return the topological dimension of the associated cell shape
 
7775
  virtual unsigned int topological_dimension() const
 
7776
  {
 
7777
    return 2;
 
7778
  }
 
7779
 
 
7780
  /// Return the geometric dimension of the associated cell shape
 
7781
  virtual unsigned int geometric_dimension() const
 
7782
  {
 
7783
    return 2;
 
7784
  }
 
7785
 
 
7786
  /// Return the dimension of the global finite element function space
 
7787
  virtual unsigned int global_dimension() const
 
7788
  {
 
7789
    return _global_dimension;
 
7790
  }
 
7791
 
 
7792
  /// Return the dimension of the local finite element function space for a cell
 
7793
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
7794
  {
 
7795
    return 1;
 
7796
  }
 
7797
 
 
7798
  /// Return the maximum dimension of the local finite element function space
 
7799
  virtual unsigned int max_local_dimension() const
 
7800
  {
 
7801
    return 1;
 
7802
  }
 
7803
 
 
7804
  /// Return the number of dofs on each cell facet
 
7805
  virtual unsigned int num_facet_dofs() const
 
7806
  {
 
7807
    return 0;
 
7808
  }
 
7809
 
 
7810
  /// Return the number of dofs associated with each cell entity of dimension d
 
7811
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
7812
  {
 
7813
    switch (d)
 
7814
    {
 
7815
    case 0:
 
7816
      {
 
7817
        return 0;
 
7818
        break;
 
7819
      }
 
7820
    case 1:
 
7821
      {
 
7822
        return 0;
 
7823
        break;
 
7824
      }
 
7825
    case 2:
 
7826
      {
 
7827
        return 1;
 
7828
        break;
 
7829
      }
 
7830
    }
 
7831
    
 
7832
    return 0;
 
7833
  }
 
7834
 
 
7835
  /// Tabulate the local-to-global mapping of dofs on a cell
 
7836
  virtual void tabulate_dofs(unsigned int* dofs,
 
7837
                             const ufc::mesh& m,
 
7838
                             const ufc::cell& c) const
 
7839
  {
 
7840
    dofs[0] = c.entity_indices[2][0];
 
7841
  }
 
7842
 
 
7843
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
7844
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
7845
                                   unsigned int facet) const
 
7846
  {
 
7847
    switch (facet)
 
7848
    {
 
7849
    case 0:
 
7850
      {
 
7851
        
 
7852
        break;
 
7853
      }
 
7854
    case 1:
 
7855
      {
 
7856
        
 
7857
        break;
 
7858
      }
 
7859
    case 2:
 
7860
      {
 
7861
        
 
7862
        break;
 
7863
      }
 
7864
    }
 
7865
    
 
7866
  }
 
7867
 
 
7868
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
7869
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
7870
                                    unsigned int d, unsigned int i) const
 
7871
  {
 
7872
    if (d > 2)
 
7873
    {
 
7874
    throw std::runtime_error("d is larger than dimension (2)");
 
7875
    }
 
7876
    
 
7877
    switch (d)
 
7878
    {
 
7879
    case 0:
 
7880
      {
 
7881
        
 
7882
        break;
 
7883
      }
 
7884
    case 1:
 
7885
      {
 
7886
        
 
7887
        break;
 
7888
      }
 
7889
    case 2:
 
7890
      {
 
7891
        if (i > 0)
 
7892
      {
 
7893
      throw std::runtime_error("i is larger than number of entities (0)");
 
7894
      }
 
7895
      
 
7896
      dofs[0] = 0;
 
7897
        break;
 
7898
      }
 
7899
    }
 
7900
    
 
7901
  }
 
7902
 
 
7903
  /// Tabulate the coordinates of all dofs on a cell
 
7904
  virtual void tabulate_coordinates(double** coordinates,
 
7905
                                    const ufc::cell& c) const
 
7906
  {
 
7907
    const double * const * x = c.coordinates;
 
7908
    
 
7909
    coordinates[0][0] = 0.333333333333333*x[0][0] + 0.333333333333333*x[1][0] + 0.333333333333333*x[2][0];
 
7910
    coordinates[0][1] = 0.333333333333333*x[0][1] + 0.333333333333333*x[1][1] + 0.333333333333333*x[2][1];
 
7911
  }
 
7912
 
 
7913
  /// Return the number of sub dofmaps (for a mixed element)
 
7914
  virtual unsigned int num_sub_dofmaps() const
 
7915
  {
 
7916
    return 0;
 
7917
  }
 
7918
 
 
7919
  /// Create a new dofmap for sub dofmap i (for a mixed element)
 
7920
  virtual ufc::dofmap* create_sub_dofmap(unsigned int i) const
 
7921
  {
 
7922
    return 0;
 
7923
  }
 
7924
 
 
7925
  /// Create a new class instance
 
7926
  virtual ufc::dofmap* create() const
 
7927
  {
 
7928
    return new adaptivepoisson_dofmap_3();
 
7929
  }
 
7930
 
 
7931
};
 
7932
 
 
7933
/// This class defines the interface for a local-to-global mapping of
 
7934
/// degrees of freedom (dofs).
 
7935
 
 
7936
class adaptivepoisson_dofmap_4: public ufc::dofmap
 
7937
{
 
7938
private:
 
7939
 
 
7940
  unsigned int _global_dimension;
 
7941
public:
 
7942
 
 
7943
  /// Constructor
 
7944
  adaptivepoisson_dofmap_4() : ufc::dofmap()
 
7945
  {
 
7946
    _global_dimension = 0;
 
7947
  }
 
7948
 
 
7949
  /// Destructor
 
7950
  virtual ~adaptivepoisson_dofmap_4()
 
7951
  {
 
7952
    // Do nothing
 
7953
  }
 
7954
 
 
7955
  /// Return a string identifying the dofmap
 
7956
  virtual const char* signature() const
 
7957
  {
 
7958
    return "FFC dofmap for FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1)";
 
7959
  }
 
7960
 
 
7961
  /// Return true iff mesh entities of topological dimension d are needed
 
7962
  virtual bool needs_mesh_entities(unsigned int d) const
 
7963
  {
 
7964
    switch (d)
 
7965
    {
 
7966
    case 0:
 
7967
      {
 
7968
        return false;
 
7969
        break;
 
7970
      }
 
7971
    case 1:
 
7972
      {
 
7973
        return false;
 
7974
        break;
 
7975
      }
 
7976
    case 2:
 
7977
      {
 
7978
        return true;
 
7979
        break;
 
7980
      }
 
7981
    }
 
7982
    
 
7983
    return false;
 
7984
  }
 
7985
 
 
7986
  /// Initialize dofmap for mesh (return true iff init_cell() is needed)
 
7987
  virtual bool init_mesh(const ufc::mesh& m)
 
7988
  {
 
7989
    _global_dimension = 3.000000000000000*m.num_entities[2];
 
7990
    return false;
 
7991
  }
 
7992
 
 
7993
  /// Initialize dofmap for given cell
 
7994
  virtual void init_cell(const ufc::mesh& m,
 
7995
                         const ufc::cell& c)
 
7996
  {
 
7997
    // Do nothing
 
7998
  }
 
7999
 
 
8000
  /// Finish initialization of dofmap for cells
 
8001
  virtual void init_cell_finalize()
 
8002
  {
 
8003
    // Do nothing
 
8004
  }
 
8005
 
 
8006
  /// Return the topological dimension of the associated cell shape
 
8007
  virtual unsigned int topological_dimension() const
 
8008
  {
 
8009
    return 2;
 
8010
  }
 
8011
 
 
8012
  /// Return the geometric dimension of the associated cell shape
 
8013
  virtual unsigned int geometric_dimension() const
 
8014
  {
 
8015
    return 2;
 
8016
  }
 
8017
 
 
8018
  /// Return the dimension of the global finite element function space
 
8019
  virtual unsigned int global_dimension() const
 
8020
  {
 
8021
    return _global_dimension;
 
8022
  }
 
8023
 
 
8024
  /// Return the dimension of the local finite element function space for a cell
 
8025
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
8026
  {
 
8027
    return 3;
 
8028
  }
 
8029
 
 
8030
  /// Return the maximum dimension of the local finite element function space
 
8031
  virtual unsigned int max_local_dimension() const
 
8032
  {
 
8033
    return 3;
 
8034
  }
 
8035
 
 
8036
  /// Return the number of dofs on each cell facet
 
8037
  virtual unsigned int num_facet_dofs() const
 
8038
  {
 
8039
    return 0;
 
8040
  }
 
8041
 
 
8042
  /// Return the number of dofs associated with each cell entity of dimension d
 
8043
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
8044
  {
 
8045
    switch (d)
 
8046
    {
 
8047
    case 0:
 
8048
      {
 
8049
        return 0;
 
8050
        break;
 
8051
      }
 
8052
    case 1:
 
8053
      {
 
8054
        return 0;
 
8055
        break;
 
8056
      }
 
8057
    case 2:
 
8058
      {
 
8059
        return 3;
 
8060
        break;
 
8061
      }
 
8062
    }
 
8063
    
 
8064
    return 0;
 
8065
  }
 
8066
 
 
8067
  /// Tabulate the local-to-global mapping of dofs on a cell
 
8068
  virtual void tabulate_dofs(unsigned int* dofs,
 
8069
                             const ufc::mesh& m,
 
8070
                             const ufc::cell& c) const
 
8071
  {
 
8072
    dofs[0] = 3*c.entity_indices[2][0];
 
8073
    dofs[1] = 3*c.entity_indices[2][0] + 1;
 
8074
    dofs[2] = 3*c.entity_indices[2][0] + 2;
 
8075
  }
 
8076
 
 
8077
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
8078
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
8079
                                   unsigned int facet) const
 
8080
  {
 
8081
    switch (facet)
 
8082
    {
 
8083
    case 0:
 
8084
      {
 
8085
        
 
8086
        break;
 
8087
      }
 
8088
    case 1:
 
8089
      {
 
8090
        
 
8091
        break;
 
8092
      }
 
8093
    case 2:
 
8094
      {
 
8095
        
 
8096
        break;
 
8097
      }
 
8098
    }
 
8099
    
 
8100
  }
 
8101
 
 
8102
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
8103
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
8104
                                    unsigned int d, unsigned int i) const
 
8105
  {
 
8106
    if (d > 2)
 
8107
    {
 
8108
    throw std::runtime_error("d is larger than dimension (2)");
 
8109
    }
 
8110
    
 
8111
    switch (d)
 
8112
    {
 
8113
    case 0:
 
8114
      {
 
8115
        
 
8116
        break;
 
8117
      }
 
8118
    case 1:
 
8119
      {
 
8120
        
 
8121
        break;
 
8122
      }
 
8123
    case 2:
 
8124
      {
 
8125
        if (i > 0)
 
8126
      {
 
8127
      throw std::runtime_error("i is larger than number of entities (0)");
 
8128
      }
 
8129
      
 
8130
      dofs[0] = 0;
 
8131
      dofs[1] = 1;
 
8132
      dofs[2] = 2;
 
8133
        break;
 
8134
      }
 
8135
    }
 
8136
    
 
8137
  }
 
8138
 
 
8139
  /// Tabulate the coordinates of all dofs on a cell
 
8140
  virtual void tabulate_coordinates(double** coordinates,
 
8141
                                    const ufc::cell& c) const
 
8142
  {
 
8143
    const double * const * x = c.coordinates;
 
8144
    
 
8145
    coordinates[0][0] = x[0][0];
 
8146
    coordinates[0][1] = x[0][1];
 
8147
    coordinates[1][0] = x[1][0];
 
8148
    coordinates[1][1] = x[1][1];
 
8149
    coordinates[2][0] = x[2][0];
 
8150
    coordinates[2][1] = x[2][1];
 
8151
  }
 
8152
 
 
8153
  /// Return the number of sub dofmaps (for a mixed element)
 
8154
  virtual unsigned int num_sub_dofmaps() const
 
8155
  {
 
8156
    return 0;
 
8157
  }
 
8158
 
 
8159
  /// Create a new dofmap for sub dofmap i (for a mixed element)
 
8160
  virtual ufc::dofmap* create_sub_dofmap(unsigned int i) const
 
8161
  {
 
8162
    return 0;
 
8163
  }
 
8164
 
 
8165
  /// Create a new class instance
 
8166
  virtual ufc::dofmap* create() const
 
8167
  {
 
8168
    return new adaptivepoisson_dofmap_4();
 
8169
  }
 
8170
 
 
8171
};
 
8172
 
 
8173
/// This class defines the interface for a local-to-global mapping of
 
8174
/// degrees of freedom (dofs).
 
8175
 
 
8176
class adaptivepoisson_dofmap_5: public ufc::dofmap
 
8177
{
 
8178
private:
 
8179
 
 
8180
  unsigned int _global_dimension;
 
8181
public:
 
8182
 
 
8183
  /// Constructor
 
8184
  adaptivepoisson_dofmap_5() : ufc::dofmap()
 
8185
  {
 
8186
    _global_dimension = 0;
 
8187
  }
 
8188
 
 
8189
  /// Destructor
 
8190
  virtual ~adaptivepoisson_dofmap_5()
 
8191
  {
 
8192
    // Do nothing
 
8193
  }
 
8194
 
 
8195
  /// Return a string identifying the dofmap
 
8196
  virtual const char* signature() const
 
8197
  {
 
8198
    return "FFC dofmap for FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1)";
 
8199
  }
 
8200
 
 
8201
  /// Return true iff mesh entities of topological dimension d are needed
 
8202
  virtual bool needs_mesh_entities(unsigned int d) const
 
8203
  {
 
8204
    switch (d)
 
8205
    {
 
8206
    case 0:
 
8207
      {
 
8208
        return true;
 
8209
        break;
 
8210
      }
 
8211
    case 1:
 
8212
      {
 
8213
        return false;
 
8214
        break;
 
8215
      }
 
8216
    case 2:
 
8217
      {
 
8218
        return false;
 
8219
        break;
 
8220
      }
 
8221
    }
 
8222
    
 
8223
    return false;
 
8224
  }
 
8225
 
 
8226
  /// Initialize dofmap for mesh (return true iff init_cell() is needed)
 
8227
  virtual bool init_mesh(const ufc::mesh& m)
 
8228
  {
 
8229
    _global_dimension = m.num_entities[0];
 
8230
    return false;
 
8231
  }
 
8232
 
 
8233
  /// Initialize dofmap for given cell
 
8234
  virtual void init_cell(const ufc::mesh& m,
 
8235
                         const ufc::cell& c)
 
8236
  {
 
8237
    // Do nothing
 
8238
  }
 
8239
 
 
8240
  /// Finish initialization of dofmap for cells
 
8241
  virtual void init_cell_finalize()
 
8242
  {
 
8243
    // Do nothing
 
8244
  }
 
8245
 
 
8246
  /// Return the topological dimension of the associated cell shape
 
8247
  virtual unsigned int topological_dimension() const
 
8248
  {
 
8249
    return 2;
 
8250
  }
 
8251
 
 
8252
  /// Return the geometric dimension of the associated cell shape
 
8253
  virtual unsigned int geometric_dimension() const
 
8254
  {
 
8255
    return 2;
 
8256
  }
 
8257
 
 
8258
  /// Return the dimension of the global finite element function space
 
8259
  virtual unsigned int global_dimension() const
 
8260
  {
 
8261
    return _global_dimension;
 
8262
  }
 
8263
 
 
8264
  /// Return the dimension of the local finite element function space for a cell
 
8265
  virtual unsigned int local_dimension(const ufc::cell& c) const
 
8266
  {
 
8267
    return 3;
 
8268
  }
 
8269
 
 
8270
  /// Return the maximum dimension of the local finite element function space
 
8271
  virtual unsigned int max_local_dimension() const
 
8272
  {
 
8273
    return 3;
 
8274
  }
 
8275
 
 
8276
  /// Return the number of dofs on each cell facet
 
8277
  virtual unsigned int num_facet_dofs() const
 
8278
  {
 
8279
    return 2;
 
8280
  }
 
8281
 
 
8282
  /// Return the number of dofs associated with each cell entity of dimension d
 
8283
  virtual unsigned int num_entity_dofs(unsigned int d) const
 
8284
  {
 
8285
    switch (d)
 
8286
    {
 
8287
    case 0:
 
8288
      {
 
8289
        return 1;
 
8290
        break;
 
8291
      }
 
8292
    case 1:
 
8293
      {
 
8294
        return 0;
 
8295
        break;
 
8296
      }
 
8297
    case 2:
 
8298
      {
 
8299
        return 0;
 
8300
        break;
 
8301
      }
 
8302
    }
 
8303
    
 
8304
    return 0;
 
8305
  }
 
8306
 
 
8307
  /// Tabulate the local-to-global mapping of dofs on a cell
 
8308
  virtual void tabulate_dofs(unsigned int* dofs,
 
8309
                             const ufc::mesh& m,
 
8310
                             const ufc::cell& c) const
 
8311
  {
 
8312
    dofs[0] = c.entity_indices[0][0];
 
8313
    dofs[1] = c.entity_indices[0][1];
 
8314
    dofs[2] = c.entity_indices[0][2];
 
8315
  }
 
8316
 
 
8317
  /// Tabulate the local-to-local mapping from facet dofs to cell dofs
 
8318
  virtual void tabulate_facet_dofs(unsigned int* dofs,
 
8319
                                   unsigned int facet) const
 
8320
  {
 
8321
    switch (facet)
 
8322
    {
 
8323
    case 0:
 
8324
      {
 
8325
        dofs[0] = 1;
 
8326
      dofs[1] = 2;
 
8327
        break;
 
8328
      }
 
8329
    case 1:
 
8330
      {
 
8331
        dofs[0] = 0;
 
8332
      dofs[1] = 2;
 
8333
        break;
 
8334
      }
 
8335
    case 2:
 
8336
      {
 
8337
        dofs[0] = 0;
 
8338
      dofs[1] = 1;
 
8339
        break;
 
8340
      }
 
8341
    }
 
8342
    
 
8343
  }
 
8344
 
 
8345
  /// Tabulate the local-to-local mapping of dofs on entity (d, i)
 
8346
  virtual void tabulate_entity_dofs(unsigned int* dofs,
 
8347
                                    unsigned int d, unsigned int i) const
 
8348
  {
 
8349
    if (d > 2)
 
8350
    {
 
8351
    throw std::runtime_error("d is larger than dimension (2)");
 
8352
    }
 
8353
    
 
8354
    switch (d)
 
8355
    {
 
8356
    case 0:
 
8357
      {
 
8358
        if (i > 2)
 
8359
      {
 
8360
      throw std::runtime_error("i is larger than number of entities (2)");
 
8361
      }
 
8362
      
 
8363
      switch (i)
 
8364
      {
 
8365
      case 0:
 
8366
        {
 
8367
          dofs[0] = 0;
 
8368
          break;
 
8369
        }
 
8370
      case 1:
 
8371
        {
 
8372
          dofs[0] = 1;
 
8373
          break;
 
8374
        }
 
8375
      case 2:
 
8376
        {
 
8377
          dofs[0] = 2;
 
8378
          break;
 
8379
        }
 
8380
      }
 
8381
      
 
8382
        break;
 
8383
      }
 
8384
    case 1:
 
8385
      {
 
8386
        
 
8387
        break;
 
8388
      }
 
8389
    case 2:
 
8390
      {
 
8391
        
 
8392
        break;
 
8393
      }
 
8394
    }
 
8395
    
 
8396
  }
 
8397
 
 
8398
  /// Tabulate the coordinates of all dofs on a cell
 
8399
  virtual void tabulate_coordinates(double** coordinates,
 
8400
                                    const ufc::cell& c) const
 
8401
  {
 
8402
    const double * const * x = c.coordinates;
 
8403
    
 
8404
    coordinates[0][0] = x[0][0];
 
8405
    coordinates[0][1] = x[0][1];
 
8406
    coordinates[1][0] = x[1][0];
 
8407
    coordinates[1][1] = x[1][1];
 
8408
    coordinates[2][0] = x[2][0];
 
8409
    coordinates[2][1] = x[2][1];
 
8410
  }
 
8411
 
 
8412
  /// Return the number of sub dofmaps (for a mixed element)
 
8413
  virtual unsigned int num_sub_dofmaps() const
 
8414
  {
 
8415
    return 0;
 
8416
  }
 
8417
 
 
8418
  /// Create a new dofmap for sub dofmap i (for a mixed element)
 
8419
  virtual ufc::dofmap* create_sub_dofmap(unsigned int i) const
 
8420
  {
 
8421
    return 0;
 
8422
  }
 
8423
 
 
8424
  /// Create a new class instance
 
8425
  virtual ufc::dofmap* create() const
 
8426
  {
 
8427
    return new adaptivepoisson_dofmap_5();
 
8428
  }
 
8429
 
 
8430
};
 
8431
 
 
8432
/// This class defines the interface for the tabulation of the cell
 
8433
/// tensor corresponding to the local contribution to a form from
 
8434
/// the integral over a cell.
 
8435
 
 
8436
class adaptivepoisson_cell_integral_0_0: public ufc::cell_integral
 
8437
{
 
8438
public:
 
8439
 
 
8440
  /// Constructor
 
8441
  adaptivepoisson_cell_integral_0_0() : ufc::cell_integral()
 
8442
  {
 
8443
    // Do nothing
 
8444
  }
 
8445
 
 
8446
  /// Destructor
 
8447
  virtual ~adaptivepoisson_cell_integral_0_0()
 
8448
  {
 
8449
    // Do nothing
 
8450
  }
 
8451
 
 
8452
  /// Tabulate the tensor for the contribution from a local cell
 
8453
  virtual void tabulate_tensor(double* A,
 
8454
                               const double * const * w,
 
8455
                               const ufc::cell& c) const
 
8456
  {
 
8457
    // Number of operations (multiply-add pairs) for Jacobian data:      11
 
8458
    // Number of operations (multiply-add pairs) for geometry tensor:    8
 
8459
    // Number of operations (multiply-add pairs) for tensor contraction: 11
 
8460
    // Total number of operations (multiply-add pairs):                  30
 
8461
    
 
8462
    // Extract vertex coordinates
 
8463
    const double * const * x = c.coordinates;
 
8464
    
 
8465
    // Compute Jacobian of affine map from reference cell
 
8466
    const double J_00 = x[1][0] - x[0][0];
 
8467
    const double J_01 = x[2][0] - x[0][0];
 
8468
    const double J_10 = x[1][1] - x[0][1];
 
8469
    const double J_11 = x[2][1] - x[0][1];
 
8470
    
 
8471
    // Compute determinant of Jacobian
 
8472
    double detJ = J_00*J_11 - J_01*J_10;
 
8473
    
 
8474
    // Compute inverse of Jacobian
 
8475
    const double K_00 =  J_11 / detJ;
 
8476
    const double K_01 = -J_01 / detJ;
 
8477
    const double K_10 = -J_10 / detJ;
 
8478
    const double K_11 =  J_00 / detJ;
 
8479
    
 
8480
    // Set scale factor
 
8481
    const double det = std::abs(detJ);
 
8482
    
 
8483
    // Compute geometry tensor
 
8484
    const double G0_0_0 = det*(K_00*K_00 + K_01*K_01);
 
8485
    const double G0_0_1 = det*(K_00*K_10 + K_01*K_11);
 
8486
    const double G0_1_0 = det*(K_10*K_00 + K_11*K_01);
 
8487
    const double G0_1_1 = det*(K_10*K_10 + K_11*K_11);
 
8488
    
 
8489
    // Compute element tensor
 
8490
    A[0] = 0.500000000000000*G0_0_0 + 0.500000000000000*G0_0_1 + 0.500000000000000*G0_1_0 + 0.500000000000000*G0_1_1;
 
8491
    A[1] = -0.500000000000000*G0_0_0 - 0.500000000000000*G0_1_0;
 
8492
    A[2] = -0.500000000000000*G0_0_1 - 0.500000000000000*G0_1_1;
 
8493
    A[3] = -0.500000000000000*G0_0_0 - 0.500000000000000*G0_0_1;
 
8494
    A[4] = 0.500000000000000*G0_0_0;
 
8495
    A[5] = 0.500000000000000*G0_0_1;
 
8496
    A[6] = -0.500000000000000*G0_1_0 - 0.500000000000000*G0_1_1;
 
8497
    A[7] = 0.500000000000000*G0_1_0;
 
8498
    A[8] = 0.500000000000000*G0_1_1;
 
8499
  }
 
8500
 
 
8501
  /// Tabulate the tensor for the contribution from a local cell
 
8502
  /// using the specified reference cell quadrature points/weights
 
8503
  virtual void tabulate_tensor(double* A,
 
8504
                               const double * const * w,
 
8505
                               const ufc::cell& c,
 
8506
                               unsigned int num_quadrature_points,
 
8507
                               const double * const * quadrature_points,
 
8508
                               const double* quadrature_weights) const
 
8509
  {
 
8510
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
8511
  }
 
8512
 
 
8513
};
 
8514
 
 
8515
/// This class defines the interface for the tabulation of the cell
 
8516
/// tensor corresponding to the local contribution to a form from
 
8517
/// the integral over a cell.
 
8518
 
 
8519
class adaptivepoisson_cell_integral_1_0: public ufc::cell_integral
 
8520
{
 
8521
public:
 
8522
 
 
8523
  /// Constructor
 
8524
  adaptivepoisson_cell_integral_1_0() : ufc::cell_integral()
 
8525
  {
 
8526
    // Do nothing
 
8527
  }
 
8528
 
 
8529
  /// Destructor
 
8530
  virtual ~adaptivepoisson_cell_integral_1_0()
 
8531
  {
 
8532
    // Do nothing
 
8533
  }
 
8534
 
 
8535
  /// Tabulate the tensor for the contribution from a local cell
 
8536
  virtual void tabulate_tensor(double* A,
 
8537
                               const double * const * w,
 
8538
                               const ufc::cell& c) const
 
8539
  {
 
8540
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
8541
    // Number of operations (multiply-add pairs) for geometry tensor:    0
 
8542
    // Number of operations (multiply-add pairs) for tensor contraction: 1
 
8543
    // Total number of operations (multiply-add pairs):                  10
 
8544
    
 
8545
    // Extract vertex coordinates
 
8546
    const double * const * x = c.coordinates;
 
8547
    
 
8548
    // Compute Jacobian of affine map from reference cell
 
8549
    const double J_00 = x[1][0] - x[0][0];
 
8550
    const double J_01 = x[2][0] - x[0][0];
 
8551
    const double J_10 = x[1][1] - x[0][1];
 
8552
    const double J_11 = x[2][1] - x[0][1];
 
8553
    
 
8554
    // Compute determinant of Jacobian
 
8555
    double detJ = J_00*J_11 - J_01*J_10;
 
8556
    
 
8557
    // Compute inverse of Jacobian
 
8558
    
 
8559
    // Set scale factor
 
8560
    const double det = std::abs(detJ);
 
8561
    
 
8562
    // Compute geometry tensor
 
8563
    const double G0_ = det;
 
8564
    
 
8565
    // Compute element tensor
 
8566
    A[0] = 0.166666666666667*G0_;
 
8567
    A[1] = 0.166666666666667*G0_;
 
8568
    A[2] = 0.166666666666667*G0_;
 
8569
  }
 
8570
 
 
8571
  /// Tabulate the tensor for the contribution from a local cell
 
8572
  /// using the specified reference cell quadrature points/weights
 
8573
  virtual void tabulate_tensor(double* A,
 
8574
                               const double * const * w,
 
8575
                               const ufc::cell& c,
 
8576
                               unsigned int num_quadrature_points,
 
8577
                               const double * const * quadrature_points,
 
8578
                               const double* quadrature_weights) const
 
8579
  {
 
8580
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
8581
  }
 
8582
 
 
8583
};
 
8584
 
 
8585
/// This class defines the interface for the tabulation of the cell
 
8586
/// tensor corresponding to the local contribution to a form from
 
8587
/// the integral over a cell.
 
8588
 
 
8589
class adaptivepoisson_cell_integral_2_0: public ufc::cell_integral
 
8590
{
 
8591
public:
 
8592
 
 
8593
  /// Constructor
 
8594
  adaptivepoisson_cell_integral_2_0() : ufc::cell_integral()
 
8595
  {
 
8596
    // Do nothing
 
8597
  }
 
8598
 
 
8599
  /// Destructor
 
8600
  virtual ~adaptivepoisson_cell_integral_2_0()
 
8601
  {
 
8602
    // Do nothing
 
8603
  }
 
8604
 
 
8605
  /// Tabulate the tensor for the contribution from a local cell
 
8606
  virtual void tabulate_tensor(double* A,
 
8607
                               const double * const * w,
 
8608
                               const ufc::cell& c) const
 
8609
  {
 
8610
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
8611
    // Number of operations (multiply-add pairs) for geometry tensor:    1
 
8612
    // Number of operations (multiply-add pairs) for tensor contraction: 4
 
8613
    // Total number of operations (multiply-add pairs):                  14
 
8614
    
 
8615
    // Extract vertex coordinates
 
8616
    const double * const * x = c.coordinates;
 
8617
    
 
8618
    // Compute Jacobian of affine map from reference cell
 
8619
    const double J_00 = x[1][0] - x[0][0];
 
8620
    const double J_01 = x[2][0] - x[0][0];
 
8621
    const double J_10 = x[1][1] - x[0][1];
 
8622
    const double J_11 = x[2][1] - x[0][1];
 
8623
    
 
8624
    // Compute determinant of Jacobian
 
8625
    double detJ = J_00*J_11 - J_01*J_10;
 
8626
    
 
8627
    // Compute inverse of Jacobian
 
8628
    
 
8629
    // Set scale factor
 
8630
    const double det = std::abs(detJ);
 
8631
    
 
8632
    // Compute geometry tensor
 
8633
    const double G0_0 = det*w[0][0]*(1.0);
 
8634
    
 
8635
    // Compute element tensor
 
8636
    A[0] = 0.032142857142857*G0_0;
 
8637
    A[1] = 0.021428571428571*G0_0;
 
8638
    A[2] = 0.021428571428571*G0_0;
 
8639
    A[3] = 0.021428571428571*G0_0;
 
8640
    A[4] = 0.032142857142857*G0_0;
 
8641
    A[5] = 0.021428571428571*G0_0;
 
8642
    A[6] = 0.021428571428571*G0_0;
 
8643
    A[7] = 0.021428571428571*G0_0;
 
8644
    A[8] = 0.032142857142857*G0_0;
 
8645
  }
 
8646
 
 
8647
  /// Tabulate the tensor for the contribution from a local cell
 
8648
  /// using the specified reference cell quadrature points/weights
 
8649
  virtual void tabulate_tensor(double* A,
 
8650
                               const double * const * w,
 
8651
                               const ufc::cell& c,
 
8652
                               unsigned int num_quadrature_points,
 
8653
                               const double * const * quadrature_points,
 
8654
                               const double* quadrature_weights) const
 
8655
  {
 
8656
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
8657
  }
 
8658
 
 
8659
};
 
8660
 
 
8661
/// This class defines the interface for the tabulation of the cell
 
8662
/// tensor corresponding to the local contribution to a form from
 
8663
/// the integral over a cell.
 
8664
 
 
8665
class adaptivepoisson_cell_integral_3_0: public ufc::cell_integral
 
8666
{
 
8667
public:
 
8668
 
 
8669
  /// Constructor
 
8670
  adaptivepoisson_cell_integral_3_0() : ufc::cell_integral()
 
8671
  {
 
8672
    // Do nothing
 
8673
  }
 
8674
 
 
8675
  /// Destructor
 
8676
  virtual ~adaptivepoisson_cell_integral_3_0()
 
8677
  {
 
8678
    // Do nothing
 
8679
  }
 
8680
 
 
8681
  /// Tabulate the tensor for the contribution from a local cell
 
8682
  virtual void tabulate_tensor(double* A,
 
8683
                               const double * const * w,
 
8684
                               const ufc::cell& c) const
 
8685
  {
 
8686
    // Extract vertex coordinates
 
8687
    const double * const * x = c.coordinates;
 
8688
    
 
8689
    // Compute Jacobian of affine map from reference cell
 
8690
    const double J_00 = x[1][0] - x[0][0];
 
8691
    const double J_01 = x[2][0] - x[0][0];
 
8692
    const double J_10 = x[1][1] - x[0][1];
 
8693
    const double J_11 = x[2][1] - x[0][1];
 
8694
    
 
8695
    // Compute determinant of Jacobian
 
8696
    double detJ = J_00*J_11 - J_01*J_10;
 
8697
    
 
8698
    // Compute inverse of Jacobian
 
8699
    const double K_00 =  J_11 / detJ;
 
8700
    const double K_01 = -J_01 / detJ;
 
8701
    const double K_10 = -J_10 / detJ;
 
8702
    const double K_11 =  J_00 / detJ;
 
8703
    
 
8704
    // Set scale factor
 
8705
    const double det = std::abs(detJ);
 
8706
    
 
8707
    // Cell Volume.
 
8708
    
 
8709
    // Compute circumradius, assuming triangle is embedded in 2D.
 
8710
    
 
8711
    
 
8712
    // Array of quadrature weights.
 
8713
    static const double W9[9] = {0.055814420483044, 0.063678085099885, 0.019396383305959, 0.089303072772871, 0.101884936159816, 0.031034213289535, 0.055814420483044, 0.063678085099885, 0.019396383305959};
 
8714
    // Quadrature points on the UFC reference element: (0.102717654809626, 0.088587959512704), (0.066554067839165, 0.409466864440735), (0.023931132287081, 0.787659461760847), (0.455706020243648, 0.088587959512704), (0.295266567779633, 0.409466864440735), (0.106170269119576, 0.787659461760847), (0.808694385677670, 0.088587959512704), (0.523979067720101, 0.409466864440735), (0.188409405952072, 0.787659461760847)
 
8715
    
 
8716
    // Value of basis functions at quadrature points.
 
8717
    static const double FE0[9][1] = \
 
8718
    {{0.198686329147682},
 
8719
    {0.385541444206917},
 
8720
    {0.095888844721203},
 
8721
    {0.496715822869205},
 
8722
    {0.963853610517293},
 
8723
    {0.239722111803007},
 
8724
    {0.198686329147682},
 
8725
    {0.385541444206917},
 
8726
    {0.095888844721203}};
 
8727
    
 
8728
    static const double FE0_D01[9][1] = \
 
8729
    {{1.997126369343180},
 
8730
    {0.205773829527613},
 
8731
    {-0.387199773682209},
 
8732
    {4.517043581212140},
 
8733
    {-0.910427300132565},
 
8734
    {-1.953555056589780},
 
8735
    {0.308518341964844},
 
8736
    {-4.851336441759750},
 
8737
    {-3.885127223352865}};
 
8738
    
 
8739
    static const double FE0_D10[9][1] = \
 
8740
    {{1.688608027378335},
 
8741
    {5.057110271287362},
 
8742
    {3.497927449670658},
 
8743
    {0.000000000000000},
 
8744
    {0.000000000000000},
 
8745
    {0.000000000000000},
 
8746
    {-1.688608027378333},
 
8747
    {-5.057110271287364},
 
8748
    {-3.497927449670658}};
 
8749
    
 
8750
    static const double FE1[9][3] = \
 
8751
    {{0.808694385677670, 0.102717654809626, 0.088587959512704},
 
8752
    {0.523979067720101, 0.066554067839165, 0.409466864440735},
 
8753
    {0.188409405952072, 0.023931132287081, 0.787659461760847},
 
8754
    {0.455706020243648, 0.455706020243648, 0.088587959512704},
 
8755
    {0.295266567779633, 0.295266567779633, 0.409466864440735},
 
8756
    {0.106170269119576, 0.106170269119577, 0.787659461760847},
 
8757
    {0.102717654809626, 0.808694385677670, 0.088587959512704},
 
8758
    {0.066554067839164, 0.523979067720101, 0.409466864440735},
 
8759
    {0.023931132287081, 0.188409405952072, 0.787659461760847}};
 
8760
    
 
8761
    static const double FE1_D01[9][2] = \
 
8762
    {{-1.000000000000000, 1.000000000000000},
 
8763
    {-1.000000000000000, 1.000000000000000},
 
8764
    {-1.000000000000000, 1.000000000000000},
 
8765
    {-1.000000000000000, 1.000000000000000},
 
8766
    {-1.000000000000000, 1.000000000000000},
 
8767
    {-1.000000000000000, 1.000000000000000},
 
8768
    {-1.000000000000000, 1.000000000000000},
 
8769
    {-1.000000000000000, 1.000000000000000},
 
8770
    {-1.000000000000000, 1.000000000000000}};
 
8771
    
 
8772
    // Array of non-zero columns
 
8773
    static const unsigned int nzc0[2] = {0, 2};
 
8774
    
 
8775
    // Array of non-zero columns
 
8776
    static const unsigned int nzc1[2] = {0, 1};
 
8777
    
 
8778
    // Reset values in the element tensor.
 
8779
    for (unsigned int r = 0; r < 3; r++)
 
8780
    {
 
8781
      A[r] = 0.000000000000000;
 
8782
    }// end loop over 'r'
 
8783
    // Number of operations to compute geometry constants: 12.
 
8784
    double G[3];
 
8785
    G[0] =  - det*(K_00*K_00 + K_01*K_01);
 
8786
    G[1] =  - det*(K_00*K_10 + K_01*K_11);
 
8787
    G[2] =  - det*(K_10*K_10 + K_11*K_11);
 
8788
    
 
8789
    // Compute element tensor using UFL quadrature representation
 
8790
    // Optimisations: ('eliminate zeros', True), ('ignore ones', True), ('ignore zero tables', True), ('optimisation', 'simplify_expressions'), ('remove zero terms', True)
 
8791
    
 
8792
    // Loop quadrature points for integral.
 
8793
    // Number of operations to compute element tensor for following IP loop = 513
 
8794
    for (unsigned int ip = 0; ip < 9; ip++)
 
8795
    {
 
8796
      
 
8797
      // Coefficient declarations.
 
8798
      double F0 = 0.000000000000000;
 
8799
      double F1 = 0.000000000000000;
 
8800
      double F2 = 0.000000000000000;
 
8801
      double F3 = 0.000000000000000;
 
8802
      double F4 = 0.000000000000000;
 
8803
      double F5 = 0.000000000000000;
 
8804
      
 
8805
      // Total number of operations to compute function values = 6
 
8806
      for (unsigned int r = 0; r < 1; r++)
 
8807
      {
 
8808
        F1 += FE0[ip][r]*w[3][r];
 
8809
        F4 += FE0_D10[ip][r]*w[3][r];
 
8810
        F5 += FE0_D01[ip][r]*w[3][r];
 
8811
      }// end loop over 'r'
 
8812
      
 
8813
      // Total number of operations to compute function values = 8
 
8814
      for (unsigned int r = 0; r < 2; r++)
 
8815
      {
 
8816
        F2 += FE1_D01[ip][r]*w[2][nzc1[r]];
 
8817
        F3 += FE1_D01[ip][r]*w[2][nzc0[r]];
 
8818
      }// end loop over 'r'
 
8819
      
 
8820
      // Total number of operations to compute function values = 6
 
8821
      for (unsigned int r = 0; r < 3; r++)
 
8822
      {
 
8823
        F0 += FE1[ip][r]*w[0][r];
 
8824
      }// end loop over 'r'
 
8825
      
 
8826
      // Number of operations to compute ip constants: 23
 
8827
      double I[3];
 
8828
      // Number of operations: 13
 
8829
      I[0] = W9[ip]*(F0*F1*det + F2*(F4*G[0] + F5*G[1]) + F3*(F4*G[1] + F5*G[2]));
 
8830
      
 
8831
      // Number of operations: 5
 
8832
      I[1] = F1*W9[ip]*(F2*G[0] + F3*G[1]);
 
8833
      
 
8834
      // Number of operations: 5
 
8835
      I[2] = F1*W9[ip]*(F2*G[1] + F3*G[2]);
 
8836
      
 
8837
      
 
8838
      // Number of operations for primary indices: 6
 
8839
      for (unsigned int j = 0; j < 3; j++)
 
8840
      {
 
8841
        // Number of operations to compute entry: 2
 
8842
        A[j] += FE1[ip][j]*I[0];
 
8843
      }// end loop over 'j'
 
8844
      
 
8845
      // Number of operations for primary indices: 8
 
8846
      for (unsigned int j = 0; j < 2; j++)
 
8847
      {
 
8848
        // Number of operations to compute entry: 2
 
8849
        A[nzc1[j]] += FE1_D01[ip][j]*I[1];
 
8850
        // Number of operations to compute entry: 2
 
8851
        A[nzc0[j]] += FE1_D01[ip][j]*I[2];
 
8852
      }// end loop over 'j'
 
8853
    }// end loop over 'ip'
 
8854
  }
 
8855
 
 
8856
  /// Tabulate the tensor for the contribution from a local cell
 
8857
  /// using the specified reference cell quadrature points/weights
 
8858
  virtual void tabulate_tensor(double* A,
 
8859
                               const double * const * w,
 
8860
                               const ufc::cell& c,
 
8861
                               unsigned int num_quadrature_points,
 
8862
                               const double * const * quadrature_points,
 
8863
                               const double* quadrature_weights) const
 
8864
  {
 
8865
    throw std::runtime_error("Quadrature version of tabulate_tensor not yet implemented (introduced in UFC 2.0).");
 
8866
  }
 
8867
 
 
8868
};
 
8869
 
 
8870
/// This class defines the interface for the tabulation of the
 
8871
/// exterior facet tensor corresponding to the local contribution to
 
8872
/// a form from the integral over an exterior facet.
 
8873
 
 
8874
class adaptivepoisson_exterior_facet_integral_3_0: public ufc::exterior_facet_integral
 
8875
{
 
8876
public:
 
8877
 
 
8878
  /// Constructor
 
8879
  adaptivepoisson_exterior_facet_integral_3_0() : ufc::exterior_facet_integral()
 
8880
  {
 
8881
    // Do nothing
 
8882
  }
 
8883
 
 
8884
  /// Destructor
 
8885
  virtual ~adaptivepoisson_exterior_facet_integral_3_0()
 
8886
  {
 
8887
    // Do nothing
 
8888
  }
 
8889
 
 
8890
  /// Tabulate the tensor for the contribution from a local exterior facet
 
8891
  virtual void tabulate_tensor(double* A,
 
8892
                               const double * const * w,
 
8893
                               const ufc::cell& c,
 
8894
                               unsigned int facet) const
 
8895
  {
 
8896
    // Number of operations (multiply-add pairs) for Jacobian data:      6
 
8897
    // Number of operations (multiply-add pairs) for geometry tensor:    0
 
8898
    // Number of operations (multiply-add pairs) for tensor contraction: 0
 
8899
    // Total number of operations (multiply-add pairs):                  6
 
8900
    
 
8901
    // Extract vertex coordinates
 
8902
    
 
8903
    // Compute Jacobian of affine map from reference cell
 
8904
    
 
8905
    // Compute determinant of Jacobian
 
8906
    
 
8907
    // Compute inverse of Jacobian
 
8908
    
 
8909
    // Get vertices on edge
 
8910
    
 
8911
    // Compute scale factor (length of edge scaled by length of reference interval)
 
8912
    
 
8913
    // Compute geometry tensor
 
8914
    
 
8915
    
 
8916
    // Compute element tensor
 
8917
    switch (facet)
 
8918
    {
 
8919
    case 0:
 
8920
      {
 
8921
        A[0] = 0.000000000000000;
 
8922
      A[1] = 0.000000000000000;
 
8923
      A[2] = 0.000000000000000;
 
8924
        break;
 
8925
      }
 
8926
    case 1:
 
8927
      {
 
8928
        A[0] = 0.000000000000000;
 
8929
      A[1] = 0.000000000000000;
 
8930
      A[2] = 0.000000000000000;
 
8931
        break;
 
8932
      }
 
8933
    case 2:
 
8934
      {
 
8935
        A[0] = 0.000000000000000;
 
8936
      A[1] = 0.000000000000000;
 
8937
      A[2] = 0.000000000000000;
 
8938
        break;
 
8939
      }
 
8940
    }
 
8941
    
 
8942
  }
 
8943
 
 
8944
  /// Tabulate the tensor for the contribution from a local exterior facet
 
8945
  /// using the specified reference cell quadrature points/weights
 
8946
  virtual void tabulate_tensor(double* A,
 
8947
                               const double * const * w,
 
8948
                               const ufc::cell& c,
 
8949
                               unsigned int num_quadrature_points,
 
8950
                               const double * const * quadrature_points,
 
8951
                               const double* quadrature_weights) const
 
8952
  {
 
8953
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
8954
  }
 
8955
 
 
8956
};
 
8957
 
 
8958
/// This class defines the interface for the tabulation of the
 
8959
/// exterior facet tensor corresponding to the local contribution to
 
8960
/// a form from the integral over an exterior facet.
 
8961
 
 
8962
class adaptivepoisson_exterior_facet_integral_4_0: public ufc::exterior_facet_integral
 
8963
{
 
8964
public:
 
8965
 
 
8966
  /// Constructor
 
8967
  adaptivepoisson_exterior_facet_integral_4_0() : ufc::exterior_facet_integral()
 
8968
  {
 
8969
    // Do nothing
 
8970
  }
 
8971
 
 
8972
  /// Destructor
 
8973
  virtual ~adaptivepoisson_exterior_facet_integral_4_0()
 
8974
  {
 
8975
    // Do nothing
 
8976
  }
 
8977
 
 
8978
  /// Tabulate the tensor for the contribution from a local exterior facet
 
8979
  virtual void tabulate_tensor(double* A,
 
8980
                               const double * const * w,
 
8981
                               const ufc::cell& c,
 
8982
                               unsigned int facet) const
 
8983
  {
 
8984
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
8985
    // Number of operations (multiply-add pairs) for geometry tensor:    6
 
8986
    // Number of operations (multiply-add pairs) for tensor contraction: 30
 
8987
    // Total number of operations (multiply-add pairs):                  45
 
8988
    
 
8989
    // Extract vertex coordinates
 
8990
    const double * const * x = c.coordinates;
 
8991
    
 
8992
    // Compute Jacobian of affine map from reference cell
 
8993
    
 
8994
    // Compute determinant of Jacobian
 
8995
    
 
8996
    // Compute inverse of Jacobian
 
8997
    
 
8998
    // Get vertices on edge
 
8999
    static unsigned int edge_vertices[3][2] = {{1, 2}, {0, 2}, {0, 1}};
 
9000
    const unsigned int v0 = edge_vertices[facet][0];
 
9001
    const unsigned int v1 = edge_vertices[facet][1];
 
9002
    
 
9003
    // Compute scale factor (length of edge scaled by length of reference interval)
 
9004
    const double dx0 = x[v1][0] - x[v0][0];
 
9005
    const double dx1 = x[v1][1] - x[v0][1];
 
9006
    const double det = std::sqrt(dx0*dx0 + dx1*dx1);
 
9007
    
 
9008
    // Compute geometry tensor
 
9009
    const double G0_0 = det*w[0][0]*(1.0);
 
9010
    const double G0_1 = det*w[0][1]*(1.0);
 
9011
    const double G0_2 = det*w[0][2]*(1.0);
 
9012
    const double G0_3 = det*w[0][3]*(1.0);
 
9013
    const double G0_4 = det*w[0][4]*(1.0);
 
9014
    const double G0_5 = det*w[0][5]*(1.0);
 
9015
    
 
9016
    // Compute element tensor
 
9017
    switch (facet)
 
9018
    {
 
9019
    case 0:
 
9020
      {
 
9021
        A[0] = 0.000000000000000;
 
9022
      A[1] = 0.000000000000000;
 
9023
      A[2] = 0.000000000000000;
 
9024
      A[3] = 0.000000000000000;
 
9025
      A[4] = 0.150000000000000*G0_1 - 0.016666666666667*G0_2 + 0.200000000000000*G0_3;
 
9026
      A[5] = 0.016666666666667*G0_1 + 0.016666666666667*G0_2 + 0.133333333333333*G0_3;
 
9027
      A[6] = 0.000000000000000;
 
9028
      A[7] = 0.016666666666667*G0_1 + 0.016666666666667*G0_2 + 0.133333333333333*G0_3;
 
9029
      A[8] = -0.016666666666667*G0_1 + 0.150000000000000*G0_2 + 0.200000000000000*G0_3;
 
9030
        break;
 
9031
      }
 
9032
    case 1:
 
9033
      {
 
9034
        A[0] = 0.150000000000000*G0_0 - 0.016666666666667*G0_2 + 0.200000000000000*G0_4;
 
9035
      A[1] = 0.000000000000000;
 
9036
      A[2] = 0.016666666666667*G0_0 + 0.016666666666667*G0_2 + 0.133333333333333*G0_4;
 
9037
      A[3] = 0.000000000000000;
 
9038
      A[4] = 0.000000000000000;
 
9039
      A[5] = 0.000000000000000;
 
9040
      A[6] = 0.016666666666667*G0_0 + 0.016666666666667*G0_2 + 0.133333333333333*G0_4;
 
9041
      A[7] = 0.000000000000000;
 
9042
      A[8] = -0.016666666666667*G0_0 + 0.150000000000000*G0_2 + 0.200000000000000*G0_4;
 
9043
        break;
 
9044
      }
 
9045
    case 2:
 
9046
      {
 
9047
        A[0] = 0.150000000000000*G0_0 - 0.016666666666667*G0_1 + 0.200000000000000*G0_5;
 
9048
      A[1] = 0.016666666666667*G0_0 + 0.016666666666667*G0_1 + 0.133333333333333*G0_5;
 
9049
      A[2] = 0.000000000000000;
 
9050
      A[3] = 0.016666666666667*G0_0 + 0.016666666666667*G0_1 + 0.133333333333333*G0_5;
 
9051
      A[4] = -0.016666666666667*G0_0 + 0.150000000000000*G0_1 + 0.200000000000000*G0_5;
 
9052
      A[5] = 0.000000000000000;
 
9053
      A[6] = 0.000000000000000;
 
9054
      A[7] = 0.000000000000000;
 
9055
      A[8] = 0.000000000000000;
 
9056
        break;
 
9057
      }
 
9058
    }
 
9059
    
 
9060
  }
 
9061
 
 
9062
  /// Tabulate the tensor for the contribution from a local exterior facet
 
9063
  /// using the specified reference cell quadrature points/weights
 
9064
  virtual void tabulate_tensor(double* A,
 
9065
                               const double * const * w,
 
9066
                               const ufc::cell& c,
 
9067
                               unsigned int num_quadrature_points,
 
9068
                               const double * const * quadrature_points,
 
9069
                               const double* quadrature_weights) const
 
9070
  {
 
9071
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
9072
  }
 
9073
 
 
9074
};
 
9075
 
 
9076
/// This class defines the interface for the tabulation of the
 
9077
/// interior facet tensor corresponding to the local contribution to
 
9078
/// a form from the integral over an interior facet.
 
9079
 
 
9080
class adaptivepoisson_interior_facet_integral_4_0: public ufc::interior_facet_integral
 
9081
{
 
9082
public:
 
9083
 
 
9084
  /// Constructor
 
9085
  adaptivepoisson_interior_facet_integral_4_0() : ufc::interior_facet_integral()
 
9086
  {
 
9087
    // Do nothing
 
9088
  }
 
9089
 
 
9090
  /// Destructor
 
9091
  virtual ~adaptivepoisson_interior_facet_integral_4_0()
 
9092
  {
 
9093
    // Do nothing
 
9094
  }
 
9095
 
 
9096
  /// Tabulate the tensor for the contribution from a local interior facet
 
9097
  virtual void tabulate_tensor(double* A,
 
9098
                               const double * const * w,
 
9099
                               const ufc::cell& c0,
 
9100
                               const ufc::cell& c1,
 
9101
                               unsigned int facet0,
 
9102
                               unsigned int facet1) const
 
9103
  {
 
9104
    // Number of operations (multiply-add pairs) for Jacobian data:      12
 
9105
    // Number of operations (multiply-add pairs) for geometry tensor:    12
 
9106
    // Number of operations (multiply-add pairs) for tensor contraction: 180
 
9107
    // Total number of operations (multiply-add pairs):                  204
 
9108
    
 
9109
    // Extract vertex coordinates
 
9110
    const double * const * x0 = c0.coordinates;
 
9111
    
 
9112
    // Compute Jacobian of affine map from reference cell
 
9113
    
 
9114
    // Compute determinant of Jacobian
 
9115
    
 
9116
    // Compute inverse of Jacobian
 
9117
    
 
9118
    // Compute Jacobian of affine map from reference cell
 
9119
    
 
9120
    // Compute determinant of Jacobian
 
9121
    
 
9122
    // Compute inverse of Jacobian
 
9123
    
 
9124
    // Get vertices on edge
 
9125
    static unsigned int edge_vertices[3][2] = {{1, 2}, {0, 2}, {0, 1}};
 
9126
    const unsigned int v0 = edge_vertices[facet0][0];
 
9127
    const unsigned int v1 = edge_vertices[facet0][1];
 
9128
    
 
9129
    // Compute scale factor (length of edge scaled by length of reference interval)
 
9130
    const double dx0 = x0[v1][0] - x0[v0][0];
 
9131
    const double dx1 = x0[v1][1] - x0[v0][1];
 
9132
    const double det = std::sqrt(dx0*dx0 + dx1*dx1);
 
9133
    
 
9134
    // Compute geometry tensor
 
9135
    const double G0_6 = det*w[0][6]*(1.0);
 
9136
    const double G0_7 = det*w[0][7]*(1.0);
 
9137
    const double G0_8 = det*w[0][8]*(1.0);
 
9138
    const double G0_9 = det*w[0][9]*(1.0);
 
9139
    const double G0_10 = det*w[0][10]*(1.0);
 
9140
    const double G0_11 = det*w[0][11]*(1.0);
 
9141
    const double G1_0 = det*w[0][0]*(1.0);
 
9142
    const double G1_1 = det*w[0][1]*(1.0);
 
9143
    const double G1_2 = det*w[0][2]*(1.0);
 
9144
    const double G1_3 = det*w[0][3]*(1.0);
 
9145
    const double G1_4 = det*w[0][4]*(1.0);
 
9146
    const double G1_5 = det*w[0][5]*(1.0);
 
9147
    
 
9148
    // Compute element tensor
 
9149
    switch (facet0)
 
9150
    {
 
9151
    case 0:
 
9152
      {
 
9153
        switch (facet1)
 
9154
      {
 
9155
      case 0:
 
9156
        {
 
9157
          A[0] = 0.000000000000000;
 
9158
        A[1] = 0.000000000000000;
 
9159
        A[2] = 0.000000000000000;
 
9160
        A[3] = 0.000000000000000;
 
9161
        A[4] = 0.000000000000000;
 
9162
        A[5] = 0.000000000000000;
 
9163
        A[6] = 0.000000000000000;
 
9164
        A[7] = 0.150000000000000*G1_1 - 0.016666666666667*G1_2 + 0.200000000000000*G1_3;
 
9165
        A[8] = 0.016666666666667*G1_1 + 0.016666666666667*G1_2 + 0.133333333333333*G1_3;
 
9166
        A[9] = 0.000000000000000;
 
9167
        A[10] = 0.000000000000000;
 
9168
        A[11] = 0.000000000000000;
 
9169
        A[12] = 0.000000000000000;
 
9170
        A[13] = 0.016666666666667*G1_1 + 0.016666666666667*G1_2 + 0.133333333333333*G1_3;
 
9171
        A[14] = -0.016666666666667*G1_1 + 0.150000000000000*G1_2 + 0.200000000000000*G1_3;
 
9172
        A[15] = 0.000000000000000;
 
9173
        A[16] = 0.000000000000000;
 
9174
        A[17] = 0.000000000000000;
 
9175
        A[18] = 0.000000000000000;
 
9176
        A[19] = 0.000000000000000;
 
9177
        A[20] = 0.000000000000000;
 
9178
        A[21] = 0.000000000000000;
 
9179
        A[22] = 0.000000000000000;
 
9180
        A[23] = 0.000000000000000;
 
9181
        A[24] = 0.000000000000000;
 
9182
        A[25] = 0.000000000000000;
 
9183
        A[26] = 0.000000000000000;
 
9184
        A[27] = 0.000000000000000;
 
9185
        A[28] = 0.150000000000000*G0_7 - 0.016666666666667*G0_8 + 0.200000000000000*G0_9;
 
9186
        A[29] = 0.016666666666667*G0_7 + 0.016666666666667*G0_8 + 0.133333333333333*G0_9;
 
9187
        A[30] = 0.000000000000000;
 
9188
        A[31] = 0.000000000000000;
 
9189
        A[32] = 0.000000000000000;
 
9190
        A[33] = 0.000000000000000;
 
9191
        A[34] = 0.016666666666667*G0_7 + 0.016666666666667*G0_8 + 0.133333333333333*G0_9;
 
9192
        A[35] = -0.016666666666667*G0_7 + 0.150000000000000*G0_8 + 0.200000000000000*G0_9;
 
9193
          break;
 
9194
        }
 
9195
      case 1:
 
9196
        {
 
9197
          A[0] = 0.000000000000000;
 
9198
        A[1] = 0.000000000000000;
 
9199
        A[2] = 0.000000000000000;
 
9200
        A[3] = 0.000000000000000;
 
9201
        A[4] = 0.000000000000000;
 
9202
        A[5] = 0.000000000000000;
 
9203
        A[6] = 0.000000000000000;
 
9204
        A[7] = 0.150000000000000*G1_1 - 0.016666666666667*G1_2 + 0.200000000000000*G1_3;
 
9205
        A[8] = 0.016666666666667*G1_1 + 0.016666666666667*G1_2 + 0.133333333333333*G1_3;
 
9206
        A[9] = 0.000000000000000;
 
9207
        A[10] = 0.000000000000000;
 
9208
        A[11] = 0.000000000000000;
 
9209
        A[12] = 0.000000000000000;
 
9210
        A[13] = 0.016666666666667*G1_1 + 0.016666666666667*G1_2 + 0.133333333333333*G1_3;
 
9211
        A[14] = -0.016666666666667*G1_1 + 0.150000000000000*G1_2 + 0.200000000000000*G1_3;
 
9212
        A[15] = 0.000000000000000;
 
9213
        A[16] = 0.000000000000000;
 
9214
        A[17] = 0.000000000000000;
 
9215
        A[18] = 0.000000000000000;
 
9216
        A[19] = 0.000000000000000;
 
9217
        A[20] = 0.000000000000000;
 
9218
        A[21] = 0.150000000000000*G0_6 - 0.016666666666667*G0_8 + 0.200000000000000*G0_10;
 
9219
        A[22] = 0.000000000000000;
 
9220
        A[23] = 0.016666666666667*G0_6 + 0.016666666666667*G0_8 + 0.133333333333333*G0_10;
 
9221
        A[24] = 0.000000000000000;
 
9222
        A[25] = 0.000000000000000;
 
9223
        A[26] = 0.000000000000000;
 
9224
        A[27] = 0.000000000000000;
 
9225
        A[28] = 0.000000000000000;
 
9226
        A[29] = 0.000000000000000;
 
9227
        A[30] = 0.000000000000000;
 
9228
        A[31] = 0.000000000000000;
 
9229
        A[32] = 0.000000000000000;
 
9230
        A[33] = 0.016666666666667*G0_6 + 0.016666666666667*G0_8 + 0.133333333333333*G0_10;
 
9231
        A[34] = 0.000000000000000;
 
9232
        A[35] = -0.016666666666667*G0_6 + 0.150000000000000*G0_8 + 0.200000000000000*G0_10;
 
9233
          break;
 
9234
        }
 
9235
      case 2:
 
9236
        {
 
9237
          A[0] = 0.000000000000000;
 
9238
        A[1] = 0.000000000000000;
 
9239
        A[2] = 0.000000000000000;
 
9240
        A[3] = 0.000000000000000;
 
9241
        A[4] = 0.000000000000000;
 
9242
        A[5] = 0.000000000000000;
 
9243
        A[6] = 0.000000000000000;
 
9244
        A[7] = 0.150000000000000*G1_1 - 0.016666666666667*G1_2 + 0.200000000000000*G1_3;
 
9245
        A[8] = 0.016666666666667*G1_1 + 0.016666666666667*G1_2 + 0.133333333333333*G1_3;
 
9246
        A[9] = 0.000000000000000;
 
9247
        A[10] = 0.000000000000000;
 
9248
        A[11] = 0.000000000000000;
 
9249
        A[12] = 0.000000000000000;
 
9250
        A[13] = 0.016666666666667*G1_1 + 0.016666666666667*G1_2 + 0.133333333333333*G1_3;
 
9251
        A[14] = -0.016666666666667*G1_1 + 0.150000000000000*G1_2 + 0.200000000000000*G1_3;
 
9252
        A[15] = 0.000000000000000;
 
9253
        A[16] = 0.000000000000000;
 
9254
        A[17] = 0.000000000000000;
 
9255
        A[18] = 0.000000000000000;
 
9256
        A[19] = 0.000000000000000;
 
9257
        A[20] = 0.000000000000000;
 
9258
        A[21] = 0.150000000000000*G0_6 - 0.016666666666667*G0_7 + 0.200000000000000*G0_11;
 
9259
        A[22] = 0.016666666666667*G0_6 + 0.016666666666667*G0_7 + 0.133333333333333*G0_11;
 
9260
        A[23] = 0.000000000000000;
 
9261
        A[24] = 0.000000000000000;
 
9262
        A[25] = 0.000000000000000;
 
9263
        A[26] = 0.000000000000000;
 
9264
        A[27] = 0.016666666666667*G0_6 + 0.016666666666667*G0_7 + 0.133333333333333*G0_11;
 
9265
        A[28] = -0.016666666666667*G0_6 + 0.150000000000000*G0_7 + 0.200000000000000*G0_11;
 
9266
        A[29] = 0.000000000000000;
 
9267
        A[30] = 0.000000000000000;
 
9268
        A[31] = 0.000000000000000;
 
9269
        A[32] = 0.000000000000000;
 
9270
        A[33] = 0.000000000000000;
 
9271
        A[34] = 0.000000000000000;
 
9272
        A[35] = 0.000000000000000;
 
9273
          break;
 
9274
        }
 
9275
      }
 
9276
      
 
9277
        break;
 
9278
      }
 
9279
    case 1:
 
9280
      {
 
9281
        switch (facet1)
 
9282
      {
 
9283
      case 0:
 
9284
        {
 
9285
          A[0] = 0.150000000000000*G1_0 - 0.016666666666667*G1_2 + 0.200000000000000*G1_4;
 
9286
        A[1] = 0.000000000000000;
 
9287
        A[2] = 0.016666666666667*G1_0 + 0.016666666666667*G1_2 + 0.133333333333333*G1_4;
 
9288
        A[3] = 0.000000000000000;
 
9289
        A[4] = 0.000000000000000;
 
9290
        A[5] = 0.000000000000000;
 
9291
        A[6] = 0.000000000000000;
 
9292
        A[7] = 0.000000000000000;
 
9293
        A[8] = 0.000000000000000;
 
9294
        A[9] = 0.000000000000000;
 
9295
        A[10] = 0.000000000000000;
 
9296
        A[11] = 0.000000000000000;
 
9297
        A[12] = 0.016666666666667*G1_0 + 0.016666666666667*G1_2 + 0.133333333333333*G1_4;
 
9298
        A[13] = 0.000000000000000;
 
9299
        A[14] = -0.016666666666667*G1_0 + 0.150000000000000*G1_2 + 0.200000000000000*G1_4;
 
9300
        A[15] = 0.000000000000000;
 
9301
        A[16] = 0.000000000000000;
 
9302
        A[17] = 0.000000000000000;
 
9303
        A[18] = 0.000000000000000;
 
9304
        A[19] = 0.000000000000000;
 
9305
        A[20] = 0.000000000000000;
 
9306
        A[21] = 0.000000000000000;
 
9307
        A[22] = 0.000000000000000;
 
9308
        A[23] = 0.000000000000000;
 
9309
        A[24] = 0.000000000000000;
 
9310
        A[25] = 0.000000000000000;
 
9311
        A[26] = 0.000000000000000;
 
9312
        A[27] = 0.000000000000000;
 
9313
        A[28] = 0.150000000000000*G0_7 - 0.016666666666667*G0_8 + 0.200000000000000*G0_9;
 
9314
        A[29] = 0.016666666666667*G0_7 + 0.016666666666667*G0_8 + 0.133333333333333*G0_9;
 
9315
        A[30] = 0.000000000000000;
 
9316
        A[31] = 0.000000000000000;
 
9317
        A[32] = 0.000000000000000;
 
9318
        A[33] = 0.000000000000000;
 
9319
        A[34] = 0.016666666666667*G0_7 + 0.016666666666667*G0_8 + 0.133333333333333*G0_9;
 
9320
        A[35] = -0.016666666666667*G0_7 + 0.150000000000000*G0_8 + 0.200000000000000*G0_9;
 
9321
          break;
 
9322
        }
 
9323
      case 1:
 
9324
        {
 
9325
          A[0] = 0.150000000000000*G1_0 - 0.016666666666667*G1_2 + 0.200000000000000*G1_4;
 
9326
        A[1] = 0.000000000000000;
 
9327
        A[2] = 0.016666666666667*G1_0 + 0.016666666666667*G1_2 + 0.133333333333333*G1_4;
 
9328
        A[3] = 0.000000000000000;
 
9329
        A[4] = 0.000000000000000;
 
9330
        A[5] = 0.000000000000000;
 
9331
        A[6] = 0.000000000000000;
 
9332
        A[7] = 0.000000000000000;
 
9333
        A[8] = 0.000000000000000;
 
9334
        A[9] = 0.000000000000000;
 
9335
        A[10] = 0.000000000000000;
 
9336
        A[11] = 0.000000000000000;
 
9337
        A[12] = 0.016666666666667*G1_0 + 0.016666666666667*G1_2 + 0.133333333333333*G1_4;
 
9338
        A[13] = 0.000000000000000;
 
9339
        A[14] = -0.016666666666667*G1_0 + 0.150000000000000*G1_2 + 0.200000000000000*G1_4;
 
9340
        A[15] = 0.000000000000000;
 
9341
        A[16] = 0.000000000000000;
 
9342
        A[17] = 0.000000000000000;
 
9343
        A[18] = 0.000000000000000;
 
9344
        A[19] = 0.000000000000000;
 
9345
        A[20] = 0.000000000000000;
 
9346
        A[21] = 0.150000000000000*G0_6 - 0.016666666666667*G0_8 + 0.200000000000000*G0_10;
 
9347
        A[22] = 0.000000000000000;
 
9348
        A[23] = 0.016666666666667*G0_6 + 0.016666666666667*G0_8 + 0.133333333333333*G0_10;
 
9349
        A[24] = 0.000000000000000;
 
9350
        A[25] = 0.000000000000000;
 
9351
        A[26] = 0.000000000000000;
 
9352
        A[27] = 0.000000000000000;
 
9353
        A[28] = 0.000000000000000;
 
9354
        A[29] = 0.000000000000000;
 
9355
        A[30] = 0.000000000000000;
 
9356
        A[31] = 0.000000000000000;
 
9357
        A[32] = 0.000000000000000;
 
9358
        A[33] = 0.016666666666667*G0_6 + 0.016666666666667*G0_8 + 0.133333333333333*G0_10;
 
9359
        A[34] = 0.000000000000000;
 
9360
        A[35] = -0.016666666666667*G0_6 + 0.150000000000000*G0_8 + 0.200000000000000*G0_10;
 
9361
          break;
 
9362
        }
 
9363
      case 2:
 
9364
        {
 
9365
          A[0] = 0.150000000000000*G1_0 - 0.016666666666667*G1_2 + 0.200000000000000*G1_4;
 
9366
        A[1] = 0.000000000000000;
 
9367
        A[2] = 0.016666666666667*G1_0 + 0.016666666666667*G1_2 + 0.133333333333333*G1_4;
 
9368
        A[3] = 0.000000000000000;
 
9369
        A[4] = 0.000000000000000;
 
9370
        A[5] = 0.000000000000000;
 
9371
        A[6] = 0.000000000000000;
 
9372
        A[7] = 0.000000000000000;
 
9373
        A[8] = 0.000000000000000;
 
9374
        A[9] = 0.000000000000000;
 
9375
        A[10] = 0.000000000000000;
 
9376
        A[11] = 0.000000000000000;
 
9377
        A[12] = 0.016666666666667*G1_0 + 0.016666666666667*G1_2 + 0.133333333333333*G1_4;
 
9378
        A[13] = 0.000000000000000;
 
9379
        A[14] = -0.016666666666667*G1_0 + 0.150000000000000*G1_2 + 0.200000000000000*G1_4;
 
9380
        A[15] = 0.000000000000000;
 
9381
        A[16] = 0.000000000000000;
 
9382
        A[17] = 0.000000000000000;
 
9383
        A[18] = 0.000000000000000;
 
9384
        A[19] = 0.000000000000000;
 
9385
        A[20] = 0.000000000000000;
 
9386
        A[21] = 0.150000000000000*G0_6 - 0.016666666666667*G0_7 + 0.200000000000000*G0_11;
 
9387
        A[22] = 0.016666666666667*G0_6 + 0.016666666666667*G0_7 + 0.133333333333333*G0_11;
 
9388
        A[23] = 0.000000000000000;
 
9389
        A[24] = 0.000000000000000;
 
9390
        A[25] = 0.000000000000000;
 
9391
        A[26] = 0.000000000000000;
 
9392
        A[27] = 0.016666666666667*G0_6 + 0.016666666666667*G0_7 + 0.133333333333333*G0_11;
 
9393
        A[28] = -0.016666666666667*G0_6 + 0.150000000000000*G0_7 + 0.200000000000000*G0_11;
 
9394
        A[29] = 0.000000000000000;
 
9395
        A[30] = 0.000000000000000;
 
9396
        A[31] = 0.000000000000000;
 
9397
        A[32] = 0.000000000000000;
 
9398
        A[33] = 0.000000000000000;
 
9399
        A[34] = 0.000000000000000;
 
9400
        A[35] = 0.000000000000000;
 
9401
          break;
 
9402
        }
 
9403
      }
 
9404
      
 
9405
        break;
 
9406
      }
 
9407
    case 2:
 
9408
      {
 
9409
        switch (facet1)
 
9410
      {
 
9411
      case 0:
 
9412
        {
 
9413
          A[0] = 0.150000000000000*G1_0 - 0.016666666666667*G1_1 + 0.200000000000000*G1_5;
 
9414
        A[1] = 0.016666666666667*G1_0 + 0.016666666666667*G1_1 + 0.133333333333333*G1_5;
 
9415
        A[2] = 0.000000000000000;
 
9416
        A[3] = 0.000000000000000;
 
9417
        A[4] = 0.000000000000000;
 
9418
        A[5] = 0.000000000000000;
 
9419
        A[6] = 0.016666666666667*G1_0 + 0.016666666666667*G1_1 + 0.133333333333333*G1_5;
 
9420
        A[7] = -0.016666666666667*G1_0 + 0.150000000000000*G1_1 + 0.200000000000000*G1_5;
 
9421
        A[8] = 0.000000000000000;
 
9422
        A[9] = 0.000000000000000;
 
9423
        A[10] = 0.000000000000000;
 
9424
        A[11] = 0.000000000000000;
 
9425
        A[12] = 0.000000000000000;
 
9426
        A[13] = 0.000000000000000;
 
9427
        A[14] = 0.000000000000000;
 
9428
        A[15] = 0.000000000000000;
 
9429
        A[16] = 0.000000000000000;
 
9430
        A[17] = 0.000000000000000;
 
9431
        A[18] = 0.000000000000000;
 
9432
        A[19] = 0.000000000000000;
 
9433
        A[20] = 0.000000000000000;
 
9434
        A[21] = 0.000000000000000;
 
9435
        A[22] = 0.000000000000000;
 
9436
        A[23] = 0.000000000000000;
 
9437
        A[24] = 0.000000000000000;
 
9438
        A[25] = 0.000000000000000;
 
9439
        A[26] = 0.000000000000000;
 
9440
        A[27] = 0.000000000000000;
 
9441
        A[28] = 0.150000000000000*G0_7 - 0.016666666666667*G0_8 + 0.200000000000000*G0_9;
 
9442
        A[29] = 0.016666666666667*G0_7 + 0.016666666666667*G0_8 + 0.133333333333333*G0_9;
 
9443
        A[30] = 0.000000000000000;
 
9444
        A[31] = 0.000000000000000;
 
9445
        A[32] = 0.000000000000000;
 
9446
        A[33] = 0.000000000000000;
 
9447
        A[34] = 0.016666666666667*G0_7 + 0.016666666666667*G0_8 + 0.133333333333333*G0_9;
 
9448
        A[35] = -0.016666666666667*G0_7 + 0.150000000000000*G0_8 + 0.200000000000000*G0_9;
 
9449
          break;
 
9450
        }
 
9451
      case 1:
 
9452
        {
 
9453
          A[0] = 0.150000000000000*G1_0 - 0.016666666666667*G1_1 + 0.200000000000000*G1_5;
 
9454
        A[1] = 0.016666666666667*G1_0 + 0.016666666666667*G1_1 + 0.133333333333333*G1_5;
 
9455
        A[2] = 0.000000000000000;
 
9456
        A[3] = 0.000000000000000;
 
9457
        A[4] = 0.000000000000000;
 
9458
        A[5] = 0.000000000000000;
 
9459
        A[6] = 0.016666666666667*G1_0 + 0.016666666666667*G1_1 + 0.133333333333333*G1_5;
 
9460
        A[7] = -0.016666666666667*G1_0 + 0.150000000000000*G1_1 + 0.200000000000000*G1_5;
 
9461
        A[8] = 0.000000000000000;
 
9462
        A[9] = 0.000000000000000;
 
9463
        A[10] = 0.000000000000000;
 
9464
        A[11] = 0.000000000000000;
 
9465
        A[12] = 0.000000000000000;
 
9466
        A[13] = 0.000000000000000;
 
9467
        A[14] = 0.000000000000000;
 
9468
        A[15] = 0.000000000000000;
 
9469
        A[16] = 0.000000000000000;
 
9470
        A[17] = 0.000000000000000;
 
9471
        A[18] = 0.000000000000000;
 
9472
        A[19] = 0.000000000000000;
 
9473
        A[20] = 0.000000000000000;
 
9474
        A[21] = 0.150000000000000*G0_6 - 0.016666666666667*G0_8 + 0.200000000000000*G0_10;
 
9475
        A[22] = 0.000000000000000;
 
9476
        A[23] = 0.016666666666667*G0_6 + 0.016666666666667*G0_8 + 0.133333333333333*G0_10;
 
9477
        A[24] = 0.000000000000000;
 
9478
        A[25] = 0.000000000000000;
 
9479
        A[26] = 0.000000000000000;
 
9480
        A[27] = 0.000000000000000;
 
9481
        A[28] = 0.000000000000000;
 
9482
        A[29] = 0.000000000000000;
 
9483
        A[30] = 0.000000000000000;
 
9484
        A[31] = 0.000000000000000;
 
9485
        A[32] = 0.000000000000000;
 
9486
        A[33] = 0.016666666666667*G0_6 + 0.016666666666667*G0_8 + 0.133333333333333*G0_10;
 
9487
        A[34] = 0.000000000000000;
 
9488
        A[35] = -0.016666666666667*G0_6 + 0.150000000000000*G0_8 + 0.200000000000000*G0_10;
 
9489
          break;
 
9490
        }
 
9491
      case 2:
 
9492
        {
 
9493
          A[0] = 0.150000000000000*G1_0 - 0.016666666666667*G1_1 + 0.200000000000000*G1_5;
 
9494
        A[1] = 0.016666666666667*G1_0 + 0.016666666666667*G1_1 + 0.133333333333333*G1_5;
 
9495
        A[2] = 0.000000000000000;
 
9496
        A[3] = 0.000000000000000;
 
9497
        A[4] = 0.000000000000000;
 
9498
        A[5] = 0.000000000000000;
 
9499
        A[6] = 0.016666666666667*G1_0 + 0.016666666666667*G1_1 + 0.133333333333333*G1_5;
 
9500
        A[7] = -0.016666666666667*G1_0 + 0.150000000000000*G1_1 + 0.200000000000000*G1_5;
 
9501
        A[8] = 0.000000000000000;
 
9502
        A[9] = 0.000000000000000;
 
9503
        A[10] = 0.000000000000000;
 
9504
        A[11] = 0.000000000000000;
 
9505
        A[12] = 0.000000000000000;
 
9506
        A[13] = 0.000000000000000;
 
9507
        A[14] = 0.000000000000000;
 
9508
        A[15] = 0.000000000000000;
 
9509
        A[16] = 0.000000000000000;
 
9510
        A[17] = 0.000000000000000;
 
9511
        A[18] = 0.000000000000000;
 
9512
        A[19] = 0.000000000000000;
 
9513
        A[20] = 0.000000000000000;
 
9514
        A[21] = 0.150000000000000*G0_6 - 0.016666666666667*G0_7 + 0.200000000000000*G0_11;
 
9515
        A[22] = 0.016666666666667*G0_6 + 0.016666666666667*G0_7 + 0.133333333333333*G0_11;
 
9516
        A[23] = 0.000000000000000;
 
9517
        A[24] = 0.000000000000000;
 
9518
        A[25] = 0.000000000000000;
 
9519
        A[26] = 0.000000000000000;
 
9520
        A[27] = 0.016666666666667*G0_6 + 0.016666666666667*G0_7 + 0.133333333333333*G0_11;
 
9521
        A[28] = -0.016666666666667*G0_6 + 0.150000000000000*G0_7 + 0.200000000000000*G0_11;
 
9522
        A[29] = 0.000000000000000;
 
9523
        A[30] = 0.000000000000000;
 
9524
        A[31] = 0.000000000000000;
 
9525
        A[32] = 0.000000000000000;
 
9526
        A[33] = 0.000000000000000;
 
9527
        A[34] = 0.000000000000000;
 
9528
        A[35] = 0.000000000000000;
 
9529
          break;
 
9530
        }
 
9531
      }
 
9532
      
 
9533
        break;
 
9534
      }
 
9535
    }
 
9536
    
 
9537
  }
 
9538
 
 
9539
  /// Tabulate the tensor for the contribution from a local interior facet
 
9540
  /// using the specified reference cell quadrature points/weights
 
9541
  virtual void tabulate_tensor(double* A,
 
9542
                               const double * const * w,
 
9543
                               const ufc::cell& c,
 
9544
                               unsigned int num_quadrature_points,
 
9545
                               const double * const * quadrature_points,
 
9546
                               const double* quadrature_weights) const
 
9547
  {
 
9548
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
9549
  }
 
9550
 
 
9551
};
 
9552
 
 
9553
/// This class defines the interface for the tabulation of the cell
 
9554
/// tensor corresponding to the local contribution to a form from
 
9555
/// the integral over a cell.
 
9556
 
 
9557
class adaptivepoisson_cell_integral_5_0: public ufc::cell_integral
 
9558
{
 
9559
public:
 
9560
 
 
9561
  /// Constructor
 
9562
  adaptivepoisson_cell_integral_5_0() : ufc::cell_integral()
 
9563
  {
 
9564
    // Do nothing
 
9565
  }
 
9566
 
 
9567
  /// Destructor
 
9568
  virtual ~adaptivepoisson_cell_integral_5_0()
 
9569
  {
 
9570
    // Do nothing
 
9571
  }
 
9572
 
 
9573
  /// Tabulate the tensor for the contribution from a local cell
 
9574
  virtual void tabulate_tensor(double* A,
 
9575
                               const double * const * w,
 
9576
                               const ufc::cell& c) const
 
9577
  {
 
9578
    // Extract vertex coordinates
 
9579
    const double * const * x = c.coordinates;
 
9580
    
 
9581
    // Compute Jacobian of affine map from reference cell
 
9582
    const double J_00 = x[1][0] - x[0][0];
 
9583
    const double J_01 = x[2][0] - x[0][0];
 
9584
    const double J_10 = x[1][1] - x[0][1];
 
9585
    const double J_11 = x[2][1] - x[0][1];
 
9586
    
 
9587
    // Compute determinant of Jacobian
 
9588
    double detJ = J_00*J_11 - J_01*J_10;
 
9589
    
 
9590
    // Compute inverse of Jacobian
 
9591
    const double K_00 =  J_11 / detJ;
 
9592
    const double K_01 = -J_01 / detJ;
 
9593
    const double K_10 = -J_10 / detJ;
 
9594
    const double K_11 =  J_00 / detJ;
 
9595
    
 
9596
    // Set scale factor
 
9597
    const double det = std::abs(detJ);
 
9598
    
 
9599
    // Cell Volume.
 
9600
    
 
9601
    // Compute circumradius, assuming triangle is embedded in 2D.
 
9602
    
 
9603
    
 
9604
    // Array of quadrature weights.
 
9605
    static const double W9[9] = {0.055814420483044, 0.063678085099885, 0.019396383305959, 0.089303072772871, 0.101884936159816, 0.031034213289535, 0.055814420483044, 0.063678085099885, 0.019396383305959};
 
9606
    // Quadrature points on the UFC reference element: (0.102717654809626, 0.088587959512704), (0.066554067839165, 0.409466864440735), (0.023931132287081, 0.787659461760847), (0.455706020243648, 0.088587959512704), (0.295266567779633, 0.409466864440735), (0.106170269119576, 0.787659461760847), (0.808694385677670, 0.088587959512704), (0.523979067720101, 0.409466864440735), (0.188409405952072, 0.787659461760847)
 
9607
    
 
9608
    // Value of basis functions at quadrature points.
 
9609
    static const double FE0[9][3] = \
 
9610
    {{0.808694385677670, 0.102717654809626, 0.088587959512704},
 
9611
    {0.523979067720101, 0.066554067839165, 0.409466864440735},
 
9612
    {0.188409405952072, 0.023931132287081, 0.787659461760847},
 
9613
    {0.455706020243648, 0.455706020243648, 0.088587959512704},
 
9614
    {0.295266567779633, 0.295266567779633, 0.409466864440735},
 
9615
    {0.106170269119576, 0.106170269119577, 0.787659461760847},
 
9616
    {0.102717654809626, 0.808694385677670, 0.088587959512704},
 
9617
    {0.066554067839164, 0.523979067720101, 0.409466864440735},
 
9618
    {0.023931132287081, 0.188409405952072, 0.787659461760847}};
 
9619
    
 
9620
    static const double FE0_D01[9][2] = \
 
9621
    {{-1.000000000000000, 1.000000000000000},
 
9622
    {-1.000000000000000, 1.000000000000000},
 
9623
    {-1.000000000000000, 1.000000000000000},
 
9624
    {-1.000000000000000, 1.000000000000000},
 
9625
    {-1.000000000000000, 1.000000000000000},
 
9626
    {-1.000000000000000, 1.000000000000000},
 
9627
    {-1.000000000000000, 1.000000000000000},
 
9628
    {-1.000000000000000, 1.000000000000000},
 
9629
    {-1.000000000000000, 1.000000000000000}};
 
9630
    
 
9631
    // Array of non-zero columns
 
9632
    static const unsigned int nzc1[2] = {0, 1};
 
9633
    
 
9634
    // Array of non-zero columns
 
9635
    static const unsigned int nzc0[2] = {0, 2};
 
9636
    
 
9637
    static const double FE2[9][6] = \
 
9638
    {{0.499278833175498, -0.081615821590447, -0.072892306371455, 0.036398189782060, 0.286562341986258, 0.332268763018087},
 
9639
    {0.025129059097551, -0.057695179947284, -0.074140638290881, 0.109006741895515, 0.858208263567716, 0.139491753677383},
 
9640
    {-0.117413197449647, -0.022785734101997, 0.453155393641927, 0.075398331106278, 0.593609805131561, 0.018035401671877},
 
9641
    {-0.040370066471040, -0.040370066471040, -0.072892306371455, 0.161480265884159, 0.161480265884159, 0.830671907545217},
 
9642
    {-0.120901875682904, -0.120901875682904, -0.074140638290881, 0.483607502731615, 0.483607502731615, 0.348729384193458},
 
9643
    {-0.083626017029730, -0.083626017029730, 0.453155393641927, 0.334504068118920, 0.334504068118920, 0.045088504179693},
 
9644
    {-0.081615821590447, 0.499278833175498, -0.072892306371455, 0.286562341986258, 0.036398189782060, 0.332268763018087},
 
9645
    {-0.057695179947284, 0.025129059097551, -0.074140638290881, 0.858208263567716, 0.109006741895515, 0.139491753677383},
 
9646
    {-0.022785734101997, -0.117413197449647, 0.453155393641927, 0.593609805131561, 0.075398331106278, 0.018035401671877}};
 
9647
    
 
9648
    static const double FE2_D01[9][5] = \
 
9649
    {{-2.234777542710679, -0.645648161949184, 0.410870619238505, 2.880425704659863, -0.410870619238505},
 
9650
    {-1.095916270880403, 0.637867457762939, 0.266216271356658, 0.458048813117464, -0.266216271356658},
 
9651
    {0.246362376191710, 2.150637847043388, 0.095724529148321, -2.397000223235098, -0.095724529148322},
 
9652
    {-0.822824080974592, -0.645648161949184, 1.822824080974592, 1.468472242923776, -1.822824080974592},
 
9653
    {-0.181066271118530, 0.637867457762939, 1.181066271118531, -0.456801186644409, -1.181066271118531},
 
9654
    {0.575318923521694, 2.150637847043388, 0.424681076478305, -2.725956770565081, -0.424681076478306},
 
9655
    {0.589129380761495, -0.645648161949184, 3.234777542710678, 0.056518781187689, -3.234777542710679},
 
9656
    {0.733783728643342, 0.637867457762939, 2.095916270880403, -1.371651186406281, -2.095916270880403},
 
9657
    {0.904275470851677, 2.150637847043388, 0.753637623808288, -3.054913317895065, -0.753637623808289}};
 
9658
    
 
9659
    // Array of non-zero columns
 
9660
    static const unsigned int nzc2[5] = {0, 2, 3, 4, 5};
 
9661
    
 
9662
    static const double FE2_D10[9][5] = \
 
9663
    {{-2.234777542710679, -0.589129380761495, 0.354351838050815, -0.354351838050816, 2.823906923472175},
 
9664
    {-1.095916270880403, -0.733783728643342, 1.637867457762939, -1.637867457762940, 1.829699999523745},
 
9665
    {0.246362376191711, -0.904275470851678, 3.150637847043387, -3.150637847043388, 0.657913094659968},
 
9666
    {-0.822824080974592, 0.822824080974592, 0.354351838050816, -0.354351838050816, 0.000000000000000},
 
9667
    {-0.181066271118530, 0.181066271118531, 1.637867457762939, -1.637867457762940, 0.000000000000000},
 
9668
    {0.575318923521694, -0.575318923521695, 3.150637847043387, -3.150637847043388, 0.000000000000000},
 
9669
    {0.589129380761495, 2.234777542710679, 0.354351838050815, -0.354351838050816, -2.823906923472174},
 
9670
    {0.733783728643342, 1.095916270880403, 1.637867457762939, -1.637867457762940, -1.829699999523746},
 
9671
    {0.904275470851678, -0.246362376191711, 3.150637847043387, -3.150637847043388, -0.657913094659966}};
 
9672
    
 
9673
    // Array of non-zero columns
 
9674
    static const unsigned int nzc3[5] = {0, 1, 3, 4, 5};
 
9675
    
 
9676
    // Reset values in the element tensor.
 
9677
    for (unsigned int r = 0; r < 3; r++)
 
9678
    {
 
9679
      A[r] = 0.000000000000000;
 
9680
    }// end loop over 'r'
 
9681
    // Number of operations to compute geometry constants: 12.
 
9682
    double G[3];
 
9683
    G[0] =  - det*(K_00*K_00 + K_01*K_01);
 
9684
    G[1] =  - det*(K_00*K_10 + K_01*K_11);
 
9685
    G[2] =  - det*(K_10*K_10 + K_11*K_11);
 
9686
    
 
9687
    // Compute element tensor using UFL quadrature representation
 
9688
    // Optimisations: ('eliminate zeros', True), ('ignore ones', True), ('ignore zero tables', True), ('optimisation', 'simplify_expressions'), ('remove zero terms', True)
 
9689
    
 
9690
    // Loop quadrature points for integral.
 
9691
    // Number of operations to compute element tensor for following IP loop = 810
 
9692
    for (unsigned int ip = 0; ip < 9; ip++)
 
9693
    {
 
9694
      
 
9695
      // Coefficient declarations.
 
9696
      double F0 = 0.000000000000000;
 
9697
      double F1 = 0.000000000000000;
 
9698
      double F2 = 0.000000000000000;
 
9699
      double F3 = 0.000000000000000;
 
9700
      double F4 = 0.000000000000000;
 
9701
      double F5 = 0.000000000000000;
 
9702
      double F6 = 0.000000000000000;
 
9703
      
 
9704
      // Total number of operations to compute function values = 8
 
9705
      for (unsigned int r = 0; r < 2; r++)
 
9706
      {
 
9707
        F3 += FE0_D01[ip][r]*w[2][nzc1[r]];
 
9708
        F4 += FE0_D01[ip][r]*w[2][nzc0[r]];
 
9709
      }// end loop over 'r'
 
9710
      
 
9711
      // Total number of operations to compute function values = 12
 
9712
      for (unsigned int r = 0; r < 3; r++)
 
9713
      {
 
9714
        F0 += FE0[ip][r]*w[3][r];
 
9715
        F2 += FE0[ip][r]*w[0][r];
 
9716
      }// end loop over 'r'
 
9717
      
 
9718
      // Total number of operations to compute function values = 20
 
9719
      for (unsigned int r = 0; r < 5; r++)
 
9720
      {
 
9721
        F5 += FE2_D10[ip][r]*w[4][nzc3[r]];
 
9722
        F6 += FE2_D01[ip][r]*w[4][nzc2[r]];
 
9723
      }// end loop over 'r'
 
9724
      
 
9725
      // Total number of operations to compute function values = 12
 
9726
      for (unsigned int r = 0; r < 6; r++)
 
9727
      {
 
9728
        F1 += FE2[ip][r]*w[4][r];
 
9729
      }// end loop over 'r'
 
9730
      
 
9731
      // Number of operations to compute ip constants: 24
 
9732
      double I[3];
 
9733
      // Number of operations: 14
 
9734
      I[0] = W9[ip]*(F1*det*(F2 - F0) + F5*(F3*G[0] + F4*G[1]) + F6*(F3*G[1] + F4*G[2]));
 
9735
      
 
9736
      // Number of operations: 5
 
9737
      I[1] = F1*W9[ip]*(F3*G[0] + F4*G[1]);
 
9738
      
 
9739
      // Number of operations: 5
 
9740
      I[2] = F1*W9[ip]*(F3*G[1] + F4*G[2]);
 
9741
      
 
9742
      
 
9743
      // Number of operations for primary indices: 6
 
9744
      for (unsigned int j = 0; j < 3; j++)
 
9745
      {
 
9746
        // Number of operations to compute entry: 2
 
9747
        A[j] += FE0[ip][j]*I[0];
 
9748
      }// end loop over 'j'
 
9749
      
 
9750
      // Number of operations for primary indices: 8
 
9751
      for (unsigned int j = 0; j < 2; j++)
 
9752
      {
 
9753
        // Number of operations to compute entry: 2
 
9754
        A[nzc1[j]] += FE0_D01[ip][j]*I[1];
 
9755
        // Number of operations to compute entry: 2
 
9756
        A[nzc0[j]] += FE0_D01[ip][j]*I[2];
 
9757
      }// end loop over 'j'
 
9758
    }// end loop over 'ip'
 
9759
  }
 
9760
 
 
9761
  /// Tabulate the tensor for the contribution from a local cell
 
9762
  /// using the specified reference cell quadrature points/weights
 
9763
  virtual void tabulate_tensor(double* A,
 
9764
                               const double * const * w,
 
9765
                               const ufc::cell& c,
 
9766
                               unsigned int num_quadrature_points,
 
9767
                               const double * const * quadrature_points,
 
9768
                               const double* quadrature_weights) const
 
9769
  {
 
9770
    throw std::runtime_error("Quadrature version of tabulate_tensor not yet implemented (introduced in UFC 2.0).");
 
9771
  }
 
9772
 
 
9773
};
 
9774
 
 
9775
/// This class defines the interface for the tabulation of the
 
9776
/// exterior facet tensor corresponding to the local contribution to
 
9777
/// a form from the integral over an exterior facet.
 
9778
 
 
9779
class adaptivepoisson_exterior_facet_integral_5_0: public ufc::exterior_facet_integral
 
9780
{
 
9781
public:
 
9782
 
 
9783
  /// Constructor
 
9784
  adaptivepoisson_exterior_facet_integral_5_0() : ufc::exterior_facet_integral()
 
9785
  {
 
9786
    // Do nothing
 
9787
  }
 
9788
 
 
9789
  /// Destructor
 
9790
  virtual ~adaptivepoisson_exterior_facet_integral_5_0()
 
9791
  {
 
9792
    // Do nothing
 
9793
  }
 
9794
 
 
9795
  /// Tabulate the tensor for the contribution from a local exterior facet
 
9796
  virtual void tabulate_tensor(double* A,
 
9797
                               const double * const * w,
 
9798
                               const ufc::cell& c,
 
9799
                               unsigned int facet) const
 
9800
  {
 
9801
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
9802
    // Number of operations (multiply-add pairs) for geometry tensor:    22
 
9803
    // Number of operations (multiply-add pairs) for tensor contraction: 33
 
9804
    // Total number of operations (multiply-add pairs):                  64
 
9805
    
 
9806
    // Extract vertex coordinates
 
9807
    const double * const * x = c.coordinates;
 
9808
    
 
9809
    // Compute Jacobian of affine map from reference cell
 
9810
    
 
9811
    // Compute determinant of Jacobian
 
9812
    
 
9813
    // Compute inverse of Jacobian
 
9814
    
 
9815
    // Get vertices on edge
 
9816
    static unsigned int edge_vertices[3][2] = {{1, 2}, {0, 2}, {0, 1}};
 
9817
    const unsigned int v0 = edge_vertices[facet][0];
 
9818
    const unsigned int v1 = edge_vertices[facet][1];
 
9819
    
 
9820
    // Compute scale factor (length of edge scaled by length of reference interval)
 
9821
    const double dx0 = x[v1][0] - x[v0][0];
 
9822
    const double dx1 = x[v1][1] - x[v0][1];
 
9823
    const double det = std::sqrt(dx0*dx0 + dx1*dx1);
 
9824
    
 
9825
    // Compute geometry tensor
 
9826
    const double G0_0_0 = det*w[1][0]*w[4][0]*(1.0);
 
9827
    const double G0_0_1 = det*w[1][0]*w[4][1]*(1.0);
 
9828
    const double G0_0_2 = det*w[1][0]*w[4][2]*(1.0);
 
9829
    const double G0_0_4 = det*w[1][0]*w[4][4]*(1.0);
 
9830
    const double G0_0_5 = det*w[1][0]*w[4][5]*(1.0);
 
9831
    const double G0_1_0 = det*w[1][1]*w[4][0]*(1.0);
 
9832
    const double G0_1_1 = det*w[1][1]*w[4][1]*(1.0);
 
9833
    const double G0_1_2 = det*w[1][1]*w[4][2]*(1.0);
 
9834
    const double G0_1_3 = det*w[1][1]*w[4][3]*(1.0);
 
9835
    const double G0_1_5 = det*w[1][1]*w[4][5]*(1.0);
 
9836
    const double G0_2_0 = det*w[1][2]*w[4][0]*(1.0);
 
9837
    const double G0_2_1 = det*w[1][2]*w[4][1]*(1.0);
 
9838
    const double G0_2_2 = det*w[1][2]*w[4][2]*(1.0);
 
9839
    const double G0_2_3 = det*w[1][2]*w[4][3]*(1.0);
 
9840
    const double G0_2_4 = det*w[1][2]*w[4][4]*(1.0);
 
9841
    
 
9842
    // Compute element tensor
 
9843
    switch (facet)
 
9844
    {
 
9845
    case 0:
 
9846
      {
 
9847
        A[0] = 0.000000000000000;
 
9848
      A[1] = 0.150000000000000*G0_1_1 - 0.016666666666667*G0_1_2 + 0.200000000000000*G0_1_3 + 0.016666666666667*G0_2_1 + 0.016666666666667*G0_2_2 + 0.133333333333333*G0_2_3;
 
9849
      A[2] = 0.016666666666667*G0_1_1 + 0.016666666666667*G0_1_2 + 0.133333333333333*G0_1_3 - 0.016666666666667*G0_2_1 + 0.150000000000000*G0_2_2 + 0.200000000000000*G0_2_3;
 
9850
        break;
 
9851
      }
 
9852
    case 1:
 
9853
      {
 
9854
        A[0] = 0.150000000000000*G0_0_0 - 0.016666666666667*G0_0_2 + 0.200000000000000*G0_0_4 + 0.016666666666667*G0_2_0 + 0.016666666666667*G0_2_2 + 0.133333333333333*G0_2_4;
 
9855
      A[1] = 0.000000000000000;
 
9856
      A[2] = 0.016666666666667*G0_0_0 + 0.016666666666667*G0_0_2 + 0.133333333333333*G0_0_4 - 0.016666666666667*G0_2_0 + 0.150000000000000*G0_2_2 + 0.200000000000000*G0_2_4;
 
9857
        break;
 
9858
      }
 
9859
    case 2:
 
9860
      {
 
9861
        A[0] = 0.150000000000000*G0_0_0 - 0.016666666666667*G0_0_1 + 0.200000000000000*G0_0_5 + 0.016666666666667*G0_1_0 + 0.016666666666667*G0_1_1 + 0.133333333333333*G0_1_5;
 
9862
      A[1] = 0.016666666666667*G0_0_0 + 0.016666666666667*G0_0_1 + 0.133333333333333*G0_0_5 - 0.016666666666667*G0_1_0 + 0.150000000000000*G0_1_1 + 0.200000000000000*G0_1_5;
 
9863
      A[2] = 0.000000000000000;
 
9864
        break;
 
9865
      }
 
9866
    }
 
9867
    
 
9868
  }
 
9869
 
 
9870
  /// Tabulate the tensor for the contribution from a local exterior facet
 
9871
  /// using the specified reference cell quadrature points/weights
 
9872
  virtual void tabulate_tensor(double* A,
 
9873
                               const double * const * w,
 
9874
                               const ufc::cell& c,
 
9875
                               unsigned int num_quadrature_points,
 
9876
                               const double * const * quadrature_points,
 
9877
                               const double* quadrature_weights) const
 
9878
  {
 
9879
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
9880
  }
 
9881
 
 
9882
};
 
9883
 
 
9884
/// This class defines the interface for the tabulation of the cell
 
9885
/// tensor corresponding to the local contribution to a form from
 
9886
/// the integral over a cell.
 
9887
 
 
9888
class adaptivepoisson_cell_integral_6_0: public ufc::cell_integral
 
9889
{
 
9890
public:
 
9891
 
 
9892
  /// Constructor
 
9893
  adaptivepoisson_cell_integral_6_0() : ufc::cell_integral()
 
9894
  {
 
9895
    // Do nothing
 
9896
  }
 
9897
 
 
9898
  /// Destructor
 
9899
  virtual ~adaptivepoisson_cell_integral_6_0()
 
9900
  {
 
9901
    // Do nothing
 
9902
  }
 
9903
 
 
9904
  /// Tabulate the tensor for the contribution from a local cell
 
9905
  virtual void tabulate_tensor(double* A,
 
9906
                               const double * const * w,
 
9907
                               const ufc::cell& c) const
 
9908
  {
 
9909
    // Extract vertex coordinates
 
9910
    const double * const * x = c.coordinates;
 
9911
    
 
9912
    // Compute Jacobian of affine map from reference cell
 
9913
    const double J_00 = x[1][0] - x[0][0];
 
9914
    const double J_01 = x[2][0] - x[0][0];
 
9915
    const double J_10 = x[1][1] - x[0][1];
 
9916
    const double J_11 = x[2][1] - x[0][1];
 
9917
    
 
9918
    // Compute determinant of Jacobian
 
9919
    double detJ = J_00*J_11 - J_01*J_10;
 
9920
    
 
9921
    // Compute inverse of Jacobian
 
9922
    const double K_00 =  J_11 / detJ;
 
9923
    const double K_01 = -J_01 / detJ;
 
9924
    const double K_10 = -J_10 / detJ;
 
9925
    const double K_11 =  J_00 / detJ;
 
9926
    
 
9927
    // Set scale factor
 
9928
    const double det = std::abs(detJ);
 
9929
    
 
9930
    // Cell Volume.
 
9931
    
 
9932
    // Compute circumradius, assuming triangle is embedded in 2D.
 
9933
    
 
9934
    
 
9935
    // Array of quadrature weights.
 
9936
    static const double W4[4] = {0.159020690871988, 0.090979309128011, 0.159020690871988, 0.090979309128011};
 
9937
    // Quadrature points on the UFC reference element: (0.178558728263616, 0.155051025721682), (0.075031110222608, 0.644948974278318), (0.666390246014701, 0.155051025721682), (0.280019915499074, 0.644948974278318)
 
9938
    
 
9939
    // Value of basis functions at quadrature points.
 
9940
    static const double FE0[4][3] = \
 
9941
    {{0.666390246014701, 0.178558728263616, 0.155051025721682},
 
9942
    {0.280019915499074, 0.075031110222608, 0.644948974278318},
 
9943
    {0.178558728263616, 0.666390246014701, 0.155051025721682},
 
9944
    {0.075031110222608, 0.280019915499074, 0.644948974278318}};
 
9945
    
 
9946
    static const double FE0_D01[4][2] = \
 
9947
    {{-1.000000000000000, 1.000000000000000},
 
9948
    {-1.000000000000000, 1.000000000000000},
 
9949
    {-1.000000000000000, 1.000000000000000},
 
9950
    {-1.000000000000000, 1.000000000000000}};
 
9951
    
 
9952
    // Array of non-zero columns
 
9953
    static const unsigned int nzc1[2] = {0, 1};
 
9954
    
 
9955
    // Array of non-zero columns
 
9956
    static const unsigned int nzc0[2] = {0, 2};
 
9957
    
 
9958
    static const double FE1[4][6] = \
 
9959
    {{0.221761673952367, -0.114792289385376, -0.106969384566991, 0.110742855875331, 0.413297964702014, 0.475959179422654},
 
9960
    {-0.123197609346857, -0.063771775220134, 0.186969384566991, 0.193564950308138, 0.722394229114516, 0.084040820577346},
 
9961
    {-0.114792289385376, 0.221761673952367, -0.106969384566991, 0.413297964702014, 0.110742855875331, 0.475959179422654},
 
9962
    {-0.063771775220134, -0.123197609346857, 0.186969384566991, 0.722394229114516, 0.193564950308138, 0.084040820577346}};
 
9963
    
 
9964
    static const double FE1_D01[4][5] = \
 
9965
    {{-1.665560984058806, -0.379795897113271, 0.714234913054465, 2.045356881172077, -0.714234913054465},
 
9966
    {-0.120079661996297, 1.579795897113271, 0.300124440890432, -1.459716235116974, -0.300124440890432},
 
9967
    {0.285765086945535, -0.379795897113271, 2.665560984058804, 0.094030810167737, -2.665560984058805},
 
9968
    {0.699875559109568, 1.579795897113271, 1.120079661996296, -2.279671456222839, -1.120079661996296}};
 
9969
    
 
9970
    // Array of non-zero columns
 
9971
    static const unsigned int nzc2[5] = {0, 2, 3, 4, 5};
 
9972
    
 
9973
    static const double FE1_D10[4][5] = \
 
9974
    {{-1.665560984058806, -0.285765086945535, 0.620204102886728, -0.620204102886729, 1.951326071004340},
 
9975
    {-0.120079661996296, -0.699875559109568, 2.579795897113270, -2.579795897113271, 0.819955221105864},
 
9976
    {0.285765086945534, 1.665560984058805, 0.620204102886728, -0.620204102886729, -1.951326071004339},
 
9977
    {0.699875559109568, 0.120079661996296, 2.579795897113271, -2.579795897113272, -0.819955221105864}};
 
9978
    
 
9979
    // Array of non-zero columns
 
9980
    static const unsigned int nzc3[5] = {0, 1, 3, 4, 5};
 
9981
    
 
9982
    // Reset values in the element tensor.
 
9983
    A[0] = 0.000000000000000;
 
9984
    // Number of operations to compute geometry constants: 12.
 
9985
    double G[3];
 
9986
    G[0] =  - det*(K_00*K_00 + K_01*K_01);
 
9987
    G[1] =  - det*(K_00*K_10 + K_01*K_11);
 
9988
    G[2] =  - det*(K_10*K_10 + K_11*K_11);
 
9989
    
 
9990
    // Compute element tensor using UFL quadrature representation
 
9991
    // Optimisations: ('eliminate zeros', True), ('ignore ones', True), ('ignore zero tables', True), ('optimisation', 'simplify_expressions'), ('remove zero terms', True)
 
9992
    
 
9993
    // Loop quadrature points for integral.
 
9994
    // Number of operations to compute element tensor for following IP loop = 240
 
9995
    for (unsigned int ip = 0; ip < 4; ip++)
 
9996
    {
 
9997
      
 
9998
      // Coefficient declarations.
 
9999
      double F0 = 0.000000000000000;
 
10000
      double F1 = 0.000000000000000;
 
10001
      double F2 = 0.000000000000000;
 
10002
      double F3 = 0.000000000000000;
 
10003
      double F4 = 0.000000000000000;
 
10004
      double F5 = 0.000000000000000;
 
10005
      
 
10006
      // Total number of operations to compute function values = 8
 
10007
      for (unsigned int r = 0; r < 2; r++)
 
10008
      {
 
10009
        F2 += FE0_D01[ip][r]*w[2][nzc1[r]];
 
10010
        F3 += FE0_D01[ip][r]*w[2][nzc0[r]];
 
10011
      }// end loop over 'r'
 
10012
      
 
10013
      // Total number of operations to compute function values = 6
 
10014
      for (unsigned int r = 0; r < 3; r++)
 
10015
      {
 
10016
        F0 += FE0[ip][r]*w[0][r];
 
10017
      }// end loop over 'r'
 
10018
      
 
10019
      // Total number of operations to compute function values = 20
 
10020
      for (unsigned int r = 0; r < 5; r++)
 
10021
      {
 
10022
        F4 += FE1_D10[ip][r]*w[3][nzc3[r]];
 
10023
        F5 += FE1_D01[ip][r]*w[3][nzc2[r]];
 
10024
      }// end loop over 'r'
 
10025
      
 
10026
      // Total number of operations to compute function values = 12
 
10027
      for (unsigned int r = 0; r < 6; r++)
 
10028
      {
 
10029
        F1 += FE1[ip][r]*w[3][r];
 
10030
      }// end loop over 'r'
 
10031
      
 
10032
      // Number of operations to compute ip constants: 13
 
10033
      double I[1];
 
10034
      // Number of operations: 13
 
10035
      I[0] = W4[ip]*(F0*F1*det + F2*(F4*G[0] + F5*G[1]) + F3*(F4*G[1] + F5*G[2]));
 
10036
      
 
10037
      
 
10038
      // Number of operations for primary indices: 1
 
10039
      // Number of operations to compute entry: 1
 
10040
      A[0] += I[0];
 
10041
    }// end loop over 'ip'
 
10042
  }
 
10043
 
 
10044
  /// Tabulate the tensor for the contribution from a local cell
 
10045
  /// using the specified reference cell quadrature points/weights
 
10046
  virtual void tabulate_tensor(double* A,
 
10047
                               const double * const * w,
 
10048
                               const ufc::cell& c,
 
10049
                               unsigned int num_quadrature_points,
 
10050
                               const double * const * quadrature_points,
 
10051
                               const double* quadrature_weights) const
 
10052
  {
 
10053
    throw std::runtime_error("Quadrature version of tabulate_tensor not yet implemented (introduced in UFC 2.0).");
 
10054
  }
 
10055
 
 
10056
};
 
10057
 
 
10058
/// This class defines the interface for the tabulation of the
 
10059
/// exterior facet tensor corresponding to the local contribution to
 
10060
/// a form from the integral over an exterior facet.
 
10061
 
 
10062
class adaptivepoisson_exterior_facet_integral_6_0: public ufc::exterior_facet_integral
 
10063
{
 
10064
public:
 
10065
 
 
10066
  /// Constructor
 
10067
  adaptivepoisson_exterior_facet_integral_6_0() : ufc::exterior_facet_integral()
 
10068
  {
 
10069
    // Do nothing
 
10070
  }
 
10071
 
 
10072
  /// Destructor
 
10073
  virtual ~adaptivepoisson_exterior_facet_integral_6_0()
 
10074
  {
 
10075
    // Do nothing
 
10076
  }
 
10077
 
 
10078
  /// Tabulate the tensor for the contribution from a local exterior facet
 
10079
  virtual void tabulate_tensor(double* A,
 
10080
                               const double * const * w,
 
10081
                               const ufc::cell& c,
 
10082
                               unsigned int facet) const
 
10083
  {
 
10084
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
10085
    // Number of operations (multiply-add pairs) for geometry tensor:    13
 
10086
    // Number of operations (multiply-add pairs) for tensor contraction: 10
 
10087
    // Total number of operations (multiply-add pairs):                  32
 
10088
    
 
10089
    // Extract vertex coordinates
 
10090
    const double * const * x = c.coordinates;
 
10091
    
 
10092
    // Compute Jacobian of affine map from reference cell
 
10093
    
 
10094
    // Compute determinant of Jacobian
 
10095
    
 
10096
    // Compute inverse of Jacobian
 
10097
    
 
10098
    // Get vertices on edge
 
10099
    static unsigned int edge_vertices[3][2] = {{1, 2}, {0, 2}, {0, 1}};
 
10100
    const unsigned int v0 = edge_vertices[facet][0];
 
10101
    const unsigned int v1 = edge_vertices[facet][1];
 
10102
    
 
10103
    // Compute scale factor (length of edge scaled by length of reference interval)
 
10104
    const double dx0 = x[v1][0] - x[v0][0];
 
10105
    const double dx1 = x[v1][1] - x[v0][1];
 
10106
    const double det = std::sqrt(dx0*dx0 + dx1*dx1);
 
10107
    
 
10108
    // Compute geometry tensor
 
10109
    const double G0_0_0 = det*w[1][0]*w[3][0]*(1.0);
 
10110
    const double G0_0_4 = det*w[1][0]*w[3][4]*(1.0);
 
10111
    const double G0_0_5 = det*w[1][0]*w[3][5]*(1.0);
 
10112
    const double G0_1_1 = det*w[1][1]*w[3][1]*(1.0);
 
10113
    const double G0_1_3 = det*w[1][1]*w[3][3]*(1.0);
 
10114
    const double G0_1_5 = det*w[1][1]*w[3][5]*(1.0);
 
10115
    const double G0_2_2 = det*w[1][2]*w[3][2]*(1.0);
 
10116
    const double G0_2_3 = det*w[1][2]*w[3][3]*(1.0);
 
10117
    const double G0_2_4 = det*w[1][2]*w[3][4]*(1.0);
 
10118
    
 
10119
    // Compute element tensor
 
10120
    switch (facet)
 
10121
    {
 
10122
    case 0:
 
10123
      {
 
10124
        A[0] = 0.166666666666666*G0_1_1 + 0.333333333333333*G0_1_3 + 0.166666666666666*G0_2_2 + 0.333333333333333*G0_2_3;
 
10125
        break;
 
10126
      }
 
10127
    case 1:
 
10128
      {
 
10129
        A[0] = 0.166666666666667*G0_0_0 + 0.333333333333333*G0_0_4 + 0.166666666666666*G0_2_2 + 0.333333333333333*G0_2_4;
 
10130
        break;
 
10131
      }
 
10132
    case 2:
 
10133
      {
 
10134
        A[0] = 0.166666666666666*G0_0_0 + 0.333333333333333*G0_0_5 + 0.166666666666667*G0_1_1 + 0.333333333333333*G0_1_5;
 
10135
        break;
 
10136
      }
 
10137
    }
 
10138
    
 
10139
  }
 
10140
 
 
10141
  /// Tabulate the tensor for the contribution from a local exterior facet
 
10142
  /// using the specified reference cell quadrature points/weights
 
10143
  virtual void tabulate_tensor(double* A,
 
10144
                               const double * const * w,
 
10145
                               const ufc::cell& c,
 
10146
                               unsigned int num_quadrature_points,
 
10147
                               const double * const * quadrature_points,
 
10148
                               const double* quadrature_weights) const
 
10149
  {
 
10150
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
10151
  }
 
10152
 
 
10153
};
 
10154
 
 
10155
/// This class defines the interface for the tabulation of the cell
 
10156
/// tensor corresponding to the local contribution to a form from
 
10157
/// the integral over a cell.
 
10158
 
 
10159
class adaptivepoisson_cell_integral_7_0: public ufc::cell_integral
 
10160
{
 
10161
public:
 
10162
 
 
10163
  /// Constructor
 
10164
  adaptivepoisson_cell_integral_7_0() : ufc::cell_integral()
 
10165
  {
 
10166
    // Do nothing
 
10167
  }
 
10168
 
 
10169
  /// Destructor
 
10170
  virtual ~adaptivepoisson_cell_integral_7_0()
 
10171
  {
 
10172
    // Do nothing
 
10173
  }
 
10174
 
 
10175
  /// Tabulate the tensor for the contribution from a local cell
 
10176
  virtual void tabulate_tensor(double* A,
 
10177
                               const double * const * w,
 
10178
                               const ufc::cell& c) const
 
10179
  {
 
10180
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
10181
    // Number of operations (multiply-add pairs) for geometry tensor:    40
 
10182
    // Number of operations (multiply-add pairs) for tensor contraction: 26
 
10183
    // Total number of operations (multiply-add pairs):                  75
 
10184
    
 
10185
    // Extract vertex coordinates
 
10186
    const double * const * x = c.coordinates;
 
10187
    
 
10188
    // Compute Jacobian of affine map from reference cell
 
10189
    const double J_00 = x[1][0] - x[0][0];
 
10190
    const double J_01 = x[2][0] - x[0][0];
 
10191
    const double J_10 = x[1][1] - x[0][1];
 
10192
    const double J_11 = x[2][1] - x[0][1];
 
10193
    
 
10194
    // Compute determinant of Jacobian
 
10195
    double detJ = J_00*J_11 - J_01*J_10;
 
10196
    
 
10197
    // Compute inverse of Jacobian
 
10198
    
 
10199
    // Set scale factor
 
10200
    const double det = std::abs(detJ);
 
10201
    
 
10202
    // Compute geometry tensor
 
10203
    const double G0_0_0 = det*w[1][0]*w[0][0]*(1.0);
 
10204
    const double G0_0_1 = det*w[1][0]*w[0][1]*(1.0);
 
10205
    const double G0_0_2 = det*w[1][0]*w[0][2]*(1.0);
 
10206
    const double G0_0_3 = det*w[1][0]*w[0][3]*(1.0);
 
10207
    const double G0_0_4 = det*w[1][0]*w[0][4]*(1.0);
 
10208
    const double G0_0_5 = det*w[1][0]*w[0][5]*(1.0);
 
10209
    const double G0_1_0 = det*w[1][1]*w[0][0]*(1.0);
 
10210
    const double G0_1_1 = det*w[1][1]*w[0][1]*(1.0);
 
10211
    const double G0_1_2 = det*w[1][1]*w[0][2]*(1.0);
 
10212
    const double G0_1_3 = det*w[1][1]*w[0][3]*(1.0);
 
10213
    const double G0_1_4 = det*w[1][1]*w[0][4]*(1.0);
 
10214
    const double G0_1_5 = det*w[1][1]*w[0][5]*(1.0);
 
10215
    const double G0_2_0 = det*w[1][2]*w[0][0]*(1.0);
 
10216
    const double G0_2_1 = det*w[1][2]*w[0][1]*(1.0);
 
10217
    const double G0_2_2 = det*w[1][2]*w[0][2]*(1.0);
 
10218
    const double G0_2_3 = det*w[1][2]*w[0][3]*(1.0);
 
10219
    const double G0_2_4 = det*w[1][2]*w[0][4]*(1.0);
 
10220
    const double G0_2_5 = det*w[1][2]*w[0][5]*(1.0);
 
10221
    const double G1_0_0 = det*w[1][0]*w[3][0]*(1.0);
 
10222
    const double G1_0_1 = det*w[1][0]*w[3][1]*(1.0);
 
10223
    const double G1_0_2 = det*w[1][0]*w[3][2]*(1.0);
 
10224
    const double G1_1_0 = det*w[1][1]*w[3][0]*(1.0);
 
10225
    const double G1_1_1 = det*w[1][1]*w[3][1]*(1.0);
 
10226
    const double G1_1_2 = det*w[1][1]*w[3][2]*(1.0);
 
10227
    const double G1_2_0 = det*w[1][2]*w[3][0]*(1.0);
 
10228
    const double G1_2_1 = det*w[1][2]*w[3][1]*(1.0);
 
10229
    const double G1_2_2 = det*w[1][2]*w[3][2]*(1.0);
 
10230
    
 
10231
    // Compute element tensor
 
10232
    A[0] = 0.016666666666667*G0_0_0 - 0.008333333333333*G0_0_1 - 0.008333333333333*G0_0_2 + 0.033333333333333*G0_0_3 + 0.066666666666667*G0_0_4 + 0.066666666666666*G0_0_5 - 0.008333333333333*G0_1_0 + 0.016666666666667*G0_1_1 - 0.008333333333333*G0_1_2 + 0.066666666666667*G0_1_3 + 0.033333333333333*G0_1_4 + 0.066666666666666*G0_1_5 - 0.008333333333333*G0_2_0 - 0.008333333333333*G0_2_1 + 0.016666666666667*G0_2_2 + 0.066666666666667*G0_2_3 + 0.066666666666667*G0_2_4 + 0.033333333333333*G0_2_5 - 0.083333333333333*G1_0_0 - 0.041666666666667*G1_0_1 - 0.041666666666667*G1_0_2 - 0.041666666666667*G1_1_0 - 0.083333333333333*G1_1_1 - 0.041666666666667*G1_1_2 - 0.041666666666667*G1_2_0 - 0.041666666666667*G1_2_1 - 0.083333333333333*G1_2_2;
 
10233
  }
 
10234
 
 
10235
  /// Tabulate the tensor for the contribution from a local cell
 
10236
  /// using the specified reference cell quadrature points/weights
 
10237
  virtual void tabulate_tensor(double* A,
 
10238
                               const double * const * w,
 
10239
                               const ufc::cell& c,
 
10240
                               unsigned int num_quadrature_points,
 
10241
                               const double * const * quadrature_points,
 
10242
                               const double* quadrature_weights) const
 
10243
  {
 
10244
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
10245
  }
 
10246
 
 
10247
};
 
10248
 
 
10249
/// This class defines the interface for the tabulation of the
 
10250
/// exterior facet tensor corresponding to the local contribution to
 
10251
/// a form from the integral over an exterior facet.
 
10252
 
 
10253
class adaptivepoisson_exterior_facet_integral_7_0: public ufc::exterior_facet_integral
 
10254
{
 
10255
public:
 
10256
 
 
10257
  /// Constructor
 
10258
  adaptivepoisson_exterior_facet_integral_7_0() : ufc::exterior_facet_integral()
 
10259
  {
 
10260
    // Do nothing
 
10261
  }
 
10262
 
 
10263
  /// Destructor
 
10264
  virtual ~adaptivepoisson_exterior_facet_integral_7_0()
 
10265
  {
 
10266
    // Do nothing
 
10267
  }
 
10268
 
 
10269
  /// Tabulate the tensor for the contribution from a local exterior facet
 
10270
  virtual void tabulate_tensor(double* A,
 
10271
                               const double * const * w,
 
10272
                               const ufc::cell& c,
 
10273
                               unsigned int facet) const
 
10274
  {
 
10275
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
10276
    // Number of operations (multiply-add pairs) for geometry tensor:    27
 
10277
    // Number of operations (multiply-add pairs) for tensor contraction: 22
 
10278
    // Total number of operations (multiply-add pairs):                  58
 
10279
    
 
10280
    // Extract vertex coordinates
 
10281
    const double * const * x = c.coordinates;
 
10282
    
 
10283
    // Compute Jacobian of affine map from reference cell
 
10284
    
 
10285
    // Compute determinant of Jacobian
 
10286
    
 
10287
    // Compute inverse of Jacobian
 
10288
    
 
10289
    // Get vertices on edge
 
10290
    static unsigned int edge_vertices[3][2] = {{1, 2}, {0, 2}, {0, 1}};
 
10291
    const unsigned int v0 = edge_vertices[facet][0];
 
10292
    const unsigned int v1 = edge_vertices[facet][1];
 
10293
    
 
10294
    // Compute scale factor (length of edge scaled by length of reference interval)
 
10295
    const double dx0 = x[v1][0] - x[v0][0];
 
10296
    const double dx1 = x[v1][1] - x[v0][1];
 
10297
    const double det = std::sqrt(dx0*dx0 + dx1*dx1);
 
10298
    
 
10299
    // Compute geometry tensor
 
10300
    const double G0_0_0 = det*w[2][0]*w[0][0]*(1.0);
 
10301
    const double G0_0_4 = det*w[2][0]*w[0][4]*(1.0);
 
10302
    const double G0_0_5 = det*w[2][0]*w[0][5]*(1.0);
 
10303
    const double G0_1_1 = det*w[2][1]*w[0][1]*(1.0);
 
10304
    const double G0_1_3 = det*w[2][1]*w[0][3]*(1.0);
 
10305
    const double G0_1_5 = det*w[2][1]*w[0][5]*(1.0);
 
10306
    const double G0_2_2 = det*w[2][2]*w[0][2]*(1.0);
 
10307
    const double G0_2_3 = det*w[2][2]*w[0][3]*(1.0);
 
10308
    const double G0_2_4 = det*w[2][2]*w[0][4]*(1.0);
 
10309
    const double G1_0_0 = det*w[2][0]*w[3][0]*(1.0);
 
10310
    const double G1_0_1 = det*w[2][0]*w[3][1]*(1.0);
 
10311
    const double G1_0_2 = det*w[2][0]*w[3][2]*(1.0);
 
10312
    const double G1_1_0 = det*w[2][1]*w[3][0]*(1.0);
 
10313
    const double G1_1_1 = det*w[2][1]*w[3][1]*(1.0);
 
10314
    const double G1_1_2 = det*w[2][1]*w[3][2]*(1.0);
 
10315
    const double G1_2_0 = det*w[2][2]*w[3][0]*(1.0);
 
10316
    const double G1_2_1 = det*w[2][2]*w[3][1]*(1.0);
 
10317
    const double G1_2_2 = det*w[2][2]*w[3][2]*(1.0);
 
10318
    
 
10319
    // Compute element tensor
 
10320
    switch (facet)
 
10321
    {
 
10322
    case 0:
 
10323
      {
 
10324
        A[0] = 0.166666666666666*G0_1_1 + 0.333333333333333*G0_1_3 + 0.166666666666666*G0_2_2 + 0.333333333333333*G0_2_3 - 0.333333333333333*G1_1_1 - 0.166666666666667*G1_1_2 - 0.166666666666667*G1_2_1 - 0.333333333333333*G1_2_2;
 
10325
        break;
 
10326
      }
 
10327
    case 1:
 
10328
      {
 
10329
        A[0] = 0.166666666666667*G0_0_0 + 0.333333333333333*G0_0_4 + 0.166666666666666*G0_2_2 + 0.333333333333333*G0_2_4 - 0.333333333333333*G1_0_0 - 0.166666666666667*G1_0_2 - 0.166666666666667*G1_2_0 - 0.333333333333333*G1_2_2;
 
10330
        break;
 
10331
      }
 
10332
    case 2:
 
10333
      {
 
10334
        A[0] = 0.166666666666666*G0_0_0 + 0.333333333333333*G0_0_5 + 0.166666666666667*G0_1_1 + 0.333333333333333*G0_1_5 - 0.333333333333333*G1_0_0 - 0.166666666666667*G1_0_1 - 0.166666666666667*G1_1_0 - 0.333333333333333*G1_1_1;
 
10335
        break;
 
10336
      }
 
10337
    }
 
10338
    
 
10339
  }
 
10340
 
 
10341
  /// Tabulate the tensor for the contribution from a local exterior facet
 
10342
  /// using the specified reference cell quadrature points/weights
 
10343
  virtual void tabulate_tensor(double* A,
 
10344
                               const double * const * w,
 
10345
                               const ufc::cell& c,
 
10346
                               unsigned int num_quadrature_points,
 
10347
                               const double * const * quadrature_points,
 
10348
                               const double* quadrature_weights) const
 
10349
  {
 
10350
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
10351
  }
 
10352
 
 
10353
};
 
10354
 
 
10355
/// This class defines the interface for the tabulation of the
 
10356
/// interior facet tensor corresponding to the local contribution to
 
10357
/// a form from the integral over an interior facet.
 
10358
 
 
10359
class adaptivepoisson_interior_facet_integral_7_0: public ufc::interior_facet_integral
 
10360
{
 
10361
public:
 
10362
 
 
10363
  /// Constructor
 
10364
  adaptivepoisson_interior_facet_integral_7_0() : ufc::interior_facet_integral()
 
10365
  {
 
10366
    // Do nothing
 
10367
  }
 
10368
 
 
10369
  /// Destructor
 
10370
  virtual ~adaptivepoisson_interior_facet_integral_7_0()
 
10371
  {
 
10372
    // Do nothing
 
10373
  }
 
10374
 
 
10375
  /// Tabulate the tensor for the contribution from a local interior facet
 
10376
  virtual void tabulate_tensor(double* A,
 
10377
                               const double * const * w,
 
10378
                               const ufc::cell& c0,
 
10379
                               const ufc::cell& c1,
 
10380
                               unsigned int facet0,
 
10381
                               unsigned int facet1) const
 
10382
  {
 
10383
    // Number of operations (multiply-add pairs) for Jacobian data:      12
 
10384
    // Number of operations (multiply-add pairs) for geometry tensor:    108
 
10385
    // Number of operations (multiply-add pairs) for tensor contraction: 279
 
10386
    // Total number of operations (multiply-add pairs):                  399
 
10387
    
 
10388
    // Extract vertex coordinates
 
10389
    const double * const * x0 = c0.coordinates;
 
10390
    
 
10391
    // Compute Jacobian of affine map from reference cell
 
10392
    
 
10393
    // Compute determinant of Jacobian
 
10394
    
 
10395
    // Compute inverse of Jacobian
 
10396
    
 
10397
    // Compute Jacobian of affine map from reference cell
 
10398
    
 
10399
    // Compute determinant of Jacobian
 
10400
    
 
10401
    // Compute inverse of Jacobian
 
10402
    
 
10403
    // Get vertices on edge
 
10404
    static unsigned int edge_vertices[3][2] = {{1, 2}, {0, 2}, {0, 1}};
 
10405
    const unsigned int v0 = edge_vertices[facet0][0];
 
10406
    const unsigned int v1 = edge_vertices[facet0][1];
 
10407
    
 
10408
    // Compute scale factor (length of edge scaled by length of reference interval)
 
10409
    const double dx0 = x0[v1][0] - x0[v0][0];
 
10410
    const double dx1 = x0[v1][1] - x0[v0][1];
 
10411
    const double det = std::sqrt(dx0*dx0 + dx1*dx1);
 
10412
    
 
10413
    // Compute geometry tensor
 
10414
    const double G0_3_6 = det*w[2][3]*w[0][6]*(1.0);
 
10415
    const double G0_3_10 = det*w[2][3]*w[0][10]*(1.0);
 
10416
    const double G0_3_11 = det*w[2][3]*w[0][11]*(1.0);
 
10417
    const double G0_4_7 = det*w[2][4]*w[0][7]*(1.0);
 
10418
    const double G0_4_9 = det*w[2][4]*w[0][9]*(1.0);
 
10419
    const double G0_4_11 = det*w[2][4]*w[0][11]*(1.0);
 
10420
    const double G0_5_8 = det*w[2][5]*w[0][8]*(1.0);
 
10421
    const double G0_5_9 = det*w[2][5]*w[0][9]*(1.0);
 
10422
    const double G0_5_10 = det*w[2][5]*w[0][10]*(1.0);
 
10423
    const double G1_3_3 = det*w[2][3]*w[3][3]*(1.0);
 
10424
    const double G1_3_4 = det*w[2][3]*w[3][4]*(1.0);
 
10425
    const double G1_3_5 = det*w[2][3]*w[3][5]*(1.0);
 
10426
    const double G1_4_3 = det*w[2][4]*w[3][3]*(1.0);
 
10427
    const double G1_4_4 = det*w[2][4]*w[3][4]*(1.0);
 
10428
    const double G1_4_5 = det*w[2][4]*w[3][5]*(1.0);
 
10429
    const double G1_5_3 = det*w[2][5]*w[3][3]*(1.0);
 
10430
    const double G1_5_4 = det*w[2][5]*w[3][4]*(1.0);
 
10431
    const double G1_5_5 = det*w[2][5]*w[3][5]*(1.0);
 
10432
    const double G2_0_0 = det*w[2][0]*w[0][0]*(1.0);
 
10433
    const double G2_0_4 = det*w[2][0]*w[0][4]*(1.0);
 
10434
    const double G2_0_5 = det*w[2][0]*w[0][5]*(1.0);
 
10435
    const double G2_1_1 = det*w[2][1]*w[0][1]*(1.0);
 
10436
    const double G2_1_3 = det*w[2][1]*w[0][3]*(1.0);
 
10437
    const double G2_1_5 = det*w[2][1]*w[0][5]*(1.0);
 
10438
    const double G2_2_2 = det*w[2][2]*w[0][2]*(1.0);
 
10439
    const double G2_2_3 = det*w[2][2]*w[0][3]*(1.0);
 
10440
    const double G2_2_4 = det*w[2][2]*w[0][4]*(1.0);
 
10441
    const double G3_0_0 = det*w[2][0]*w[3][0]*(1.0);
 
10442
    const double G3_0_1 = det*w[2][0]*w[3][1]*(1.0);
 
10443
    const double G3_0_2 = det*w[2][0]*w[3][2]*(1.0);
 
10444
    const double G3_1_0 = det*w[2][1]*w[3][0]*(1.0);
 
10445
    const double G3_1_1 = det*w[2][1]*w[3][1]*(1.0);
 
10446
    const double G3_1_2 = det*w[2][1]*w[3][2]*(1.0);
 
10447
    const double G3_2_0 = det*w[2][2]*w[3][0]*(1.0);
 
10448
    const double G3_2_1 = det*w[2][2]*w[3][1]*(1.0);
 
10449
    const double G3_2_2 = det*w[2][2]*w[3][2]*(1.0);
 
10450
    const double G4_3_6 = det*w[2][3]*w[0][6]*(1.0);
 
10451
    const double G4_3_10 = det*w[2][3]*w[0][10]*(1.0);
 
10452
    const double G4_3_11 = det*w[2][3]*w[0][11]*(1.0);
 
10453
    const double G4_4_7 = det*w[2][4]*w[0][7]*(1.0);
 
10454
    const double G4_4_9 = det*w[2][4]*w[0][9]*(1.0);
 
10455
    const double G4_4_11 = det*w[2][4]*w[0][11]*(1.0);
 
10456
    const double G4_5_8 = det*w[2][5]*w[0][8]*(1.0);
 
10457
    const double G4_5_9 = det*w[2][5]*w[0][9]*(1.0);
 
10458
    const double G4_5_10 = det*w[2][5]*w[0][10]*(1.0);
 
10459
    const double G5_3_3 = det*w[2][3]*w[3][3]*(1.0);
 
10460
    const double G5_3_4 = det*w[2][3]*w[3][4]*(1.0);
 
10461
    const double G5_3_5 = det*w[2][3]*w[3][5]*(1.0);
 
10462
    const double G5_4_3 = det*w[2][4]*w[3][3]*(1.0);
 
10463
    const double G5_4_4 = det*w[2][4]*w[3][4]*(1.0);
 
10464
    const double G5_4_5 = det*w[2][4]*w[3][5]*(1.0);
 
10465
    const double G5_5_3 = det*w[2][5]*w[3][3]*(1.0);
 
10466
    const double G5_5_4 = det*w[2][5]*w[3][4]*(1.0);
 
10467
    const double G5_5_5 = det*w[2][5]*w[3][5]*(1.0);
 
10468
    const double G6_0_0 = det*w[2][0]*w[0][0]*(1.0);
 
10469
    const double G6_0_4 = det*w[2][0]*w[0][4]*(1.0);
 
10470
    const double G6_0_5 = det*w[2][0]*w[0][5]*(1.0);
 
10471
    const double G6_1_1 = det*w[2][1]*w[0][1]*(1.0);
 
10472
    const double G6_1_3 = det*w[2][1]*w[0][3]*(1.0);
 
10473
    const double G6_1_5 = det*w[2][1]*w[0][5]*(1.0);
 
10474
    const double G6_2_2 = det*w[2][2]*w[0][2]*(1.0);
 
10475
    const double G6_2_3 = det*w[2][2]*w[0][3]*(1.0);
 
10476
    const double G6_2_4 = det*w[2][2]*w[0][4]*(1.0);
 
10477
    const double G7_0_0 = det*w[2][0]*w[3][0]*(1.0);
 
10478
    const double G7_0_1 = det*w[2][0]*w[3][1]*(1.0);
 
10479
    const double G7_0_2 = det*w[2][0]*w[3][2]*(1.0);
 
10480
    const double G7_1_0 = det*w[2][1]*w[3][0]*(1.0);
 
10481
    const double G7_1_1 = det*w[2][1]*w[3][1]*(1.0);
 
10482
    const double G7_1_2 = det*w[2][1]*w[3][2]*(1.0);
 
10483
    const double G7_2_0 = det*w[2][2]*w[3][0]*(1.0);
 
10484
    const double G7_2_1 = det*w[2][2]*w[3][1]*(1.0);
 
10485
    const double G7_2_2 = det*w[2][2]*w[3][2]*(1.0);
 
10486
    
 
10487
    // Compute element tensor
 
10488
    switch (facet0)
 
10489
    {
 
10490
    case 0:
 
10491
      {
 
10492
        switch (facet1)
 
10493
      {
 
10494
      case 0:
 
10495
        {
 
10496
          A[0] = 0.083333333333333*G4_4_7 + 0.166666666666667*G4_4_9 + 0.083333333333333*G4_5_8 + 0.166666666666667*G4_5_9 - 0.166666666666667*G5_4_4 - 0.083333333333333*G5_4_5 - 0.083333333333333*G5_5_4 - 0.166666666666667*G5_5_5 + 0.083333333333333*G6_1_1 + 0.166666666666667*G6_1_3 + 0.083333333333333*G6_2_2 + 0.166666666666667*G6_2_3 - 0.166666666666667*G7_1_1 - 0.083333333333333*G7_1_2 - 0.083333333333333*G7_2_1 - 0.166666666666667*G7_2_2;
 
10497
        A[1] = 0.083333333333333*G0_4_7 + 0.166666666666667*G0_4_9 + 0.083333333333333*G0_5_8 + 0.166666666666667*G0_5_9 - 0.166666666666667*G1_4_4 - 0.083333333333333*G1_4_5 - 0.083333333333333*G1_5_4 - 0.166666666666667*G1_5_5 + 0.083333333333333*G2_1_1 + 0.166666666666667*G2_1_3 + 0.083333333333333*G2_2_2 + 0.166666666666667*G2_2_3 - 0.166666666666667*G3_1_1 - 0.083333333333333*G3_1_2 - 0.083333333333333*G3_2_1 - 0.166666666666667*G3_2_2;
 
10498
          break;
 
10499
        }
 
10500
      case 1:
 
10501
        {
 
10502
          A[0] = 0.083333333333333*G4_3_6 + 0.166666666666667*G4_3_10 + 0.083333333333333*G4_5_8 + 0.166666666666667*G4_5_10 - 0.166666666666667*G5_3_3 - 0.083333333333333*G5_3_5 - 0.083333333333333*G5_5_3 - 0.166666666666667*G5_5_5 + 0.083333333333333*G6_1_1 + 0.166666666666667*G6_1_3 + 0.083333333333333*G6_2_2 + 0.166666666666667*G6_2_3 - 0.166666666666667*G7_1_1 - 0.083333333333333*G7_1_2 - 0.083333333333333*G7_2_1 - 0.166666666666667*G7_2_2;
 
10503
        A[1] = 0.083333333333333*G0_3_6 + 0.166666666666667*G0_3_10 + 0.083333333333333*G0_5_8 + 0.166666666666667*G0_5_10 - 0.166666666666667*G1_3_3 - 0.083333333333333*G1_3_5 - 0.083333333333333*G1_5_3 - 0.166666666666667*G1_5_5 + 0.083333333333333*G2_1_1 + 0.166666666666667*G2_1_3 + 0.083333333333333*G2_2_2 + 0.166666666666667*G2_2_3 - 0.166666666666667*G3_1_1 - 0.083333333333333*G3_1_2 - 0.083333333333333*G3_2_1 - 0.166666666666667*G3_2_2;
 
10504
          break;
 
10505
        }
 
10506
      case 2:
 
10507
        {
 
10508
          A[0] = 0.083333333333333*G4_3_6 + 0.166666666666667*G4_3_11 + 0.083333333333333*G4_4_7 + 0.166666666666667*G4_4_11 - 0.166666666666666*G5_3_3 - 0.083333333333333*G5_3_4 - 0.083333333333333*G5_4_3 - 0.166666666666667*G5_4_4 + 0.083333333333333*G6_1_1 + 0.166666666666667*G6_1_3 + 0.083333333333333*G6_2_2 + 0.166666666666667*G6_2_3 - 0.166666666666667*G7_1_1 - 0.083333333333333*G7_1_2 - 0.083333333333333*G7_2_1 - 0.166666666666667*G7_2_2;
 
10509
        A[1] = 0.083333333333333*G0_3_6 + 0.166666666666667*G0_3_11 + 0.083333333333333*G0_4_7 + 0.166666666666667*G0_4_11 - 0.166666666666666*G1_3_3 - 0.083333333333333*G1_3_4 - 0.083333333333333*G1_4_3 - 0.166666666666667*G1_4_4 + 0.083333333333333*G2_1_1 + 0.166666666666667*G2_1_3 + 0.083333333333333*G2_2_2 + 0.166666666666667*G2_2_3 - 0.166666666666667*G3_1_1 - 0.083333333333333*G3_1_2 - 0.083333333333333*G3_2_1 - 0.166666666666667*G3_2_2;
 
10510
          break;
 
10511
        }
 
10512
      }
 
10513
      
 
10514
        break;
 
10515
      }
 
10516
    case 1:
 
10517
      {
 
10518
        switch (facet1)
 
10519
      {
 
10520
      case 0:
 
10521
        {
 
10522
          A[0] = 0.083333333333333*G4_4_7 + 0.166666666666667*G4_4_9 + 0.083333333333333*G4_5_8 + 0.166666666666667*G4_5_9 - 0.166666666666667*G5_4_4 - 0.083333333333333*G5_4_5 - 0.083333333333333*G5_5_4 - 0.166666666666667*G5_5_5 + 0.083333333333333*G6_0_0 + 0.166666666666667*G6_0_4 + 0.083333333333333*G6_2_2 + 0.166666666666667*G6_2_4 - 0.166666666666667*G7_0_0 - 0.083333333333333*G7_0_2 - 0.083333333333333*G7_2_0 - 0.166666666666667*G7_2_2;
 
10523
        A[1] = 0.083333333333333*G0_4_7 + 0.166666666666667*G0_4_9 + 0.083333333333333*G0_5_8 + 0.166666666666667*G0_5_9 - 0.166666666666667*G1_4_4 - 0.083333333333333*G1_4_5 - 0.083333333333333*G1_5_4 - 0.166666666666667*G1_5_5 + 0.083333333333333*G2_0_0 + 0.166666666666667*G2_0_4 + 0.083333333333333*G2_2_2 + 0.166666666666667*G2_2_4 - 0.166666666666667*G3_0_0 - 0.083333333333333*G3_0_2 - 0.083333333333333*G3_2_0 - 0.166666666666667*G3_2_2;
 
10524
          break;
 
10525
        }
 
10526
      case 1:
 
10527
        {
 
10528
          A[0] = 0.083333333333333*G4_3_6 + 0.166666666666667*G4_3_10 + 0.083333333333333*G4_5_8 + 0.166666666666667*G4_5_10 - 0.166666666666667*G5_3_3 - 0.083333333333333*G5_3_5 - 0.083333333333333*G5_5_3 - 0.166666666666667*G5_5_5 + 0.083333333333333*G6_0_0 + 0.166666666666667*G6_0_4 + 0.083333333333333*G6_2_2 + 0.166666666666667*G6_2_4 - 0.166666666666667*G7_0_0 - 0.083333333333333*G7_0_2 - 0.083333333333333*G7_2_0 - 0.166666666666667*G7_2_2;
 
10529
        A[1] = 0.083333333333333*G0_3_6 + 0.166666666666667*G0_3_10 + 0.083333333333333*G0_5_8 + 0.166666666666667*G0_5_10 - 0.166666666666667*G1_3_3 - 0.083333333333333*G1_3_5 - 0.083333333333333*G1_5_3 - 0.166666666666667*G1_5_5 + 0.083333333333333*G2_0_0 + 0.166666666666667*G2_0_4 + 0.083333333333333*G2_2_2 + 0.166666666666667*G2_2_4 - 0.166666666666667*G3_0_0 - 0.083333333333333*G3_0_2 - 0.083333333333333*G3_2_0 - 0.166666666666667*G3_2_2;
 
10530
          break;
 
10531
        }
 
10532
      case 2:
 
10533
        {
 
10534
          A[0] = 0.083333333333333*G4_3_6 + 0.166666666666667*G4_3_11 + 0.083333333333333*G4_4_7 + 0.166666666666667*G4_4_11 - 0.166666666666666*G5_3_3 - 0.083333333333333*G5_3_4 - 0.083333333333333*G5_4_3 - 0.166666666666667*G5_4_4 + 0.083333333333333*G6_0_0 + 0.166666666666667*G6_0_4 + 0.083333333333333*G6_2_2 + 0.166666666666667*G6_2_4 - 0.166666666666667*G7_0_0 - 0.083333333333333*G7_0_2 - 0.083333333333333*G7_2_0 - 0.166666666666667*G7_2_2;
 
10535
        A[1] = 0.083333333333333*G0_3_6 + 0.166666666666667*G0_3_11 + 0.083333333333333*G0_4_7 + 0.166666666666667*G0_4_11 - 0.166666666666666*G1_3_3 - 0.083333333333333*G1_3_4 - 0.083333333333333*G1_4_3 - 0.166666666666667*G1_4_4 + 0.083333333333333*G2_0_0 + 0.166666666666667*G2_0_4 + 0.083333333333333*G2_2_2 + 0.166666666666667*G2_2_4 - 0.166666666666667*G3_0_0 - 0.083333333333333*G3_0_2 - 0.083333333333333*G3_2_0 - 0.166666666666667*G3_2_2;
 
10536
          break;
 
10537
        }
 
10538
      }
 
10539
      
 
10540
        break;
 
10541
      }
 
10542
    case 2:
 
10543
      {
 
10544
        switch (facet1)
 
10545
      {
 
10546
      case 0:
 
10547
        {
 
10548
          A[0] = 0.083333333333333*G4_4_7 + 0.166666666666667*G4_4_9 + 0.083333333333333*G4_5_8 + 0.166666666666667*G4_5_9 - 0.166666666666667*G5_4_4 - 0.083333333333333*G5_4_5 - 0.083333333333333*G5_5_4 - 0.166666666666667*G5_5_5 + 0.083333333333333*G6_0_0 + 0.166666666666667*G6_0_5 + 0.083333333333333*G6_1_1 + 0.166666666666667*G6_1_5 - 0.166666666666666*G7_0_0 - 0.083333333333333*G7_0_1 - 0.083333333333333*G7_1_0 - 0.166666666666667*G7_1_1;
 
10549
        A[1] = 0.083333333333333*G0_4_7 + 0.166666666666667*G0_4_9 + 0.083333333333333*G0_5_8 + 0.166666666666667*G0_5_9 - 0.166666666666667*G1_4_4 - 0.083333333333333*G1_4_5 - 0.083333333333333*G1_5_4 - 0.166666666666667*G1_5_5 + 0.083333333333333*G2_0_0 + 0.166666666666667*G2_0_5 + 0.083333333333333*G2_1_1 + 0.166666666666667*G2_1_5 - 0.166666666666666*G3_0_0 - 0.083333333333333*G3_0_1 - 0.083333333333333*G3_1_0 - 0.166666666666667*G3_1_1;
 
10550
          break;
 
10551
        }
 
10552
      case 1:
 
10553
        {
 
10554
          A[0] = 0.083333333333333*G4_3_6 + 0.166666666666667*G4_3_10 + 0.083333333333333*G4_5_8 + 0.166666666666667*G4_5_10 - 0.166666666666667*G5_3_3 - 0.083333333333333*G5_3_5 - 0.083333333333333*G5_5_3 - 0.166666666666667*G5_5_5 + 0.083333333333333*G6_0_0 + 0.166666666666667*G6_0_5 + 0.083333333333333*G6_1_1 + 0.166666666666667*G6_1_5 - 0.166666666666666*G7_0_0 - 0.083333333333333*G7_0_1 - 0.083333333333333*G7_1_0 - 0.166666666666667*G7_1_1;
 
10555
        A[1] = 0.083333333333333*G0_3_6 + 0.166666666666667*G0_3_10 + 0.083333333333333*G0_5_8 + 0.166666666666667*G0_5_10 - 0.166666666666667*G1_3_3 - 0.083333333333333*G1_3_5 - 0.083333333333333*G1_5_3 - 0.166666666666667*G1_5_5 + 0.083333333333333*G2_0_0 + 0.166666666666667*G2_0_5 + 0.083333333333333*G2_1_1 + 0.166666666666667*G2_1_5 - 0.166666666666666*G3_0_0 - 0.083333333333333*G3_0_1 - 0.083333333333333*G3_1_0 - 0.166666666666667*G3_1_1;
 
10556
          break;
 
10557
        }
 
10558
      case 2:
 
10559
        {
 
10560
          A[0] = 0.083333333333333*G4_3_6 + 0.166666666666667*G4_3_11 + 0.083333333333333*G4_4_7 + 0.166666666666667*G4_4_11 - 0.166666666666666*G5_3_3 - 0.083333333333333*G5_3_4 - 0.083333333333333*G5_4_3 - 0.166666666666667*G5_4_4 + 0.083333333333333*G6_0_0 + 0.166666666666667*G6_0_5 + 0.083333333333333*G6_1_1 + 0.166666666666667*G6_1_5 - 0.166666666666666*G7_0_0 - 0.083333333333333*G7_0_1 - 0.083333333333333*G7_1_0 - 0.166666666666667*G7_1_1;
 
10561
        A[1] = 0.083333333333333*G0_3_6 + 0.166666666666667*G0_3_11 + 0.083333333333333*G0_4_7 + 0.166666666666667*G0_4_11 - 0.166666666666666*G1_3_3 - 0.083333333333333*G1_3_4 - 0.083333333333333*G1_4_3 - 0.166666666666667*G1_4_4 + 0.083333333333333*G2_0_0 + 0.166666666666667*G2_0_5 + 0.083333333333333*G2_1_1 + 0.166666666666667*G2_1_5 - 0.166666666666666*G3_0_0 - 0.083333333333333*G3_0_1 - 0.083333333333333*G3_1_0 - 0.166666666666667*G3_1_1;
 
10562
          break;
 
10563
        }
 
10564
      }
 
10565
      
 
10566
        break;
 
10567
      }
 
10568
    }
 
10569
    
 
10570
  }
 
10571
 
 
10572
  /// Tabulate the tensor for the contribution from a local interior facet
 
10573
  /// using the specified reference cell quadrature points/weights
 
10574
  virtual void tabulate_tensor(double* A,
 
10575
                               const double * const * w,
 
10576
                               const ufc::cell& c,
 
10577
                               unsigned int num_quadrature_points,
 
10578
                               const double * const * quadrature_points,
 
10579
                               const double* quadrature_weights) const
 
10580
  {
 
10581
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
10582
  }
 
10583
 
 
10584
};
 
10585
 
 
10586
/// This class defines the interface for the tabulation of the cell
 
10587
/// tensor corresponding to the local contribution to a form from
 
10588
/// the integral over a cell.
 
10589
 
 
10590
class adaptivepoisson_cell_integral_8_0: public ufc::cell_integral
 
10591
{
 
10592
public:
 
10593
 
 
10594
  /// Constructor
 
10595
  adaptivepoisson_cell_integral_8_0() : ufc::cell_integral()
 
10596
  {
 
10597
    // Do nothing
 
10598
  }
 
10599
 
 
10600
  /// Destructor
 
10601
  virtual ~adaptivepoisson_cell_integral_8_0()
 
10602
  {
 
10603
    // Do nothing
 
10604
  }
 
10605
 
 
10606
  /// Tabulate the tensor for the contribution from a local cell
 
10607
  virtual void tabulate_tensor(double* A,
 
10608
                               const double * const * w,
 
10609
                               const ufc::cell& c) const
 
10610
  {
 
10611
    // Number of operations (multiply-add pairs) for Jacobian data:      11
 
10612
    // Number of operations (multiply-add pairs) for geometry tensor:    8
 
10613
    // Number of operations (multiply-add pairs) for tensor contraction: 11
 
10614
    // Total number of operations (multiply-add pairs):                  30
 
10615
    
 
10616
    // Extract vertex coordinates
 
10617
    const double * const * x = c.coordinates;
 
10618
    
 
10619
    // Compute Jacobian of affine map from reference cell
 
10620
    const double J_00 = x[1][0] - x[0][0];
 
10621
    const double J_01 = x[2][0] - x[0][0];
 
10622
    const double J_10 = x[1][1] - x[0][1];
 
10623
    const double J_11 = x[2][1] - x[0][1];
 
10624
    
 
10625
    // Compute determinant of Jacobian
 
10626
    double detJ = J_00*J_11 - J_01*J_10;
 
10627
    
 
10628
    // Compute inverse of Jacobian
 
10629
    const double K_00 =  J_11 / detJ;
 
10630
    const double K_01 = -J_01 / detJ;
 
10631
    const double K_10 = -J_10 / detJ;
 
10632
    const double K_11 =  J_00 / detJ;
 
10633
    
 
10634
    // Set scale factor
 
10635
    const double det = std::abs(detJ);
 
10636
    
 
10637
    // Compute geometry tensor
 
10638
    const double G0_0_0 = det*(K_00*K_00 + K_01*K_01);
 
10639
    const double G0_0_1 = det*(K_00*K_10 + K_01*K_11);
 
10640
    const double G0_1_0 = det*(K_10*K_00 + K_11*K_01);
 
10641
    const double G0_1_1 = det*(K_10*K_10 + K_11*K_11);
 
10642
    
 
10643
    // Compute element tensor
 
10644
    A[0] = 0.500000000000000*G0_0_0 + 0.500000000000000*G0_0_1 + 0.500000000000000*G0_1_0 + 0.500000000000000*G0_1_1;
 
10645
    A[1] = -0.500000000000000*G0_0_0 - 0.500000000000000*G0_1_0;
 
10646
    A[2] = -0.500000000000000*G0_0_1 - 0.500000000000000*G0_1_1;
 
10647
    A[3] = -0.500000000000000*G0_0_0 - 0.500000000000000*G0_0_1;
 
10648
    A[4] = 0.500000000000000*G0_0_0;
 
10649
    A[5] = 0.500000000000000*G0_0_1;
 
10650
    A[6] = -0.500000000000000*G0_1_0 - 0.500000000000000*G0_1_1;
 
10651
    A[7] = 0.500000000000000*G0_1_0;
 
10652
    A[8] = 0.500000000000000*G0_1_1;
 
10653
  }
 
10654
 
 
10655
  /// Tabulate the tensor for the contribution from a local cell
 
10656
  /// using the specified reference cell quadrature points/weights
 
10657
  virtual void tabulate_tensor(double* A,
 
10658
                               const double * const * w,
 
10659
                               const ufc::cell& c,
 
10660
                               unsigned int num_quadrature_points,
 
10661
                               const double * const * quadrature_points,
 
10662
                               const double* quadrature_weights) const
 
10663
  {
 
10664
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
10665
  }
 
10666
 
 
10667
};
 
10668
 
 
10669
/// This class defines the interface for the tabulation of the cell
 
10670
/// tensor corresponding to the local contribution to a form from
 
10671
/// the integral over a cell.
 
10672
 
 
10673
class adaptivepoisson_cell_integral_9_0: public ufc::cell_integral
 
10674
{
 
10675
public:
 
10676
 
 
10677
  /// Constructor
 
10678
  adaptivepoisson_cell_integral_9_0() : ufc::cell_integral()
 
10679
  {
 
10680
    // Do nothing
 
10681
  }
 
10682
 
 
10683
  /// Destructor
 
10684
  virtual ~adaptivepoisson_cell_integral_9_0()
 
10685
  {
 
10686
    // Do nothing
 
10687
  }
 
10688
 
 
10689
  /// Tabulate the tensor for the contribution from a local cell
 
10690
  virtual void tabulate_tensor(double* A,
 
10691
                               const double * const * w,
 
10692
                               const ufc::cell& c) const
 
10693
  {
 
10694
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
10695
    // Number of operations (multiply-add pairs) for geometry tensor:    3
 
10696
    // Number of operations (multiply-add pairs) for tensor contraction: 7
 
10697
    // Total number of operations (multiply-add pairs):                  19
 
10698
    
 
10699
    // Extract vertex coordinates
 
10700
    const double * const * x = c.coordinates;
 
10701
    
 
10702
    // Compute Jacobian of affine map from reference cell
 
10703
    const double J_00 = x[1][0] - x[0][0];
 
10704
    const double J_01 = x[2][0] - x[0][0];
 
10705
    const double J_10 = x[1][1] - x[0][1];
 
10706
    const double J_11 = x[2][1] - x[0][1];
 
10707
    
 
10708
    // Compute determinant of Jacobian
 
10709
    double detJ = J_00*J_11 - J_01*J_10;
 
10710
    
 
10711
    // Compute inverse of Jacobian
 
10712
    
 
10713
    // Set scale factor
 
10714
    const double det = std::abs(detJ);
 
10715
    
 
10716
    // Compute geometry tensor
 
10717
    const double G0_0 = det*w[0][0]*(1.0);
 
10718
    const double G0_1 = det*w[0][1]*(1.0);
 
10719
    const double G0_2 = det*w[0][2]*(1.0);
 
10720
    
 
10721
    // Compute element tensor
 
10722
    A[0] = 0.083333333333333*G0_0 + 0.041666666666667*G0_1 + 0.041666666666667*G0_2;
 
10723
    A[1] = 0.041666666666667*G0_0 + 0.083333333333333*G0_1 + 0.041666666666667*G0_2;
 
10724
    A[2] = 0.041666666666667*G0_0 + 0.041666666666667*G0_1 + 0.083333333333333*G0_2;
 
10725
  }
 
10726
 
 
10727
  /// Tabulate the tensor for the contribution from a local cell
 
10728
  /// using the specified reference cell quadrature points/weights
 
10729
  virtual void tabulate_tensor(double* A,
 
10730
                               const double * const * w,
 
10731
                               const ufc::cell& c,
 
10732
                               unsigned int num_quadrature_points,
 
10733
                               const double * const * quadrature_points,
 
10734
                               const double* quadrature_weights) const
 
10735
  {
 
10736
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
10737
  }
 
10738
 
 
10739
};
 
10740
 
 
10741
/// This class defines the interface for the tabulation of the
 
10742
/// exterior facet tensor corresponding to the local contribution to
 
10743
/// a form from the integral over an exterior facet.
 
10744
 
 
10745
class adaptivepoisson_exterior_facet_integral_9_0: public ufc::exterior_facet_integral
 
10746
{
 
10747
public:
 
10748
 
 
10749
  /// Constructor
 
10750
  adaptivepoisson_exterior_facet_integral_9_0() : ufc::exterior_facet_integral()
 
10751
  {
 
10752
    // Do nothing
 
10753
  }
 
10754
 
 
10755
  /// Destructor
 
10756
  virtual ~adaptivepoisson_exterior_facet_integral_9_0()
 
10757
  {
 
10758
    // Do nothing
 
10759
  }
 
10760
 
 
10761
  /// Tabulate the tensor for the contribution from a local exterior facet
 
10762
  virtual void tabulate_tensor(double* A,
 
10763
                               const double * const * w,
 
10764
                               const ufc::cell& c,
 
10765
                               unsigned int facet) const
 
10766
  {
 
10767
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
10768
    // Number of operations (multiply-add pairs) for geometry tensor:    3
 
10769
    // Number of operations (multiply-add pairs) for tensor contraction: 9
 
10770
    // Total number of operations (multiply-add pairs):                  21
 
10771
    
 
10772
    // Extract vertex coordinates
 
10773
    const double * const * x = c.coordinates;
 
10774
    
 
10775
    // Compute Jacobian of affine map from reference cell
 
10776
    
 
10777
    // Compute determinant of Jacobian
 
10778
    
 
10779
    // Compute inverse of Jacobian
 
10780
    
 
10781
    // Get vertices on edge
 
10782
    static unsigned int edge_vertices[3][2] = {{1, 2}, {0, 2}, {0, 1}};
 
10783
    const unsigned int v0 = edge_vertices[facet][0];
 
10784
    const unsigned int v1 = edge_vertices[facet][1];
 
10785
    
 
10786
    // Compute scale factor (length of edge scaled by length of reference interval)
 
10787
    const double dx0 = x[v1][0] - x[v0][0];
 
10788
    const double dx1 = x[v1][1] - x[v0][1];
 
10789
    const double det = std::sqrt(dx0*dx0 + dx1*dx1);
 
10790
    
 
10791
    // Compute geometry tensor
 
10792
    const double G0_0 = det*w[1][0]*(1.0);
 
10793
    const double G0_1 = det*w[1][1]*(1.0);
 
10794
    const double G0_2 = det*w[1][2]*(1.0);
 
10795
    
 
10796
    // Compute element tensor
 
10797
    switch (facet)
 
10798
    {
 
10799
    case 0:
 
10800
      {
 
10801
        A[0] = 0.000000000000000;
 
10802
      A[1] = 0.333333333333333*G0_1 + 0.166666666666667*G0_2;
 
10803
      A[2] = 0.166666666666667*G0_1 + 0.333333333333333*G0_2;
 
10804
        break;
 
10805
      }
 
10806
    case 1:
 
10807
      {
 
10808
        A[0] = 0.333333333333333*G0_0 + 0.166666666666667*G0_2;
 
10809
      A[1] = 0.000000000000000;
 
10810
      A[2] = 0.166666666666667*G0_0 + 0.333333333333333*G0_2;
 
10811
        break;
 
10812
      }
 
10813
    case 2:
 
10814
      {
 
10815
        A[0] = 0.333333333333333*G0_0 + 0.166666666666667*G0_1;
 
10816
      A[1] = 0.166666666666667*G0_0 + 0.333333333333333*G0_1;
 
10817
      A[2] = 0.000000000000000;
 
10818
        break;
 
10819
      }
 
10820
    }
 
10821
    
 
10822
  }
 
10823
 
 
10824
  /// Tabulate the tensor for the contribution from a local exterior facet
 
10825
  /// using the specified reference cell quadrature points/weights
 
10826
  virtual void tabulate_tensor(double* A,
 
10827
                               const double * const * w,
 
10828
                               const ufc::cell& c,
 
10829
                               unsigned int num_quadrature_points,
 
10830
                               const double * const * quadrature_points,
 
10831
                               const double* quadrature_weights) const
 
10832
  {
 
10833
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
10834
  }
 
10835
 
 
10836
};
 
10837
 
 
10838
/// This class defines the interface for the tabulation of the cell
 
10839
/// tensor corresponding to the local contribution to a form from
 
10840
/// the integral over a cell.
 
10841
 
 
10842
class adaptivepoisson_cell_integral_10_0: public ufc::cell_integral
 
10843
{
 
10844
public:
 
10845
 
 
10846
  /// Constructor
 
10847
  adaptivepoisson_cell_integral_10_0() : ufc::cell_integral()
 
10848
  {
 
10849
    // Do nothing
 
10850
  }
 
10851
 
 
10852
  /// Destructor
 
10853
  virtual ~adaptivepoisson_cell_integral_10_0()
 
10854
  {
 
10855
    // Do nothing
 
10856
  }
 
10857
 
 
10858
  /// Tabulate the tensor for the contribution from a local cell
 
10859
  virtual void tabulate_tensor(double* A,
 
10860
                               const double * const * w,
 
10861
                               const ufc::cell& c) const
 
10862
  {
 
10863
    // Number of operations (multiply-add pairs) for Jacobian data:      9
 
10864
    // Number of operations (multiply-add pairs) for geometry tensor:    3
 
10865
    // Number of operations (multiply-add pairs) for tensor contraction: 2
 
10866
    // Total number of operations (multiply-add pairs):                  14
 
10867
    
 
10868
    // Extract vertex coordinates
 
10869
    const double * const * x = c.coordinates;
 
10870
    
 
10871
    // Compute Jacobian of affine map from reference cell
 
10872
    const double J_00 = x[1][0] - x[0][0];
 
10873
    const double J_01 = x[2][0] - x[0][0];
 
10874
    const double J_10 = x[1][1] - x[0][1];
 
10875
    const double J_11 = x[2][1] - x[0][1];
 
10876
    
 
10877
    // Compute determinant of Jacobian
 
10878
    double detJ = J_00*J_11 - J_01*J_10;
 
10879
    
 
10880
    // Compute inverse of Jacobian
 
10881
    
 
10882
    // Set scale factor
 
10883
    const double det = std::abs(detJ);
 
10884
    
 
10885
    // Compute geometry tensor
 
10886
    const double G0_0 = det*w[0][0]*(1.0);
 
10887
    const double G0_1 = det*w[0][1]*(1.0);
 
10888
    const double G0_2 = det*w[0][2]*(1.0);
 
10889
    
 
10890
    // Compute element tensor
 
10891
    A[0] = 0.166666666666667*G0_0 + 0.166666666666667*G0_1 + 0.166666666666667*G0_2;
 
10892
  }
 
10893
 
 
10894
  /// Tabulate the tensor for the contribution from a local cell
 
10895
  /// using the specified reference cell quadrature points/weights
 
10896
  virtual void tabulate_tensor(double* A,
 
10897
                               const double * const * w,
 
10898
                               const ufc::cell& c,
 
10899
                               unsigned int num_quadrature_points,
 
10900
                               const double * const * quadrature_points,
 
10901
                               const double* quadrature_weights) const
 
10902
  {
 
10903
    throw std::runtime_error("Quadrature version of tabulate_tensor not available when using the FFC tensor representation.");
 
10904
  }
 
10905
 
 
10906
};
 
10907
 
 
10908
/// This class defines the interface for the assembly of the global
 
10909
/// tensor corresponding to a form with r + n arguments, that is, a
 
10910
/// mapping
 
10911
///
 
10912
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
10913
///
 
10914
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
10915
/// global tensor A is defined by
 
10916
///
 
10917
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
10918
///
 
10919
/// where each argument Vj represents the application to the
 
10920
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
10921
/// fixed functions (coefficients).
 
10922
 
 
10923
class adaptivepoisson_form_0: public ufc::form
 
10924
{
 
10925
public:
 
10926
 
 
10927
  /// Constructor
 
10928
  adaptivepoisson_form_0() : ufc::form()
 
10929
  {
 
10930
    // Do nothing
 
10931
  }
 
10932
 
 
10933
  /// Destructor
 
10934
  virtual ~adaptivepoisson_form_0()
 
10935
  {
 
10936
    // Do nothing
 
10937
  }
 
10938
 
 
10939
  /// Return a string identifying the form
 
10940
  virtual const char* signature() const
 
10941
  {
 
10942
    return "Form([Integral(IndexSum(Product(Indexed(ComponentTensor(SpatialDerivative(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(1),), {Index(1): 2})), Indexed(ComponentTensor(SpatialDerivative(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 1), MultiIndex((Index(2),), {Index(2): 2})), MultiIndex((Index(2),), {Index(2): 2})), MultiIndex((Index(1),), {Index(1): 2}))), MultiIndex((Index(1),), {Index(1): 2})), Measure('cell', 0, None))])";
 
10943
  }
 
10944
 
 
10945
  /// Return the rank of the global tensor (r)
 
10946
  virtual unsigned int rank() const
 
10947
  {
 
10948
    return 2;
 
10949
  }
 
10950
 
 
10951
  /// Return the number of coefficients (n)
 
10952
  virtual unsigned int num_coefficients() const
 
10953
  {
 
10954
    return 0;
 
10955
  }
 
10956
 
 
10957
  /// Return the number of cell domains
 
10958
  virtual unsigned int num_cell_domains() const
 
10959
  {
 
10960
    return 1;
 
10961
  }
 
10962
 
 
10963
  /// Return the number of exterior facet domains
 
10964
  virtual unsigned int num_exterior_facet_domains() const
 
10965
  {
 
10966
    return 0;
 
10967
  }
 
10968
 
 
10969
  /// Return the number of interior facet domains
 
10970
  virtual unsigned int num_interior_facet_domains() const
 
10971
  {
 
10972
    return 0;
 
10973
  }
 
10974
 
 
10975
  /// Create a new finite element for argument function i
 
10976
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
10977
  {
 
10978
    switch (i)
 
10979
    {
 
10980
    case 0:
 
10981
      {
 
10982
        return new adaptivepoisson_finite_element_5();
 
10983
        break;
 
10984
      }
 
10985
    case 1:
 
10986
      {
 
10987
        return new adaptivepoisson_finite_element_5();
 
10988
        break;
 
10989
      }
 
10990
    }
 
10991
    
 
10992
    return 0;
 
10993
  }
 
10994
 
 
10995
  /// Create a new dofmap for argument function i
 
10996
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
10997
  {
 
10998
    switch (i)
 
10999
    {
 
11000
    case 0:
 
11001
      {
 
11002
        return new adaptivepoisson_dofmap_5();
 
11003
        break;
 
11004
      }
 
11005
    case 1:
 
11006
      {
 
11007
        return new adaptivepoisson_dofmap_5();
 
11008
        break;
 
11009
      }
 
11010
    }
 
11011
    
 
11012
    return 0;
 
11013
  }
 
11014
 
 
11015
  /// Create a new cell integral on sub domain i
 
11016
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
11017
  {
 
11018
    switch (i)
 
11019
    {
 
11020
    case 0:
 
11021
      {
 
11022
        return new adaptivepoisson_cell_integral_0_0();
 
11023
        break;
 
11024
      }
 
11025
    }
 
11026
    
 
11027
    return 0;
 
11028
  }
 
11029
 
 
11030
  /// Create a new exterior facet integral on sub domain i
 
11031
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
11032
  {
 
11033
    return 0;
 
11034
  }
 
11035
 
 
11036
  /// Create a new interior facet integral on sub domain i
 
11037
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
11038
  {
 
11039
    return 0;
 
11040
  }
 
11041
 
 
11042
};
 
11043
 
 
11044
/// This class defines the interface for the assembly of the global
 
11045
/// tensor corresponding to a form with r + n arguments, that is, a
 
11046
/// mapping
 
11047
///
 
11048
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
11049
///
 
11050
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
11051
/// global tensor A is defined by
 
11052
///
 
11053
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
11054
///
 
11055
/// where each argument Vj represents the application to the
 
11056
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
11057
/// fixed functions (coefficients).
 
11058
 
 
11059
class adaptivepoisson_form_1: public ufc::form
 
11060
{
 
11061
public:
 
11062
 
 
11063
  /// Constructor
 
11064
  adaptivepoisson_form_1() : ufc::form()
 
11065
  {
 
11066
    // Do nothing
 
11067
  }
 
11068
 
 
11069
  /// Destructor
 
11070
  virtual ~adaptivepoisson_form_1()
 
11071
  {
 
11072
    // Do nothing
 
11073
  }
 
11074
 
 
11075
  /// Return a string identifying the form
 
11076
  virtual const char* signature() const
 
11077
  {
 
11078
    return "Form([Integral(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Measure('cell', 0, None))])";
 
11079
  }
 
11080
 
 
11081
  /// Return the rank of the global tensor (r)
 
11082
  virtual unsigned int rank() const
 
11083
  {
 
11084
    return 1;
 
11085
  }
 
11086
 
 
11087
  /// Return the number of coefficients (n)
 
11088
  virtual unsigned int num_coefficients() const
 
11089
  {
 
11090
    return 0;
 
11091
  }
 
11092
 
 
11093
  /// Return the number of cell domains
 
11094
  virtual unsigned int num_cell_domains() const
 
11095
  {
 
11096
    return 1;
 
11097
  }
 
11098
 
 
11099
  /// Return the number of exterior facet domains
 
11100
  virtual unsigned int num_exterior_facet_domains() const
 
11101
  {
 
11102
    return 0;
 
11103
  }
 
11104
 
 
11105
  /// Return the number of interior facet domains
 
11106
  virtual unsigned int num_interior_facet_domains() const
 
11107
  {
 
11108
    return 0;
 
11109
  }
 
11110
 
 
11111
  /// Create a new finite element for argument function i
 
11112
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
11113
  {
 
11114
    switch (i)
 
11115
    {
 
11116
    case 0:
 
11117
      {
 
11118
        return new adaptivepoisson_finite_element_5();
 
11119
        break;
 
11120
      }
 
11121
    }
 
11122
    
 
11123
    return 0;
 
11124
  }
 
11125
 
 
11126
  /// Create a new dofmap for argument function i
 
11127
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
11128
  {
 
11129
    switch (i)
 
11130
    {
 
11131
    case 0:
 
11132
      {
 
11133
        return new adaptivepoisson_dofmap_5();
 
11134
        break;
 
11135
      }
 
11136
    }
 
11137
    
 
11138
    return 0;
 
11139
  }
 
11140
 
 
11141
  /// Create a new cell integral on sub domain i
 
11142
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
11143
  {
 
11144
    switch (i)
 
11145
    {
 
11146
    case 0:
 
11147
      {
 
11148
        return new adaptivepoisson_cell_integral_1_0();
 
11149
        break;
 
11150
      }
 
11151
    }
 
11152
    
 
11153
    return 0;
 
11154
  }
 
11155
 
 
11156
  /// Create a new exterior facet integral on sub domain i
 
11157
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
11158
  {
 
11159
    return 0;
 
11160
  }
 
11161
 
 
11162
  /// Create a new interior facet integral on sub domain i
 
11163
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
11164
  {
 
11165
    return 0;
 
11166
  }
 
11167
 
 
11168
};
 
11169
 
 
11170
/// This class defines the interface for the assembly of the global
 
11171
/// tensor corresponding to a form with r + n arguments, that is, a
 
11172
/// mapping
 
11173
///
 
11174
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
11175
///
 
11176
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
11177
/// global tensor A is defined by
 
11178
///
 
11179
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
11180
///
 
11181
/// where each argument Vj represents the application to the
 
11182
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
11183
/// fixed functions (coefficients).
 
11184
 
 
11185
class adaptivepoisson_form_2: public ufc::form
 
11186
{
 
11187
public:
 
11188
 
 
11189
  /// Constructor
 
11190
  adaptivepoisson_form_2() : ufc::form()
 
11191
  {
 
11192
    // Do nothing
 
11193
  }
 
11194
 
 
11195
  /// Destructor
 
11196
  virtual ~adaptivepoisson_form_2()
 
11197
  {
 
11198
    // Do nothing
 
11199
  }
 
11200
 
 
11201
  /// Return a string identifying the form
 
11202
  virtual const char* signature() const
 
11203
  {
 
11204
    return "Form([Integral(Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 1), Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Bubble', Cell('triangle', 1, Space(2)), 3), 0))), Measure('cell', 0, None))])";
 
11205
  }
 
11206
 
 
11207
  /// Return the rank of the global tensor (r)
 
11208
  virtual unsigned int rank() const
 
11209
  {
 
11210
    return 2;
 
11211
  }
 
11212
 
 
11213
  /// Return the number of coefficients (n)
 
11214
  virtual unsigned int num_coefficients() const
 
11215
  {
 
11216
    return 1;
 
11217
  }
 
11218
 
 
11219
  /// Return the number of cell domains
 
11220
  virtual unsigned int num_cell_domains() const
 
11221
  {
 
11222
    return 1;
 
11223
  }
 
11224
 
 
11225
  /// Return the number of exterior facet domains
 
11226
  virtual unsigned int num_exterior_facet_domains() const
 
11227
  {
 
11228
    return 0;
 
11229
  }
 
11230
 
 
11231
  /// Return the number of interior facet domains
 
11232
  virtual unsigned int num_interior_facet_domains() const
 
11233
  {
 
11234
    return 0;
 
11235
  }
 
11236
 
 
11237
  /// Create a new finite element for argument function i
 
11238
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
11239
  {
 
11240
    switch (i)
 
11241
    {
 
11242
    case 0:
 
11243
      {
 
11244
        return new adaptivepoisson_finite_element_4();
 
11245
        break;
 
11246
      }
 
11247
    case 1:
 
11248
      {
 
11249
        return new adaptivepoisson_finite_element_4();
 
11250
        break;
 
11251
      }
 
11252
    case 2:
 
11253
      {
 
11254
        return new adaptivepoisson_finite_element_3();
 
11255
        break;
 
11256
      }
 
11257
    }
 
11258
    
 
11259
    return 0;
 
11260
  }
 
11261
 
 
11262
  /// Create a new dofmap for argument function i
 
11263
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
11264
  {
 
11265
    switch (i)
 
11266
    {
 
11267
    case 0:
 
11268
      {
 
11269
        return new adaptivepoisson_dofmap_4();
 
11270
        break;
 
11271
      }
 
11272
    case 1:
 
11273
      {
 
11274
        return new adaptivepoisson_dofmap_4();
 
11275
        break;
 
11276
      }
 
11277
    case 2:
 
11278
      {
 
11279
        return new adaptivepoisson_dofmap_3();
 
11280
        break;
 
11281
      }
 
11282
    }
 
11283
    
 
11284
    return 0;
 
11285
  }
 
11286
 
 
11287
  /// Create a new cell integral on sub domain i
 
11288
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
11289
  {
 
11290
    switch (i)
 
11291
    {
 
11292
    case 0:
 
11293
      {
 
11294
        return new adaptivepoisson_cell_integral_2_0();
 
11295
        break;
 
11296
      }
 
11297
    }
 
11298
    
 
11299
    return 0;
 
11300
  }
 
11301
 
 
11302
  /// Create a new exterior facet integral on sub domain i
 
11303
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
11304
  {
 
11305
    return 0;
 
11306
  }
 
11307
 
 
11308
  /// Create a new interior facet integral on sub domain i
 
11309
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
11310
  {
 
11311
    return 0;
 
11312
  }
 
11313
 
 
11314
};
 
11315
 
 
11316
/// This class defines the interface for the assembly of the global
 
11317
/// tensor corresponding to a form with r + n arguments, that is, a
 
11318
/// mapping
 
11319
///
 
11320
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
11321
///
 
11322
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
11323
/// global tensor A is defined by
 
11324
///
 
11325
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
11326
///
 
11327
/// where each argument Vj represents the application to the
 
11328
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
11329
/// fixed functions (coefficients).
 
11330
 
 
11331
class adaptivepoisson_form_3: public ufc::form
 
11332
{
 
11333
public:
 
11334
 
 
11335
  /// Constructor
 
11336
  adaptivepoisson_form_3() : ufc::form()
 
11337
  {
 
11338
    // Do nothing
 
11339
  }
 
11340
 
 
11341
  /// Destructor
 
11342
  virtual ~adaptivepoisson_form_3()
 
11343
  {
 
11344
    // Do nothing
 
11345
  }
 
11346
 
 
11347
  /// Return a string identifying the form
 
11348
  virtual const char* signature() const
 
11349
  {
 
11350
    return "Form([Integral(Sum(Product(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Bubble', Cell('triangle', 1, Space(2)), 3), 3))), Product(IntValue(-1, (), (), {}), IndexSum(Product(Indexed(ComponentTensor(SpatialDerivative(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 2), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(1),), {Index(1): 2})), Indexed(ComponentTensor(Sum(Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), SpatialDerivative(Coefficient(FiniteElement('Bubble', Cell('triangle', 1, Space(2)), 3), 3), MultiIndex((Index(2),), {Index(2): 2}))), Product(Coefficient(FiniteElement('Bubble', Cell('triangle', 1, Space(2)), 3), 3), SpatialDerivative(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), MultiIndex((Index(2),), {Index(2): 2})))), MultiIndex((Index(2),), {Index(2): 2})), MultiIndex((Index(1),), {Index(1): 2}))), MultiIndex((Index(1),), {Index(1): 2})))), Measure('cell', 0, None)), Integral(Product(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 1), Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Bubble', Cell('triangle', 1, Space(2)), 3), 3))), Measure('exterior_facet', 0, None))])";
 
11351
  }
 
11352
 
 
11353
  /// Return the rank of the global tensor (r)
 
11354
  virtual unsigned int rank() const
 
11355
  {
 
11356
    return 1;
 
11357
  }
 
11358
 
 
11359
  /// Return the number of coefficients (n)
 
11360
  virtual unsigned int num_coefficients() const
 
11361
  {
 
11362
    return 4;
 
11363
  }
 
11364
 
 
11365
  /// Return the number of cell domains
 
11366
  virtual unsigned int num_cell_domains() const
 
11367
  {
 
11368
    return 1;
 
11369
  }
 
11370
 
 
11371
  /// Return the number of exterior facet domains
 
11372
  virtual unsigned int num_exterior_facet_domains() const
 
11373
  {
 
11374
    return 1;
 
11375
  }
 
11376
 
 
11377
  /// Return the number of interior facet domains
 
11378
  virtual unsigned int num_interior_facet_domains() const
 
11379
  {
 
11380
    return 0;
 
11381
  }
 
11382
 
 
11383
  /// Create a new finite element for argument function i
 
11384
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
11385
  {
 
11386
    switch (i)
 
11387
    {
 
11388
    case 0:
 
11389
      {
 
11390
        return new adaptivepoisson_finite_element_4();
 
11391
        break;
 
11392
      }
 
11393
    case 1:
 
11394
      {
 
11395
        return new adaptivepoisson_finite_element_5();
 
11396
        break;
 
11397
      }
 
11398
    case 2:
 
11399
      {
 
11400
        return new adaptivepoisson_finite_element_5();
 
11401
        break;
 
11402
      }
 
11403
    case 3:
 
11404
      {
 
11405
        return new adaptivepoisson_finite_element_5();
 
11406
        break;
 
11407
      }
 
11408
    case 4:
 
11409
      {
 
11410
        return new adaptivepoisson_finite_element_3();
 
11411
        break;
 
11412
      }
 
11413
    }
 
11414
    
 
11415
    return 0;
 
11416
  }
 
11417
 
 
11418
  /// Create a new dofmap for argument function i
 
11419
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
11420
  {
 
11421
    switch (i)
 
11422
    {
 
11423
    case 0:
 
11424
      {
 
11425
        return new adaptivepoisson_dofmap_4();
 
11426
        break;
 
11427
      }
 
11428
    case 1:
 
11429
      {
 
11430
        return new adaptivepoisson_dofmap_5();
 
11431
        break;
 
11432
      }
 
11433
    case 2:
 
11434
      {
 
11435
        return new adaptivepoisson_dofmap_5();
 
11436
        break;
 
11437
      }
 
11438
    case 3:
 
11439
      {
 
11440
        return new adaptivepoisson_dofmap_5();
 
11441
        break;
 
11442
      }
 
11443
    case 4:
 
11444
      {
 
11445
        return new adaptivepoisson_dofmap_3();
 
11446
        break;
 
11447
      }
 
11448
    }
 
11449
    
 
11450
    return 0;
 
11451
  }
 
11452
 
 
11453
  /// Create a new cell integral on sub domain i
 
11454
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
11455
  {
 
11456
    switch (i)
 
11457
    {
 
11458
    case 0:
 
11459
      {
 
11460
        return new adaptivepoisson_cell_integral_3_0();
 
11461
        break;
 
11462
      }
 
11463
    }
 
11464
    
 
11465
    return 0;
 
11466
  }
 
11467
 
 
11468
  /// Create a new exterior facet integral on sub domain i
 
11469
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
11470
  {
 
11471
    switch (i)
 
11472
    {
 
11473
    case 0:
 
11474
      {
 
11475
        return new adaptivepoisson_exterior_facet_integral_3_0();
 
11476
        break;
 
11477
      }
 
11478
    }
 
11479
    
 
11480
    return 0;
 
11481
  }
 
11482
 
 
11483
  /// Create a new interior facet integral on sub domain i
 
11484
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
11485
  {
 
11486
    return 0;
 
11487
  }
 
11488
 
 
11489
};
 
11490
 
 
11491
/// This class defines the interface for the assembly of the global
 
11492
/// tensor corresponding to a form with r + n arguments, that is, a
 
11493
/// mapping
 
11494
///
 
11495
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
11496
///
 
11497
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
11498
/// global tensor A is defined by
 
11499
///
 
11500
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
11501
///
 
11502
/// where each argument Vj represents the application to the
 
11503
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
11504
/// fixed functions (coefficients).
 
11505
 
 
11506
class adaptivepoisson_form_4: public ufc::form
 
11507
{
 
11508
public:
 
11509
 
 
11510
  /// Constructor
 
11511
  adaptivepoisson_form_4() : ufc::form()
 
11512
  {
 
11513
    // Do nothing
 
11514
  }
 
11515
 
 
11516
  /// Destructor
 
11517
  virtual ~adaptivepoisson_form_4()
 
11518
  {
 
11519
    // Do nothing
 
11520
  }
 
11521
 
 
11522
  /// Return a string identifying the form
 
11523
  virtual const char* signature() const
 
11524
  {
 
11525
    return "Form([Integral(Sum(Product(NegativeRestricted(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 1)), NegativeRestricted(Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2), 0)))), Product(PositiveRestricted(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 1)), PositiveRestricted(Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2), 0))))), Measure('interior_facet', 0, None)), Integral(Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 1), Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2), 0))), Measure('exterior_facet', 0, None))])";
 
11526
  }
 
11527
 
 
11528
  /// Return the rank of the global tensor (r)
 
11529
  virtual unsigned int rank() const
 
11530
  {
 
11531
    return 2;
 
11532
  }
 
11533
 
 
11534
  /// Return the number of coefficients (n)
 
11535
  virtual unsigned int num_coefficients() const
 
11536
  {
 
11537
    return 1;
 
11538
  }
 
11539
 
 
11540
  /// Return the number of cell domains
 
11541
  virtual unsigned int num_cell_domains() const
 
11542
  {
 
11543
    return 0;
 
11544
  }
 
11545
 
 
11546
  /// Return the number of exterior facet domains
 
11547
  virtual unsigned int num_exterior_facet_domains() const
 
11548
  {
 
11549
    return 1;
 
11550
  }
 
11551
 
 
11552
  /// Return the number of interior facet domains
 
11553
  virtual unsigned int num_interior_facet_domains() const
 
11554
  {
 
11555
    return 1;
 
11556
  }
 
11557
 
 
11558
  /// Create a new finite element for argument function i
 
11559
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
11560
  {
 
11561
    switch (i)
 
11562
    {
 
11563
    case 0:
 
11564
      {
 
11565
        return new adaptivepoisson_finite_element_4();
 
11566
        break;
 
11567
      }
 
11568
    case 1:
 
11569
      {
 
11570
        return new adaptivepoisson_finite_element_4();
 
11571
        break;
 
11572
      }
 
11573
    case 2:
 
11574
      {
 
11575
        return new adaptivepoisson_finite_element_2();
 
11576
        break;
 
11577
      }
 
11578
    }
 
11579
    
 
11580
    return 0;
 
11581
  }
 
11582
 
 
11583
  /// Create a new dofmap for argument function i
 
11584
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
11585
  {
 
11586
    switch (i)
 
11587
    {
 
11588
    case 0:
 
11589
      {
 
11590
        return new adaptivepoisson_dofmap_4();
 
11591
        break;
 
11592
      }
 
11593
    case 1:
 
11594
      {
 
11595
        return new adaptivepoisson_dofmap_4();
 
11596
        break;
 
11597
      }
 
11598
    case 2:
 
11599
      {
 
11600
        return new adaptivepoisson_dofmap_2();
 
11601
        break;
 
11602
      }
 
11603
    }
 
11604
    
 
11605
    return 0;
 
11606
  }
 
11607
 
 
11608
  /// Create a new cell integral on sub domain i
 
11609
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
11610
  {
 
11611
    return 0;
 
11612
  }
 
11613
 
 
11614
  /// Create a new exterior facet integral on sub domain i
 
11615
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
11616
  {
 
11617
    switch (i)
 
11618
    {
 
11619
    case 0:
 
11620
      {
 
11621
        return new adaptivepoisson_exterior_facet_integral_4_0();
 
11622
        break;
 
11623
      }
 
11624
    }
 
11625
    
 
11626
    return 0;
 
11627
  }
 
11628
 
 
11629
  /// Create a new interior facet integral on sub domain i
 
11630
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
11631
  {
 
11632
    switch (i)
 
11633
    {
 
11634
    case 0:
 
11635
      {
 
11636
        return new adaptivepoisson_interior_facet_integral_4_0();
 
11637
        break;
 
11638
      }
 
11639
    }
 
11640
    
 
11641
    return 0;
 
11642
  }
 
11643
 
 
11644
};
 
11645
 
 
11646
/// This class defines the interface for the assembly of the global
 
11647
/// tensor corresponding to a form with r + n arguments, that is, a
 
11648
/// mapping
 
11649
///
 
11650
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
11651
///
 
11652
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
11653
/// global tensor A is defined by
 
11654
///
 
11655
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
11656
///
 
11657
/// where each argument Vj represents the application to the
 
11658
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
11659
/// fixed functions (coefficients).
 
11660
 
 
11661
class adaptivepoisson_form_5: public ufc::form
 
11662
{
 
11663
public:
 
11664
 
 
11665
  /// Constructor
 
11666
  adaptivepoisson_form_5() : ufc::form()
 
11667
  {
 
11668
    // Do nothing
 
11669
  }
 
11670
 
 
11671
  /// Destructor
 
11672
  virtual ~adaptivepoisson_form_5()
 
11673
  {
 
11674
    // Do nothing
 
11675
  }
 
11676
 
 
11677
  /// Return a string identifying the form
 
11678
  virtual const char* signature() const
 
11679
  {
 
11680
    return "Form([Integral(Sum(Product(IntValue(-1, (), (), {}), Product(Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 3), Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2), 4)))), Sum(Product(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2), 4))), Product(IntValue(-1, (), (), {}), IndexSum(Product(Indexed(ComponentTensor(SpatialDerivative(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 2), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(1),), {Index(1): 2})), Indexed(ComponentTensor(Sum(Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), SpatialDerivative(Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2), 4), MultiIndex((Index(2),), {Index(2): 2}))), Product(Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2), 4), SpatialDerivative(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), MultiIndex((Index(2),), {Index(2): 2})))), MultiIndex((Index(2),), {Index(2): 2})), MultiIndex((Index(1),), {Index(1): 2}))), MultiIndex((Index(1),), {Index(1): 2}))))), Measure('cell', 0, None)), Integral(Product(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 1), Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 2), 4))), Measure('exterior_facet', 0, None))])";
 
11681
  }
 
11682
 
 
11683
  /// Return the rank of the global tensor (r)
 
11684
  virtual unsigned int rank() const
 
11685
  {
 
11686
    return 1;
 
11687
  }
 
11688
 
 
11689
  /// Return the number of coefficients (n)
 
11690
  virtual unsigned int num_coefficients() const
 
11691
  {
 
11692
    return 5;
 
11693
  }
 
11694
 
 
11695
  /// Return the number of cell domains
 
11696
  virtual unsigned int num_cell_domains() const
 
11697
  {
 
11698
    return 1;
 
11699
  }
 
11700
 
 
11701
  /// Return the number of exterior facet domains
 
11702
  virtual unsigned int num_exterior_facet_domains() const
 
11703
  {
 
11704
    return 1;
 
11705
  }
 
11706
 
 
11707
  /// Return the number of interior facet domains
 
11708
  virtual unsigned int num_interior_facet_domains() const
 
11709
  {
 
11710
    return 0;
 
11711
  }
 
11712
 
 
11713
  /// Create a new finite element for argument function i
 
11714
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
11715
  {
 
11716
    switch (i)
 
11717
    {
 
11718
    case 0:
 
11719
      {
 
11720
        return new adaptivepoisson_finite_element_4();
 
11721
        break;
 
11722
      }
 
11723
    case 1:
 
11724
      {
 
11725
        return new adaptivepoisson_finite_element_5();
 
11726
        break;
 
11727
      }
 
11728
    case 2:
 
11729
      {
 
11730
        return new adaptivepoisson_finite_element_5();
 
11731
        break;
 
11732
      }
 
11733
    case 3:
 
11734
      {
 
11735
        return new adaptivepoisson_finite_element_5();
 
11736
        break;
 
11737
      }
 
11738
    case 4:
 
11739
      {
 
11740
        return new adaptivepoisson_finite_element_4();
 
11741
        break;
 
11742
      }
 
11743
    case 5:
 
11744
      {
 
11745
        return new adaptivepoisson_finite_element_2();
 
11746
        break;
 
11747
      }
 
11748
    }
 
11749
    
 
11750
    return 0;
 
11751
  }
 
11752
 
 
11753
  /// Create a new dofmap for argument function i
 
11754
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
11755
  {
 
11756
    switch (i)
 
11757
    {
 
11758
    case 0:
 
11759
      {
 
11760
        return new adaptivepoisson_dofmap_4();
 
11761
        break;
 
11762
      }
 
11763
    case 1:
 
11764
      {
 
11765
        return new adaptivepoisson_dofmap_5();
 
11766
        break;
 
11767
      }
 
11768
    case 2:
 
11769
      {
 
11770
        return new adaptivepoisson_dofmap_5();
 
11771
        break;
 
11772
      }
 
11773
    case 3:
 
11774
      {
 
11775
        return new adaptivepoisson_dofmap_5();
 
11776
        break;
 
11777
      }
 
11778
    case 4:
 
11779
      {
 
11780
        return new adaptivepoisson_dofmap_4();
 
11781
        break;
 
11782
      }
 
11783
    case 5:
 
11784
      {
 
11785
        return new adaptivepoisson_dofmap_2();
 
11786
        break;
 
11787
      }
 
11788
    }
 
11789
    
 
11790
    return 0;
 
11791
  }
 
11792
 
 
11793
  /// Create a new cell integral on sub domain i
 
11794
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
11795
  {
 
11796
    switch (i)
 
11797
    {
 
11798
    case 0:
 
11799
      {
 
11800
        return new adaptivepoisson_cell_integral_5_0();
 
11801
        break;
 
11802
      }
 
11803
    }
 
11804
    
 
11805
    return 0;
 
11806
  }
 
11807
 
 
11808
  /// Create a new exterior facet integral on sub domain i
 
11809
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
11810
  {
 
11811
    switch (i)
 
11812
    {
 
11813
    case 0:
 
11814
      {
 
11815
        return new adaptivepoisson_exterior_facet_integral_5_0();
 
11816
        break;
 
11817
      }
 
11818
    }
 
11819
    
 
11820
    return 0;
 
11821
  }
 
11822
 
 
11823
  /// Create a new interior facet integral on sub domain i
 
11824
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
11825
  {
 
11826
    return 0;
 
11827
  }
 
11828
 
 
11829
};
 
11830
 
 
11831
/// This class defines the interface for the assembly of the global
 
11832
/// tensor corresponding to a form with r + n arguments, that is, a
 
11833
/// mapping
 
11834
///
 
11835
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
11836
///
 
11837
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
11838
/// global tensor A is defined by
 
11839
///
 
11840
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
11841
///
 
11842
/// where each argument Vj represents the application to the
 
11843
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
11844
/// fixed functions (coefficients).
 
11845
 
 
11846
class adaptivepoisson_form_6: public ufc::form
 
11847
{
 
11848
public:
 
11849
 
 
11850
  /// Constructor
 
11851
  adaptivepoisson_form_6() : ufc::form()
 
11852
  {
 
11853
    // Do nothing
 
11854
  }
 
11855
 
 
11856
  /// Destructor
 
11857
  virtual ~adaptivepoisson_form_6()
 
11858
  {
 
11859
    // Do nothing
 
11860
  }
 
11861
 
 
11862
  /// Return a string identifying the form
 
11863
  virtual const char* signature() const
 
11864
  {
 
11865
    return "Form([Integral(Sum(Product(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2), 3)), Product(IntValue(-1, (), (), {}), IndexSum(Product(Indexed(ComponentTensor(SpatialDerivative(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 2), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(1),), {Index(1): 2})), Indexed(ComponentTensor(SpatialDerivative(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2), 3), MultiIndex((Index(2),), {Index(2): 2})), MultiIndex((Index(2),), {Index(2): 2})), MultiIndex((Index(1),), {Index(1): 2}))), MultiIndex((Index(1),), {Index(1): 2})))), Measure('cell', 0, None)), Integral(Product(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 1), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2), 3)), Measure('exterior_facet', 0, None))])";
 
11866
  }
 
11867
 
 
11868
  /// Return the rank of the global tensor (r)
 
11869
  virtual unsigned int rank() const
 
11870
  {
 
11871
    return 0;
 
11872
  }
 
11873
 
 
11874
  /// Return the number of coefficients (n)
 
11875
  virtual unsigned int num_coefficients() const
 
11876
  {
 
11877
    return 4;
 
11878
  }
 
11879
 
 
11880
  /// Return the number of cell domains
 
11881
  virtual unsigned int num_cell_domains() const
 
11882
  {
 
11883
    return 1;
 
11884
  }
 
11885
 
 
11886
  /// Return the number of exterior facet domains
 
11887
  virtual unsigned int num_exterior_facet_domains() const
 
11888
  {
 
11889
    return 1;
 
11890
  }
 
11891
 
 
11892
  /// Return the number of interior facet domains
 
11893
  virtual unsigned int num_interior_facet_domains() const
 
11894
  {
 
11895
    return 0;
 
11896
  }
 
11897
 
 
11898
  /// Create a new finite element for argument function i
 
11899
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
11900
  {
 
11901
    switch (i)
 
11902
    {
 
11903
    case 0:
 
11904
      {
 
11905
        return new adaptivepoisson_finite_element_5();
 
11906
        break;
 
11907
      }
 
11908
    case 1:
 
11909
      {
 
11910
        return new adaptivepoisson_finite_element_5();
 
11911
        break;
 
11912
      }
 
11913
    case 2:
 
11914
      {
 
11915
        return new adaptivepoisson_finite_element_5();
 
11916
        break;
 
11917
      }
 
11918
    case 3:
 
11919
      {
 
11920
        return new adaptivepoisson_finite_element_1();
 
11921
        break;
 
11922
      }
 
11923
    }
 
11924
    
 
11925
    return 0;
 
11926
  }
 
11927
 
 
11928
  /// Create a new dofmap for argument function i
 
11929
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
11930
  {
 
11931
    switch (i)
 
11932
    {
 
11933
    case 0:
 
11934
      {
 
11935
        return new adaptivepoisson_dofmap_5();
 
11936
        break;
 
11937
      }
 
11938
    case 1:
 
11939
      {
 
11940
        return new adaptivepoisson_dofmap_5();
 
11941
        break;
 
11942
      }
 
11943
    case 2:
 
11944
      {
 
11945
        return new adaptivepoisson_dofmap_5();
 
11946
        break;
 
11947
      }
 
11948
    case 3:
 
11949
      {
 
11950
        return new adaptivepoisson_dofmap_1();
 
11951
        break;
 
11952
      }
 
11953
    }
 
11954
    
 
11955
    return 0;
 
11956
  }
 
11957
 
 
11958
  /// Create a new cell integral on sub domain i
 
11959
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
11960
  {
 
11961
    switch (i)
 
11962
    {
 
11963
    case 0:
 
11964
      {
 
11965
        return new adaptivepoisson_cell_integral_6_0();
 
11966
        break;
 
11967
      }
 
11968
    }
 
11969
    
 
11970
    return 0;
 
11971
  }
 
11972
 
 
11973
  /// Create a new exterior facet integral on sub domain i
 
11974
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
11975
  {
 
11976
    switch (i)
 
11977
    {
 
11978
    case 0:
 
11979
      {
 
11980
        return new adaptivepoisson_exterior_facet_integral_6_0();
 
11981
        break;
 
11982
      }
 
11983
    }
 
11984
    
 
11985
    return 0;
 
11986
  }
 
11987
 
 
11988
  /// Create a new interior facet integral on sub domain i
 
11989
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
11990
  {
 
11991
    return 0;
 
11992
  }
 
11993
 
 
11994
};
 
11995
 
 
11996
/// This class defines the interface for the assembly of the global
 
11997
/// tensor corresponding to a form with r + n arguments, that is, a
 
11998
/// mapping
 
11999
///
 
12000
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
12001
///
 
12002
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
12003
/// global tensor A is defined by
 
12004
///
 
12005
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
12006
///
 
12007
/// where each argument Vj represents the application to the
 
12008
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
12009
/// fixed functions (coefficients).
 
12010
 
 
12011
class adaptivepoisson_form_7: public ufc::form
 
12012
{
 
12013
public:
 
12014
 
 
12015
  /// Constructor
 
12016
  adaptivepoisson_form_7() : ufc::form()
 
12017
  {
 
12018
    // Do nothing
 
12019
  }
 
12020
 
 
12021
  /// Destructor
 
12022
  virtual ~adaptivepoisson_form_7()
 
12023
  {
 
12024
    // Do nothing
 
12025
  }
 
12026
 
 
12027
  /// Return a string identifying the form
 
12028
  virtual const char* signature() const
 
12029
  {
 
12030
    return "Form([Integral(Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0), 0), Product(Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 1), Sum(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2), 0), Product(IntValue(-1, (), (), {}), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 3))))), Measure('cell', 0, None)), Integral(Product(Product(FloatValue(0.5, (), (), {}), Sum(NegativeRestricted(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0), 0)), PositiveRestricted(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0), 0)))), Sum(Product(NegativeRestricted(Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 2)), NegativeRestricted(Sum(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2), 0), Product(IntValue(-1, (), (), {}), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 3))))), Product(PositiveRestricted(Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 2)), PositiveRestricted(Sum(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2), 0), Product(IntValue(-1, (), (), {}), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 3))))))), Measure('interior_facet', 0, None)), Integral(Product(Argument(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0), 0), Product(Coefficient(FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 1), 2), Sum(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 2), 0), Product(IntValue(-1, (), (), {}), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 3))))), Measure('exterior_facet', 0, None))])";
 
12031
  }
 
12032
 
 
12033
  /// Return the rank of the global tensor (r)
 
12034
  virtual unsigned int rank() const
 
12035
  {
 
12036
    return 1;
 
12037
  }
 
12038
 
 
12039
  /// Return the number of coefficients (n)
 
12040
  virtual unsigned int num_coefficients() const
 
12041
  {
 
12042
    return 4;
 
12043
  }
 
12044
 
 
12045
  /// Return the number of cell domains
 
12046
  virtual unsigned int num_cell_domains() const
 
12047
  {
 
12048
    return 1;
 
12049
  }
 
12050
 
 
12051
  /// Return the number of exterior facet domains
 
12052
  virtual unsigned int num_exterior_facet_domains() const
 
12053
  {
 
12054
    return 1;
 
12055
  }
 
12056
 
 
12057
  /// Return the number of interior facet domains
 
12058
  virtual unsigned int num_interior_facet_domains() const
 
12059
  {
 
12060
    return 1;
 
12061
  }
 
12062
 
 
12063
  /// Create a new finite element for argument function i
 
12064
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
12065
  {
 
12066
    switch (i)
 
12067
    {
 
12068
    case 0:
 
12069
      {
 
12070
        return new adaptivepoisson_finite_element_0();
 
12071
        break;
 
12072
      }
 
12073
    case 1:
 
12074
      {
 
12075
        return new adaptivepoisson_finite_element_1();
 
12076
        break;
 
12077
      }
 
12078
    case 2:
 
12079
      {
 
12080
        return new adaptivepoisson_finite_element_4();
 
12081
        break;
 
12082
      }
 
12083
    case 3:
 
12084
      {
 
12085
        return new adaptivepoisson_finite_element_4();
 
12086
        break;
 
12087
      }
 
12088
    case 4:
 
12089
      {
 
12090
        return new adaptivepoisson_finite_element_5();
 
12091
        break;
 
12092
      }
 
12093
    }
 
12094
    
 
12095
    return 0;
 
12096
  }
 
12097
 
 
12098
  /// Create a new dofmap for argument function i
 
12099
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
12100
  {
 
12101
    switch (i)
 
12102
    {
 
12103
    case 0:
 
12104
      {
 
12105
        return new adaptivepoisson_dofmap_0();
 
12106
        break;
 
12107
      }
 
12108
    case 1:
 
12109
      {
 
12110
        return new adaptivepoisson_dofmap_1();
 
12111
        break;
 
12112
      }
 
12113
    case 2:
 
12114
      {
 
12115
        return new adaptivepoisson_dofmap_4();
 
12116
        break;
 
12117
      }
 
12118
    case 3:
 
12119
      {
 
12120
        return new adaptivepoisson_dofmap_4();
 
12121
        break;
 
12122
      }
 
12123
    case 4:
 
12124
      {
 
12125
        return new adaptivepoisson_dofmap_5();
 
12126
        break;
 
12127
      }
 
12128
    }
 
12129
    
 
12130
    return 0;
 
12131
  }
 
12132
 
 
12133
  /// Create a new cell integral on sub domain i
 
12134
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
12135
  {
 
12136
    switch (i)
 
12137
    {
 
12138
    case 0:
 
12139
      {
 
12140
        return new adaptivepoisson_cell_integral_7_0();
 
12141
        break;
 
12142
      }
 
12143
    }
 
12144
    
 
12145
    return 0;
 
12146
  }
 
12147
 
 
12148
  /// Create a new exterior facet integral on sub domain i
 
12149
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
12150
  {
 
12151
    switch (i)
 
12152
    {
 
12153
    case 0:
 
12154
      {
 
12155
        return new adaptivepoisson_exterior_facet_integral_7_0();
 
12156
        break;
 
12157
      }
 
12158
    }
 
12159
    
 
12160
    return 0;
 
12161
  }
 
12162
 
 
12163
  /// Create a new interior facet integral on sub domain i
 
12164
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
12165
  {
 
12166
    switch (i)
 
12167
    {
 
12168
    case 0:
 
12169
      {
 
12170
        return new adaptivepoisson_interior_facet_integral_7_0();
 
12171
        break;
 
12172
      }
 
12173
    }
 
12174
    
 
12175
    return 0;
 
12176
  }
 
12177
 
 
12178
};
 
12179
 
 
12180
/// This class defines the interface for the assembly of the global
 
12181
/// tensor corresponding to a form with r + n arguments, that is, a
 
12182
/// mapping
 
12183
///
 
12184
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
12185
///
 
12186
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
12187
/// global tensor A is defined by
 
12188
///
 
12189
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
12190
///
 
12191
/// where each argument Vj represents the application to the
 
12192
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
12193
/// fixed functions (coefficients).
 
12194
 
 
12195
class adaptivepoisson_form_8: public ufc::form
 
12196
{
 
12197
public:
 
12198
 
 
12199
  /// Constructor
 
12200
  adaptivepoisson_form_8() : ufc::form()
 
12201
  {
 
12202
    // Do nothing
 
12203
  }
 
12204
 
 
12205
  /// Destructor
 
12206
  virtual ~adaptivepoisson_form_8()
 
12207
  {
 
12208
    // Do nothing
 
12209
  }
 
12210
 
 
12211
  /// Return a string identifying the form
 
12212
  virtual const char* signature() const
 
12213
  {
 
12214
    return "Form([Integral(IndexSum(Product(Indexed(ComponentTensor(SpatialDerivative(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(1),), {Index(1): 2})), Indexed(ComponentTensor(SpatialDerivative(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 1), MultiIndex((Index(2),), {Index(2): 2})), MultiIndex((Index(2),), {Index(2): 2})), MultiIndex((Index(1),), {Index(1): 2}))), MultiIndex((Index(1),), {Index(1): 2})), Measure('cell', 0, None))])";
 
12215
  }
 
12216
 
 
12217
  /// Return the rank of the global tensor (r)
 
12218
  virtual unsigned int rank() const
 
12219
  {
 
12220
    return 2;
 
12221
  }
 
12222
 
 
12223
  /// Return the number of coefficients (n)
 
12224
  virtual unsigned int num_coefficients() const
 
12225
  {
 
12226
    return 0;
 
12227
  }
 
12228
 
 
12229
  /// Return the number of cell domains
 
12230
  virtual unsigned int num_cell_domains() const
 
12231
  {
 
12232
    return 1;
 
12233
  }
 
12234
 
 
12235
  /// Return the number of exterior facet domains
 
12236
  virtual unsigned int num_exterior_facet_domains() const
 
12237
  {
 
12238
    return 0;
 
12239
  }
 
12240
 
 
12241
  /// Return the number of interior facet domains
 
12242
  virtual unsigned int num_interior_facet_domains() const
 
12243
  {
 
12244
    return 0;
 
12245
  }
 
12246
 
 
12247
  /// Create a new finite element for argument function i
 
12248
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
12249
  {
 
12250
    switch (i)
 
12251
    {
 
12252
    case 0:
 
12253
      {
 
12254
        return new adaptivepoisson_finite_element_5();
 
12255
        break;
 
12256
      }
 
12257
    case 1:
 
12258
      {
 
12259
        return new adaptivepoisson_finite_element_5();
 
12260
        break;
 
12261
      }
 
12262
    }
 
12263
    
 
12264
    return 0;
 
12265
  }
 
12266
 
 
12267
  /// Create a new dofmap for argument function i
 
12268
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
12269
  {
 
12270
    switch (i)
 
12271
    {
 
12272
    case 0:
 
12273
      {
 
12274
        return new adaptivepoisson_dofmap_5();
 
12275
        break;
 
12276
      }
 
12277
    case 1:
 
12278
      {
 
12279
        return new adaptivepoisson_dofmap_5();
 
12280
        break;
 
12281
      }
 
12282
    }
 
12283
    
 
12284
    return 0;
 
12285
  }
 
12286
 
 
12287
  /// Create a new cell integral on sub domain i
 
12288
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
12289
  {
 
12290
    switch (i)
 
12291
    {
 
12292
    case 0:
 
12293
      {
 
12294
        return new adaptivepoisson_cell_integral_8_0();
 
12295
        break;
 
12296
      }
 
12297
    }
 
12298
    
 
12299
    return 0;
 
12300
  }
 
12301
 
 
12302
  /// Create a new exterior facet integral on sub domain i
 
12303
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
12304
  {
 
12305
    return 0;
 
12306
  }
 
12307
 
 
12308
  /// Create a new interior facet integral on sub domain i
 
12309
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
12310
  {
 
12311
    return 0;
 
12312
  }
 
12313
 
 
12314
};
 
12315
 
 
12316
/// This class defines the interface for the assembly of the global
 
12317
/// tensor corresponding to a form with r + n arguments, that is, a
 
12318
/// mapping
 
12319
///
 
12320
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
12321
///
 
12322
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
12323
/// global tensor A is defined by
 
12324
///
 
12325
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
12326
///
 
12327
/// where each argument Vj represents the application to the
 
12328
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
12329
/// fixed functions (coefficients).
 
12330
 
 
12331
class adaptivepoisson_form_9: public ufc::form
 
12332
{
 
12333
public:
 
12334
 
 
12335
  /// Constructor
 
12336
  adaptivepoisson_form_9() : ufc::form()
 
12337
  {
 
12338
    // Do nothing
 
12339
  }
 
12340
 
 
12341
  /// Destructor
 
12342
  virtual ~adaptivepoisson_form_9()
 
12343
  {
 
12344
    // Do nothing
 
12345
  }
 
12346
 
 
12347
  /// Return a string identifying the form
 
12348
  virtual const char* signature() const
 
12349
  {
 
12350
    return "Form([Integral(Product(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0)), Measure('cell', 0, None)), Integral(Product(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 1)), Measure('exterior_facet', 0, None))])";
 
12351
  }
 
12352
 
 
12353
  /// Return the rank of the global tensor (r)
 
12354
  virtual unsigned int rank() const
 
12355
  {
 
12356
    return 1;
 
12357
  }
 
12358
 
 
12359
  /// Return the number of coefficients (n)
 
12360
  virtual unsigned int num_coefficients() const
 
12361
  {
 
12362
    return 2;
 
12363
  }
 
12364
 
 
12365
  /// Return the number of cell domains
 
12366
  virtual unsigned int num_cell_domains() const
 
12367
  {
 
12368
    return 1;
 
12369
  }
 
12370
 
 
12371
  /// Return the number of exterior facet domains
 
12372
  virtual unsigned int num_exterior_facet_domains() const
 
12373
  {
 
12374
    return 1;
 
12375
  }
 
12376
 
 
12377
  /// Return the number of interior facet domains
 
12378
  virtual unsigned int num_interior_facet_domains() const
 
12379
  {
 
12380
    return 0;
 
12381
  }
 
12382
 
 
12383
  /// Create a new finite element for argument function i
 
12384
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
12385
  {
 
12386
    switch (i)
 
12387
    {
 
12388
    case 0:
 
12389
      {
 
12390
        return new adaptivepoisson_finite_element_5();
 
12391
        break;
 
12392
      }
 
12393
    case 1:
 
12394
      {
 
12395
        return new adaptivepoisson_finite_element_5();
 
12396
        break;
 
12397
      }
 
12398
    case 2:
 
12399
      {
 
12400
        return new adaptivepoisson_finite_element_5();
 
12401
        break;
 
12402
      }
 
12403
    }
 
12404
    
 
12405
    return 0;
 
12406
  }
 
12407
 
 
12408
  /// Create a new dofmap for argument function i
 
12409
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
12410
  {
 
12411
    switch (i)
 
12412
    {
 
12413
    case 0:
 
12414
      {
 
12415
        return new adaptivepoisson_dofmap_5();
 
12416
        break;
 
12417
      }
 
12418
    case 1:
 
12419
      {
 
12420
        return new adaptivepoisson_dofmap_5();
 
12421
        break;
 
12422
      }
 
12423
    case 2:
 
12424
      {
 
12425
        return new adaptivepoisson_dofmap_5();
 
12426
        break;
 
12427
      }
 
12428
    }
 
12429
    
 
12430
    return 0;
 
12431
  }
 
12432
 
 
12433
  /// Create a new cell integral on sub domain i
 
12434
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
12435
  {
 
12436
    switch (i)
 
12437
    {
 
12438
    case 0:
 
12439
      {
 
12440
        return new adaptivepoisson_cell_integral_9_0();
 
12441
        break;
 
12442
      }
 
12443
    }
 
12444
    
 
12445
    return 0;
 
12446
  }
 
12447
 
 
12448
  /// Create a new exterior facet integral on sub domain i
 
12449
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
12450
  {
 
12451
    switch (i)
 
12452
    {
 
12453
    case 0:
 
12454
      {
 
12455
        return new adaptivepoisson_exterior_facet_integral_9_0();
 
12456
        break;
 
12457
      }
 
12458
    }
 
12459
    
 
12460
    return 0;
 
12461
  }
 
12462
 
 
12463
  /// Create a new interior facet integral on sub domain i
 
12464
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
12465
  {
 
12466
    return 0;
 
12467
  }
 
12468
 
 
12469
};
 
12470
 
 
12471
/// This class defines the interface for the assembly of the global
 
12472
/// tensor corresponding to a form with r + n arguments, that is, a
 
12473
/// mapping
 
12474
///
 
12475
///     a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
 
12476
///
 
12477
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
 
12478
/// global tensor A is defined by
 
12479
///
 
12480
///     A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
 
12481
///
 
12482
/// where each argument Vj represents the application to the
 
12483
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
 
12484
/// fixed functions (coefficients).
 
12485
 
 
12486
class adaptivepoisson_form_10: public ufc::form
 
12487
{
 
12488
public:
 
12489
 
 
12490
  /// Constructor
 
12491
  adaptivepoisson_form_10() : ufc::form()
 
12492
  {
 
12493
    // Do nothing
 
12494
  }
 
12495
 
 
12496
  /// Destructor
 
12497
  virtual ~adaptivepoisson_form_10()
 
12498
  {
 
12499
    // Do nothing
 
12500
  }
 
12501
 
 
12502
  /// Return a string identifying the form
 
12503
  virtual const char* signature() const
 
12504
  {
 
12505
    return "Form([Integral(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Measure('cell', 0, None))])";
 
12506
  }
 
12507
 
 
12508
  /// Return the rank of the global tensor (r)
 
12509
  virtual unsigned int rank() const
 
12510
  {
 
12511
    return 0;
 
12512
  }
 
12513
 
 
12514
  /// Return the number of coefficients (n)
 
12515
  virtual unsigned int num_coefficients() const
 
12516
  {
 
12517
    return 1;
 
12518
  }
 
12519
 
 
12520
  /// Return the number of cell domains
 
12521
  virtual unsigned int num_cell_domains() const
 
12522
  {
 
12523
    return 1;
 
12524
  }
 
12525
 
 
12526
  /// Return the number of exterior facet domains
 
12527
  virtual unsigned int num_exterior_facet_domains() const
 
12528
  {
 
12529
    return 0;
 
12530
  }
 
12531
 
 
12532
  /// Return the number of interior facet domains
 
12533
  virtual unsigned int num_interior_facet_domains() const
 
12534
  {
 
12535
    return 0;
 
12536
  }
 
12537
 
 
12538
  /// Create a new finite element for argument function i
 
12539
  virtual ufc::finite_element* create_finite_element(unsigned int i) const
 
12540
  {
 
12541
    switch (i)
 
12542
    {
 
12543
    case 0:
 
12544
      {
 
12545
        return new adaptivepoisson_finite_element_5();
 
12546
        break;
 
12547
      }
 
12548
    }
 
12549
    
 
12550
    return 0;
 
12551
  }
 
12552
 
 
12553
  /// Create a new dofmap for argument function i
 
12554
  virtual ufc::dofmap* create_dofmap(unsigned int i) const
 
12555
  {
 
12556
    switch (i)
 
12557
    {
 
12558
    case 0:
 
12559
      {
 
12560
        return new adaptivepoisson_dofmap_5();
 
12561
        break;
 
12562
      }
 
12563
    }
 
12564
    
 
12565
    return 0;
 
12566
  }
 
12567
 
 
12568
  /// Create a new cell integral on sub domain i
 
12569
  virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
 
12570
  {
 
12571
    switch (i)
 
12572
    {
 
12573
    case 0:
 
12574
      {
 
12575
        return new adaptivepoisson_cell_integral_10_0();
 
12576
        break;
 
12577
      }
 
12578
    }
 
12579
    
 
12580
    return 0;
 
12581
  }
 
12582
 
 
12583
  /// Create a new exterior facet integral on sub domain i
 
12584
  virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
 
12585
  {
 
12586
    return 0;
 
12587
  }
 
12588
 
 
12589
  /// Create a new interior facet integral on sub domain i
 
12590
  virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
 
12591
  {
 
12592
    return 0;
 
12593
  }
 
12594
 
 
12595
};
 
12596
 
 
12597
// DOLFIN wrappers
 
12598
 
 
12599
// Standard library includes
 
12600
#include <string>
 
12601
 
 
12602
// DOLFIN includes
 
12603
#include <dolfin/common/NoDeleter.h>
 
12604
#include <dolfin/fem/FiniteElement.h>
 
12605
#include <dolfin/fem/DofMap.h>
 
12606
#include <dolfin/fem/Form.h>
 
12607
#include <dolfin/function/FunctionSpace.h>
 
12608
#include <dolfin/function/GenericFunction.h>
 
12609
#include <dolfin/function/CoefficientAssigner.h>
 
12610
#include <dolfin/adaptivity/ErrorControl.h>
 
12611
#include <dolfin/adaptivity/GoalFunctional.h>
 
12612
 
 
12613
namespace AdaptivePoisson
 
12614
{
 
12615
 
 
12616
class CoefficientSpace___cell_bubble: public dolfin::FunctionSpace
 
12617
{
 
12618
public:
 
12619
 
 
12620
  CoefficientSpace___cell_bubble(const dolfin::Mesh& mesh):
 
12621
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12622
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_3()))),
 
12623
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_3()), mesh)))
 
12624
  {
 
12625
    // Do nothing
 
12626
  }
 
12627
 
 
12628
  CoefficientSpace___cell_bubble(dolfin::Mesh& mesh):
 
12629
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12630
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_3()))),
 
12631
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_3()), mesh)))
 
12632
  {
 
12633
    // Do nothing
 
12634
  }
 
12635
 
 
12636
  CoefficientSpace___cell_bubble(boost::shared_ptr<dolfin::Mesh> mesh):
 
12637
    dolfin::FunctionSpace(mesh,
 
12638
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_3()))),
 
12639
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_3()), *mesh)))
 
12640
  {
 
12641
      // Do nothing
 
12642
  }
 
12643
 
 
12644
  CoefficientSpace___cell_bubble(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12645
    dolfin::FunctionSpace(mesh,
 
12646
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_3()))),
 
12647
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_3()), *mesh)))
 
12648
  {
 
12649
      // Do nothing
 
12650
  }
 
12651
 
 
12652
  ~CoefficientSpace___cell_bubble()
 
12653
  {
 
12654
  }
 
12655
 
 
12656
};
 
12657
 
 
12658
class CoefficientSpace___cell_cone: public dolfin::FunctionSpace
 
12659
{
 
12660
public:
 
12661
 
 
12662
  CoefficientSpace___cell_cone(const dolfin::Mesh& mesh):
 
12663
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12664
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_2()))),
 
12665
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_2()), mesh)))
 
12666
  {
 
12667
    // Do nothing
 
12668
  }
 
12669
 
 
12670
  CoefficientSpace___cell_cone(dolfin::Mesh& mesh):
 
12671
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12672
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_2()))),
 
12673
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_2()), mesh)))
 
12674
  {
 
12675
    // Do nothing
 
12676
  }
 
12677
 
 
12678
  CoefficientSpace___cell_cone(boost::shared_ptr<dolfin::Mesh> mesh):
 
12679
    dolfin::FunctionSpace(mesh,
 
12680
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_2()))),
 
12681
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_2()), *mesh)))
 
12682
  {
 
12683
      // Do nothing
 
12684
  }
 
12685
 
 
12686
  CoefficientSpace___cell_cone(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12687
    dolfin::FunctionSpace(mesh,
 
12688
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_2()))),
 
12689
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_2()), *mesh)))
 
12690
  {
 
12691
      // Do nothing
 
12692
  }
 
12693
 
 
12694
  ~CoefficientSpace___cell_cone()
 
12695
  {
 
12696
  }
 
12697
 
 
12698
};
 
12699
 
 
12700
class CoefficientSpace___cell_residual: public dolfin::FunctionSpace
 
12701
{
 
12702
public:
 
12703
 
 
12704
  CoefficientSpace___cell_residual(const dolfin::Mesh& mesh):
 
12705
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12706
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
12707
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
12708
  {
 
12709
    // Do nothing
 
12710
  }
 
12711
 
 
12712
  CoefficientSpace___cell_residual(dolfin::Mesh& mesh):
 
12713
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12714
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
12715
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
12716
  {
 
12717
    // Do nothing
 
12718
  }
 
12719
 
 
12720
  CoefficientSpace___cell_residual(boost::shared_ptr<dolfin::Mesh> mesh):
 
12721
    dolfin::FunctionSpace(mesh,
 
12722
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
12723
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
12724
  {
 
12725
      // Do nothing
 
12726
  }
 
12727
 
 
12728
  CoefficientSpace___cell_residual(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12729
    dolfin::FunctionSpace(mesh,
 
12730
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
12731
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
12732
  {
 
12733
      // Do nothing
 
12734
  }
 
12735
 
 
12736
  ~CoefficientSpace___cell_residual()
 
12737
  {
 
12738
  }
 
12739
 
 
12740
};
 
12741
 
 
12742
class CoefficientSpace___discrete_dual_solution: public dolfin::FunctionSpace
 
12743
{
 
12744
public:
 
12745
 
 
12746
  CoefficientSpace___discrete_dual_solution(const dolfin::Mesh& mesh):
 
12747
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12748
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12749
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
12750
  {
 
12751
    // Do nothing
 
12752
  }
 
12753
 
 
12754
  CoefficientSpace___discrete_dual_solution(dolfin::Mesh& mesh):
 
12755
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12756
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12757
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
12758
  {
 
12759
    // Do nothing
 
12760
  }
 
12761
 
 
12762
  CoefficientSpace___discrete_dual_solution(boost::shared_ptr<dolfin::Mesh> mesh):
 
12763
    dolfin::FunctionSpace(mesh,
 
12764
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12765
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
12766
  {
 
12767
      // Do nothing
 
12768
  }
 
12769
 
 
12770
  CoefficientSpace___discrete_dual_solution(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12771
    dolfin::FunctionSpace(mesh,
 
12772
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12773
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
12774
  {
 
12775
      // Do nothing
 
12776
  }
 
12777
 
 
12778
  ~CoefficientSpace___discrete_dual_solution()
 
12779
  {
 
12780
  }
 
12781
 
 
12782
};
 
12783
 
 
12784
class CoefficientSpace___discrete_primal_solution: public dolfin::FunctionSpace
 
12785
{
 
12786
public:
 
12787
 
 
12788
  CoefficientSpace___discrete_primal_solution(const dolfin::Mesh& mesh):
 
12789
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12790
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12791
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
12792
  {
 
12793
    // Do nothing
 
12794
  }
 
12795
 
 
12796
  CoefficientSpace___discrete_primal_solution(dolfin::Mesh& mesh):
 
12797
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12798
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12799
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
12800
  {
 
12801
    // Do nothing
 
12802
  }
 
12803
 
 
12804
  CoefficientSpace___discrete_primal_solution(boost::shared_ptr<dolfin::Mesh> mesh):
 
12805
    dolfin::FunctionSpace(mesh,
 
12806
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12807
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
12808
  {
 
12809
      // Do nothing
 
12810
  }
 
12811
 
 
12812
  CoefficientSpace___discrete_primal_solution(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12813
    dolfin::FunctionSpace(mesh,
 
12814
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12815
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
12816
  {
 
12817
      // Do nothing
 
12818
  }
 
12819
 
 
12820
  ~CoefficientSpace___discrete_primal_solution()
 
12821
  {
 
12822
  }
 
12823
 
 
12824
};
 
12825
 
 
12826
class CoefficientSpace___facet_residual: public dolfin::FunctionSpace
 
12827
{
 
12828
public:
 
12829
 
 
12830
  CoefficientSpace___facet_residual(const dolfin::Mesh& mesh):
 
12831
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12832
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
12833
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
12834
  {
 
12835
    // Do nothing
 
12836
  }
 
12837
 
 
12838
  CoefficientSpace___facet_residual(dolfin::Mesh& mesh):
 
12839
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12840
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
12841
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
12842
  {
 
12843
    // Do nothing
 
12844
  }
 
12845
 
 
12846
  CoefficientSpace___facet_residual(boost::shared_ptr<dolfin::Mesh> mesh):
 
12847
    dolfin::FunctionSpace(mesh,
 
12848
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
12849
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
12850
  {
 
12851
      // Do nothing
 
12852
  }
 
12853
 
 
12854
  CoefficientSpace___facet_residual(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12855
    dolfin::FunctionSpace(mesh,
 
12856
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
12857
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
12858
  {
 
12859
      // Do nothing
 
12860
  }
 
12861
 
 
12862
  ~CoefficientSpace___facet_residual()
 
12863
  {
 
12864
  }
 
12865
 
 
12866
};
 
12867
 
 
12868
class CoefficientSpace___improved_dual: public dolfin::FunctionSpace
 
12869
{
 
12870
public:
 
12871
 
 
12872
  CoefficientSpace___improved_dual(const dolfin::Mesh& mesh):
 
12873
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12874
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_1()))),
 
12875
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_1()), mesh)))
 
12876
  {
 
12877
    // Do nothing
 
12878
  }
 
12879
 
 
12880
  CoefficientSpace___improved_dual(dolfin::Mesh& mesh):
 
12881
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12882
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_1()))),
 
12883
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_1()), mesh)))
 
12884
  {
 
12885
    // Do nothing
 
12886
  }
 
12887
 
 
12888
  CoefficientSpace___improved_dual(boost::shared_ptr<dolfin::Mesh> mesh):
 
12889
    dolfin::FunctionSpace(mesh,
 
12890
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_1()))),
 
12891
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_1()), *mesh)))
 
12892
  {
 
12893
      // Do nothing
 
12894
  }
 
12895
 
 
12896
  CoefficientSpace___improved_dual(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12897
    dolfin::FunctionSpace(mesh,
 
12898
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_1()))),
 
12899
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_1()), *mesh)))
 
12900
  {
 
12901
      // Do nothing
 
12902
  }
 
12903
 
 
12904
  ~CoefficientSpace___improved_dual()
 
12905
  {
 
12906
  }
 
12907
 
 
12908
};
 
12909
 
 
12910
class CoefficientSpace_f: public dolfin::FunctionSpace
 
12911
{
 
12912
public:
 
12913
 
 
12914
  CoefficientSpace_f(const dolfin::Mesh& mesh):
 
12915
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12916
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12917
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
12918
  {
 
12919
    // Do nothing
 
12920
  }
 
12921
 
 
12922
  CoefficientSpace_f(dolfin::Mesh& mesh):
 
12923
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12924
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12925
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
12926
  {
 
12927
    // Do nothing
 
12928
  }
 
12929
 
 
12930
  CoefficientSpace_f(boost::shared_ptr<dolfin::Mesh> mesh):
 
12931
    dolfin::FunctionSpace(mesh,
 
12932
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12933
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
12934
  {
 
12935
      // Do nothing
 
12936
  }
 
12937
 
 
12938
  CoefficientSpace_f(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12939
    dolfin::FunctionSpace(mesh,
 
12940
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12941
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
12942
  {
 
12943
      // Do nothing
 
12944
  }
 
12945
 
 
12946
  ~CoefficientSpace_f()
 
12947
  {
 
12948
  }
 
12949
 
 
12950
};
 
12951
 
 
12952
class CoefficientSpace_g: public dolfin::FunctionSpace
 
12953
{
 
12954
public:
 
12955
 
 
12956
  CoefficientSpace_g(const dolfin::Mesh& mesh):
 
12957
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12958
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12959
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
12960
  {
 
12961
    // Do nothing
 
12962
  }
 
12963
 
 
12964
  CoefficientSpace_g(dolfin::Mesh& mesh):
 
12965
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
12966
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12967
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
12968
  {
 
12969
    // Do nothing
 
12970
  }
 
12971
 
 
12972
  CoefficientSpace_g(boost::shared_ptr<dolfin::Mesh> mesh):
 
12973
    dolfin::FunctionSpace(mesh,
 
12974
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12975
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
12976
  {
 
12977
      // Do nothing
 
12978
  }
 
12979
 
 
12980
  CoefficientSpace_g(boost::shared_ptr<const dolfin::Mesh> mesh):
 
12981
    dolfin::FunctionSpace(mesh,
 
12982
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
12983
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
12984
  {
 
12985
      // Do nothing
 
12986
  }
 
12987
 
 
12988
  ~CoefficientSpace_g()
 
12989
  {
 
12990
  }
 
12991
 
 
12992
};
 
12993
 
 
12994
class Form_0_FunctionSpace_0: public dolfin::FunctionSpace
 
12995
{
 
12996
public:
 
12997
 
 
12998
  Form_0_FunctionSpace_0(const dolfin::Mesh& mesh):
 
12999
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13000
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13001
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
13002
  {
 
13003
    // Do nothing
 
13004
  }
 
13005
 
 
13006
  Form_0_FunctionSpace_0(dolfin::Mesh& mesh):
 
13007
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13008
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13009
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
13010
  {
 
13011
    // Do nothing
 
13012
  }
 
13013
 
 
13014
  Form_0_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
13015
    dolfin::FunctionSpace(mesh,
 
13016
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13017
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
13018
  {
 
13019
      // Do nothing
 
13020
  }
 
13021
 
 
13022
  Form_0_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13023
    dolfin::FunctionSpace(mesh,
 
13024
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13025
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
13026
  {
 
13027
      // Do nothing
 
13028
  }
 
13029
 
 
13030
  ~Form_0_FunctionSpace_0()
 
13031
  {
 
13032
  }
 
13033
 
 
13034
};
 
13035
 
 
13036
class Form_0_FunctionSpace_1: public dolfin::FunctionSpace
 
13037
{
 
13038
public:
 
13039
 
 
13040
  Form_0_FunctionSpace_1(const dolfin::Mesh& mesh):
 
13041
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13042
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13043
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
13044
  {
 
13045
    // Do nothing
 
13046
  }
 
13047
 
 
13048
  Form_0_FunctionSpace_1(dolfin::Mesh& mesh):
 
13049
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13050
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13051
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
13052
  {
 
13053
    // Do nothing
 
13054
  }
 
13055
 
 
13056
  Form_0_FunctionSpace_1(boost::shared_ptr<dolfin::Mesh> mesh):
 
13057
    dolfin::FunctionSpace(mesh,
 
13058
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13059
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
13060
  {
 
13061
      // Do nothing
 
13062
  }
 
13063
 
 
13064
  Form_0_FunctionSpace_1(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13065
    dolfin::FunctionSpace(mesh,
 
13066
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13067
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
13068
  {
 
13069
      // Do nothing
 
13070
  }
 
13071
 
 
13072
  ~Form_0_FunctionSpace_1()
 
13073
  {
 
13074
  }
 
13075
 
 
13076
};
 
13077
 
 
13078
class Form_0: public dolfin::Form
 
13079
{
 
13080
public:
 
13081
 
 
13082
  // Constructor
 
13083
  Form_0(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1):
 
13084
    dolfin::Form(2, 0)
 
13085
  {
 
13086
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13087
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
13088
 
 
13089
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_0());
 
13090
  }
 
13091
 
 
13092
  // Constructor
 
13093
  Form_0(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1):
 
13094
    dolfin::Form(2, 0)
 
13095
  {
 
13096
    _function_spaces[0] = V0;
 
13097
    _function_spaces[1] = V1;
 
13098
 
 
13099
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_0());
 
13100
  }
 
13101
 
 
13102
  // Destructor
 
13103
  ~Form_0()
 
13104
  {}
 
13105
 
 
13106
  /// Return the number of the coefficient with this name
 
13107
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
13108
  {
 
13109
 
 
13110
    dolfin::error("No coefficients.");
 
13111
    return 0;
 
13112
  }
 
13113
 
 
13114
  /// Return the name of the coefficient with this number
 
13115
  virtual std::string coefficient_name(dolfin::uint i) const
 
13116
  {
 
13117
 
 
13118
    dolfin::error("No coefficients.");
 
13119
    return "unnamed";
 
13120
  }
 
13121
 
 
13122
  // Typedefs
 
13123
  typedef Form_0_FunctionSpace_0 TestSpace;
 
13124
  typedef Form_0_FunctionSpace_1 TrialSpace;
 
13125
 
 
13126
  // Coefficients
 
13127
};
 
13128
 
 
13129
class Form_1_FunctionSpace_0: public dolfin::FunctionSpace
 
13130
{
 
13131
public:
 
13132
 
 
13133
  Form_1_FunctionSpace_0(const dolfin::Mesh& mesh):
 
13134
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13135
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13136
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
13137
  {
 
13138
    // Do nothing
 
13139
  }
 
13140
 
 
13141
  Form_1_FunctionSpace_0(dolfin::Mesh& mesh):
 
13142
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13143
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13144
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
13145
  {
 
13146
    // Do nothing
 
13147
  }
 
13148
 
 
13149
  Form_1_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
13150
    dolfin::FunctionSpace(mesh,
 
13151
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13152
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
13153
  {
 
13154
      // Do nothing
 
13155
  }
 
13156
 
 
13157
  Form_1_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13158
    dolfin::FunctionSpace(mesh,
 
13159
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
13160
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
13161
  {
 
13162
      // Do nothing
 
13163
  }
 
13164
 
 
13165
  ~Form_1_FunctionSpace_0()
 
13166
  {
 
13167
  }
 
13168
 
 
13169
};
 
13170
 
 
13171
class Form_1: public dolfin::Form
 
13172
{
 
13173
public:
 
13174
 
 
13175
  // Constructor
 
13176
  Form_1(const dolfin::FunctionSpace& V0):
 
13177
    dolfin::Form(1, 0)
 
13178
  {
 
13179
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13180
 
 
13181
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_1());
 
13182
  }
 
13183
 
 
13184
  // Constructor
 
13185
  Form_1(boost::shared_ptr<const dolfin::FunctionSpace> V0):
 
13186
    dolfin::Form(1, 0)
 
13187
  {
 
13188
    _function_spaces[0] = V0;
 
13189
 
 
13190
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_1());
 
13191
  }
 
13192
 
 
13193
  // Destructor
 
13194
  ~Form_1()
 
13195
  {}
 
13196
 
 
13197
  /// Return the number of the coefficient with this name
 
13198
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
13199
  {
 
13200
 
 
13201
    dolfin::error("No coefficients.");
 
13202
    return 0;
 
13203
  }
 
13204
 
 
13205
  /// Return the name of the coefficient with this number
 
13206
  virtual std::string coefficient_name(dolfin::uint i) const
 
13207
  {
 
13208
 
 
13209
    dolfin::error("No coefficients.");
 
13210
    return "unnamed";
 
13211
  }
 
13212
 
 
13213
  // Typedefs
 
13214
  typedef Form_1_FunctionSpace_0 TestSpace;
 
13215
 
 
13216
  // Coefficients
 
13217
};
 
13218
 
 
13219
class Form_2_FunctionSpace_0: public dolfin::FunctionSpace
 
13220
{
 
13221
public:
 
13222
 
 
13223
  Form_2_FunctionSpace_0(const dolfin::Mesh& mesh):
 
13224
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13225
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13226
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13227
  {
 
13228
    // Do nothing
 
13229
  }
 
13230
 
 
13231
  Form_2_FunctionSpace_0(dolfin::Mesh& mesh):
 
13232
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13233
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13234
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13235
  {
 
13236
    // Do nothing
 
13237
  }
 
13238
 
 
13239
  Form_2_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
13240
    dolfin::FunctionSpace(mesh,
 
13241
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13242
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13243
  {
 
13244
      // Do nothing
 
13245
  }
 
13246
 
 
13247
  Form_2_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13248
    dolfin::FunctionSpace(mesh,
 
13249
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13250
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13251
  {
 
13252
      // Do nothing
 
13253
  }
 
13254
 
 
13255
  ~Form_2_FunctionSpace_0()
 
13256
  {
 
13257
  }
 
13258
 
 
13259
};
 
13260
 
 
13261
class Form_2_FunctionSpace_1: public dolfin::FunctionSpace
 
13262
{
 
13263
public:
 
13264
 
 
13265
  Form_2_FunctionSpace_1(const dolfin::Mesh& mesh):
 
13266
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13267
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13268
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13269
  {
 
13270
    // Do nothing
 
13271
  }
 
13272
 
 
13273
  Form_2_FunctionSpace_1(dolfin::Mesh& mesh):
 
13274
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13275
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13276
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13277
  {
 
13278
    // Do nothing
 
13279
  }
 
13280
 
 
13281
  Form_2_FunctionSpace_1(boost::shared_ptr<dolfin::Mesh> mesh):
 
13282
    dolfin::FunctionSpace(mesh,
 
13283
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13284
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13285
  {
 
13286
      // Do nothing
 
13287
  }
 
13288
 
 
13289
  Form_2_FunctionSpace_1(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13290
    dolfin::FunctionSpace(mesh,
 
13291
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13292
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13293
  {
 
13294
      // Do nothing
 
13295
  }
 
13296
 
 
13297
  ~Form_2_FunctionSpace_1()
 
13298
  {
 
13299
  }
 
13300
 
 
13301
};
 
13302
 
 
13303
typedef CoefficientSpace___cell_bubble Form_2_FunctionSpace_2;
 
13304
 
 
13305
class Form_2: public dolfin::Form
 
13306
{
 
13307
public:
 
13308
 
 
13309
  // Constructor
 
13310
  Form_2(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1):
 
13311
    dolfin::Form(2, 1), __cell_bubble(*this, 0)
 
13312
  {
 
13313
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13314
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
13315
 
 
13316
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_2());
 
13317
  }
 
13318
 
 
13319
  // Constructor
 
13320
  Form_2(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1, const dolfin::GenericFunction& __cell_bubble):
 
13321
    dolfin::Form(2, 1), __cell_bubble(*this, 0)
 
13322
  {
 
13323
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13324
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
13325
 
 
13326
    this->__cell_bubble = __cell_bubble;
 
13327
 
 
13328
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_2());
 
13329
  }
 
13330
 
 
13331
  // Constructor
 
13332
  Form_2(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1, boost::shared_ptr<const dolfin::GenericFunction> __cell_bubble):
 
13333
    dolfin::Form(2, 1), __cell_bubble(*this, 0)
 
13334
  {
 
13335
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13336
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
13337
 
 
13338
    this->__cell_bubble = *__cell_bubble;
 
13339
 
 
13340
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_2());
 
13341
  }
 
13342
 
 
13343
  // Constructor
 
13344
  Form_2(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1):
 
13345
    dolfin::Form(2, 1), __cell_bubble(*this, 0)
 
13346
  {
 
13347
    _function_spaces[0] = V0;
 
13348
    _function_spaces[1] = V1;
 
13349
 
 
13350
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_2());
 
13351
  }
 
13352
 
 
13353
  // Constructor
 
13354
  Form_2(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1, const dolfin::GenericFunction& __cell_bubble):
 
13355
    dolfin::Form(2, 1), __cell_bubble(*this, 0)
 
13356
  {
 
13357
    _function_spaces[0] = V0;
 
13358
    _function_spaces[1] = V1;
 
13359
 
 
13360
    this->__cell_bubble = __cell_bubble;
 
13361
 
 
13362
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_2());
 
13363
  }
 
13364
 
 
13365
  // Constructor
 
13366
  Form_2(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1, boost::shared_ptr<const dolfin::GenericFunction> __cell_bubble):
 
13367
    dolfin::Form(2, 1), __cell_bubble(*this, 0)
 
13368
  {
 
13369
    _function_spaces[0] = V0;
 
13370
    _function_spaces[1] = V1;
 
13371
 
 
13372
    this->__cell_bubble = *__cell_bubble;
 
13373
 
 
13374
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_2());
 
13375
  }
 
13376
 
 
13377
  // Destructor
 
13378
  ~Form_2()
 
13379
  {}
 
13380
 
 
13381
  /// Return the number of the coefficient with this name
 
13382
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
13383
  {
 
13384
    if (name == "__cell_bubble")
 
13385
      return 0;
 
13386
 
 
13387
    dolfin::error("Invalid coefficient.");
 
13388
    return 0;
 
13389
  }
 
13390
 
 
13391
  /// Return the name of the coefficient with this number
 
13392
  virtual std::string coefficient_name(dolfin::uint i) const
 
13393
  {
 
13394
    switch (i)
 
13395
    {
 
13396
    case 0:
 
13397
      return "__cell_bubble";
 
13398
    }
 
13399
 
 
13400
    dolfin::error("Invalid coefficient.");
 
13401
    return "unnamed";
 
13402
  }
 
13403
 
 
13404
  // Typedefs
 
13405
  typedef Form_2_FunctionSpace_0 TestSpace;
 
13406
  typedef Form_2_FunctionSpace_1 TrialSpace;
 
13407
  typedef Form_2_FunctionSpace_2 CoefficientSpace___cell_bubble;
 
13408
 
 
13409
  // Coefficients
 
13410
  dolfin::CoefficientAssigner __cell_bubble;
 
13411
};
 
13412
 
 
13413
class Form_3_FunctionSpace_0: public dolfin::FunctionSpace
 
13414
{
 
13415
public:
 
13416
 
 
13417
  Form_3_FunctionSpace_0(const dolfin::Mesh& mesh):
 
13418
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13419
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13420
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13421
  {
 
13422
    // Do nothing
 
13423
  }
 
13424
 
 
13425
  Form_3_FunctionSpace_0(dolfin::Mesh& mesh):
 
13426
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13427
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13428
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13429
  {
 
13430
    // Do nothing
 
13431
  }
 
13432
 
 
13433
  Form_3_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
13434
    dolfin::FunctionSpace(mesh,
 
13435
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13436
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13437
  {
 
13438
      // Do nothing
 
13439
  }
 
13440
 
 
13441
  Form_3_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13442
    dolfin::FunctionSpace(mesh,
 
13443
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13444
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13445
  {
 
13446
      // Do nothing
 
13447
  }
 
13448
 
 
13449
  ~Form_3_FunctionSpace_0()
 
13450
  {
 
13451
  }
 
13452
 
 
13453
};
 
13454
 
 
13455
typedef CoefficientSpace_f Form_3_FunctionSpace_1;
 
13456
 
 
13457
typedef CoefficientSpace_g Form_3_FunctionSpace_2;
 
13458
 
 
13459
typedef CoefficientSpace___discrete_primal_solution Form_3_FunctionSpace_3;
 
13460
 
 
13461
typedef CoefficientSpace___cell_bubble Form_3_FunctionSpace_4;
 
13462
 
 
13463
class Form_3: public dolfin::Form
 
13464
{
 
13465
public:
 
13466
 
 
13467
  // Constructor
 
13468
  Form_3(const dolfin::FunctionSpace& V0):
 
13469
    dolfin::Form(1, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_bubble(*this, 3)
 
13470
  {
 
13471
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13472
 
 
13473
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_3());
 
13474
  }
 
13475
 
 
13476
  // Constructor
 
13477
  Form_3(const dolfin::FunctionSpace& V0, const dolfin::GenericFunction& f, const dolfin::GenericFunction& g, const dolfin::GenericFunction& __discrete_primal_solution, const dolfin::GenericFunction& __cell_bubble):
 
13478
    dolfin::Form(1, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_bubble(*this, 3)
 
13479
  {
 
13480
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13481
 
 
13482
    this->f = f;
 
13483
    this->g = g;
 
13484
    this->__discrete_primal_solution = __discrete_primal_solution;
 
13485
    this->__cell_bubble = __cell_bubble;
 
13486
 
 
13487
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_3());
 
13488
  }
 
13489
 
 
13490
  // Constructor
 
13491
  Form_3(const dolfin::FunctionSpace& V0, boost::shared_ptr<const dolfin::GenericFunction> f, boost::shared_ptr<const dolfin::GenericFunction> g, boost::shared_ptr<const dolfin::GenericFunction> __discrete_primal_solution, boost::shared_ptr<const dolfin::GenericFunction> __cell_bubble):
 
13492
    dolfin::Form(1, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_bubble(*this, 3)
 
13493
  {
 
13494
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13495
 
 
13496
    this->f = *f;
 
13497
    this->g = *g;
 
13498
    this->__discrete_primal_solution = *__discrete_primal_solution;
 
13499
    this->__cell_bubble = *__cell_bubble;
 
13500
 
 
13501
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_3());
 
13502
  }
 
13503
 
 
13504
  // Constructor
 
13505
  Form_3(boost::shared_ptr<const dolfin::FunctionSpace> V0):
 
13506
    dolfin::Form(1, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_bubble(*this, 3)
 
13507
  {
 
13508
    _function_spaces[0] = V0;
 
13509
 
 
13510
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_3());
 
13511
  }
 
13512
 
 
13513
  // Constructor
 
13514
  Form_3(boost::shared_ptr<const dolfin::FunctionSpace> V0, const dolfin::GenericFunction& f, const dolfin::GenericFunction& g, const dolfin::GenericFunction& __discrete_primal_solution, const dolfin::GenericFunction& __cell_bubble):
 
13515
    dolfin::Form(1, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_bubble(*this, 3)
 
13516
  {
 
13517
    _function_spaces[0] = V0;
 
13518
 
 
13519
    this->f = f;
 
13520
    this->g = g;
 
13521
    this->__discrete_primal_solution = __discrete_primal_solution;
 
13522
    this->__cell_bubble = __cell_bubble;
 
13523
 
 
13524
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_3());
 
13525
  }
 
13526
 
 
13527
  // Constructor
 
13528
  Form_3(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::GenericFunction> f, boost::shared_ptr<const dolfin::GenericFunction> g, boost::shared_ptr<const dolfin::GenericFunction> __discrete_primal_solution, boost::shared_ptr<const dolfin::GenericFunction> __cell_bubble):
 
13529
    dolfin::Form(1, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_bubble(*this, 3)
 
13530
  {
 
13531
    _function_spaces[0] = V0;
 
13532
 
 
13533
    this->f = *f;
 
13534
    this->g = *g;
 
13535
    this->__discrete_primal_solution = *__discrete_primal_solution;
 
13536
    this->__cell_bubble = *__cell_bubble;
 
13537
 
 
13538
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_3());
 
13539
  }
 
13540
 
 
13541
  // Destructor
 
13542
  ~Form_3()
 
13543
  {}
 
13544
 
 
13545
  /// Return the number of the coefficient with this name
 
13546
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
13547
  {
 
13548
    if (name == "f")
 
13549
      return 0;
 
13550
    else if (name == "g")
 
13551
      return 1;
 
13552
    else if (name == "__discrete_primal_solution")
 
13553
      return 2;
 
13554
    else if (name == "__cell_bubble")
 
13555
      return 3;
 
13556
 
 
13557
    dolfin::error("Invalid coefficient.");
 
13558
    return 0;
 
13559
  }
 
13560
 
 
13561
  /// Return the name of the coefficient with this number
 
13562
  virtual std::string coefficient_name(dolfin::uint i) const
 
13563
  {
 
13564
    switch (i)
 
13565
    {
 
13566
    case 0:
 
13567
      return "f";
 
13568
    case 1:
 
13569
      return "g";
 
13570
    case 2:
 
13571
      return "__discrete_primal_solution";
 
13572
    case 3:
 
13573
      return "__cell_bubble";
 
13574
    }
 
13575
 
 
13576
    dolfin::error("Invalid coefficient.");
 
13577
    return "unnamed";
 
13578
  }
 
13579
 
 
13580
  // Typedefs
 
13581
  typedef Form_3_FunctionSpace_0 TestSpace;
 
13582
  typedef Form_3_FunctionSpace_1 CoefficientSpace_f;
 
13583
  typedef Form_3_FunctionSpace_2 CoefficientSpace_g;
 
13584
  typedef Form_3_FunctionSpace_3 CoefficientSpace___discrete_primal_solution;
 
13585
  typedef Form_3_FunctionSpace_4 CoefficientSpace___cell_bubble;
 
13586
 
 
13587
  // Coefficients
 
13588
  dolfin::CoefficientAssigner f;
 
13589
  dolfin::CoefficientAssigner g;
 
13590
  dolfin::CoefficientAssigner __discrete_primal_solution;
 
13591
  dolfin::CoefficientAssigner __cell_bubble;
 
13592
};
 
13593
 
 
13594
class Form_4_FunctionSpace_0: public dolfin::FunctionSpace
 
13595
{
 
13596
public:
 
13597
 
 
13598
  Form_4_FunctionSpace_0(const dolfin::Mesh& mesh):
 
13599
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13600
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13601
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13602
  {
 
13603
    // Do nothing
 
13604
  }
 
13605
 
 
13606
  Form_4_FunctionSpace_0(dolfin::Mesh& mesh):
 
13607
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13608
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13609
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13610
  {
 
13611
    // Do nothing
 
13612
  }
 
13613
 
 
13614
  Form_4_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
13615
    dolfin::FunctionSpace(mesh,
 
13616
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13617
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13618
  {
 
13619
      // Do nothing
 
13620
  }
 
13621
 
 
13622
  Form_4_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13623
    dolfin::FunctionSpace(mesh,
 
13624
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13625
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13626
  {
 
13627
      // Do nothing
 
13628
  }
 
13629
 
 
13630
  ~Form_4_FunctionSpace_0()
 
13631
  {
 
13632
  }
 
13633
 
 
13634
};
 
13635
 
 
13636
class Form_4_FunctionSpace_1: public dolfin::FunctionSpace
 
13637
{
 
13638
public:
 
13639
 
 
13640
  Form_4_FunctionSpace_1(const dolfin::Mesh& mesh):
 
13641
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13642
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13643
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13644
  {
 
13645
    // Do nothing
 
13646
  }
 
13647
 
 
13648
  Form_4_FunctionSpace_1(dolfin::Mesh& mesh):
 
13649
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13650
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13651
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13652
  {
 
13653
    // Do nothing
 
13654
  }
 
13655
 
 
13656
  Form_4_FunctionSpace_1(boost::shared_ptr<dolfin::Mesh> mesh):
 
13657
    dolfin::FunctionSpace(mesh,
 
13658
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13659
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13660
  {
 
13661
      // Do nothing
 
13662
  }
 
13663
 
 
13664
  Form_4_FunctionSpace_1(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13665
    dolfin::FunctionSpace(mesh,
 
13666
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13667
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13668
  {
 
13669
      // Do nothing
 
13670
  }
 
13671
 
 
13672
  ~Form_4_FunctionSpace_1()
 
13673
  {
 
13674
  }
 
13675
 
 
13676
};
 
13677
 
 
13678
typedef CoefficientSpace___cell_cone Form_4_FunctionSpace_2;
 
13679
 
 
13680
class Form_4: public dolfin::Form
 
13681
{
 
13682
public:
 
13683
 
 
13684
  // Constructor
 
13685
  Form_4(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1):
 
13686
    dolfin::Form(2, 1), __cell_cone(*this, 0)
 
13687
  {
 
13688
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13689
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
13690
 
 
13691
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_4());
 
13692
  }
 
13693
 
 
13694
  // Constructor
 
13695
  Form_4(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1, const dolfin::GenericFunction& __cell_cone):
 
13696
    dolfin::Form(2, 1), __cell_cone(*this, 0)
 
13697
  {
 
13698
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13699
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
13700
 
 
13701
    this->__cell_cone = __cell_cone;
 
13702
 
 
13703
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_4());
 
13704
  }
 
13705
 
 
13706
  // Constructor
 
13707
  Form_4(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1, boost::shared_ptr<const dolfin::GenericFunction> __cell_cone):
 
13708
    dolfin::Form(2, 1), __cell_cone(*this, 0)
 
13709
  {
 
13710
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13711
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
13712
 
 
13713
    this->__cell_cone = *__cell_cone;
 
13714
 
 
13715
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_4());
 
13716
  }
 
13717
 
 
13718
  // Constructor
 
13719
  Form_4(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1):
 
13720
    dolfin::Form(2, 1), __cell_cone(*this, 0)
 
13721
  {
 
13722
    _function_spaces[0] = V0;
 
13723
    _function_spaces[1] = V1;
 
13724
 
 
13725
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_4());
 
13726
  }
 
13727
 
 
13728
  // Constructor
 
13729
  Form_4(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1, const dolfin::GenericFunction& __cell_cone):
 
13730
    dolfin::Form(2, 1), __cell_cone(*this, 0)
 
13731
  {
 
13732
    _function_spaces[0] = V0;
 
13733
    _function_spaces[1] = V1;
 
13734
 
 
13735
    this->__cell_cone = __cell_cone;
 
13736
 
 
13737
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_4());
 
13738
  }
 
13739
 
 
13740
  // Constructor
 
13741
  Form_4(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1, boost::shared_ptr<const dolfin::GenericFunction> __cell_cone):
 
13742
    dolfin::Form(2, 1), __cell_cone(*this, 0)
 
13743
  {
 
13744
    _function_spaces[0] = V0;
 
13745
    _function_spaces[1] = V1;
 
13746
 
 
13747
    this->__cell_cone = *__cell_cone;
 
13748
 
 
13749
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_4());
 
13750
  }
 
13751
 
 
13752
  // Destructor
 
13753
  ~Form_4()
 
13754
  {}
 
13755
 
 
13756
  /// Return the number of the coefficient with this name
 
13757
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
13758
  {
 
13759
    if (name == "__cell_cone")
 
13760
      return 0;
 
13761
 
 
13762
    dolfin::error("Invalid coefficient.");
 
13763
    return 0;
 
13764
  }
 
13765
 
 
13766
  /// Return the name of the coefficient with this number
 
13767
  virtual std::string coefficient_name(dolfin::uint i) const
 
13768
  {
 
13769
    switch (i)
 
13770
    {
 
13771
    case 0:
 
13772
      return "__cell_cone";
 
13773
    }
 
13774
 
 
13775
    dolfin::error("Invalid coefficient.");
 
13776
    return "unnamed";
 
13777
  }
 
13778
 
 
13779
  // Typedefs
 
13780
  typedef Form_4_FunctionSpace_0 TestSpace;
 
13781
  typedef Form_4_FunctionSpace_1 TrialSpace;
 
13782
  typedef Form_4_FunctionSpace_2 CoefficientSpace___cell_cone;
 
13783
 
 
13784
  // Coefficients
 
13785
  dolfin::CoefficientAssigner __cell_cone;
 
13786
};
 
13787
 
 
13788
class Form_5_FunctionSpace_0: public dolfin::FunctionSpace
 
13789
{
 
13790
public:
 
13791
 
 
13792
  Form_5_FunctionSpace_0(const dolfin::Mesh& mesh):
 
13793
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13794
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13795
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13796
  {
 
13797
    // Do nothing
 
13798
  }
 
13799
 
 
13800
  Form_5_FunctionSpace_0(dolfin::Mesh& mesh):
 
13801
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
13802
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13803
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), mesh)))
 
13804
  {
 
13805
    // Do nothing
 
13806
  }
 
13807
 
 
13808
  Form_5_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
13809
    dolfin::FunctionSpace(mesh,
 
13810
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13811
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13812
  {
 
13813
      // Do nothing
 
13814
  }
 
13815
 
 
13816
  Form_5_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
13817
    dolfin::FunctionSpace(mesh,
 
13818
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_4()))),
 
13819
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_4()), *mesh)))
 
13820
  {
 
13821
      // Do nothing
 
13822
  }
 
13823
 
 
13824
  ~Form_5_FunctionSpace_0()
 
13825
  {
 
13826
  }
 
13827
 
 
13828
};
 
13829
 
 
13830
typedef CoefficientSpace_f Form_5_FunctionSpace_1;
 
13831
 
 
13832
typedef CoefficientSpace_g Form_5_FunctionSpace_2;
 
13833
 
 
13834
typedef CoefficientSpace___discrete_primal_solution Form_5_FunctionSpace_3;
 
13835
 
 
13836
typedef CoefficientSpace___cell_residual Form_5_FunctionSpace_4;
 
13837
 
 
13838
typedef CoefficientSpace___cell_cone Form_5_FunctionSpace_5;
 
13839
 
 
13840
class Form_5: public dolfin::Form
 
13841
{
 
13842
public:
 
13843
 
 
13844
  // Constructor
 
13845
  Form_5(const dolfin::FunctionSpace& V0):
 
13846
    dolfin::Form(1, 5), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_residual(*this, 3), __cell_cone(*this, 4)
 
13847
  {
 
13848
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13849
 
 
13850
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_5());
 
13851
  }
 
13852
 
 
13853
  // Constructor
 
13854
  Form_5(const dolfin::FunctionSpace& V0, const dolfin::GenericFunction& f, const dolfin::GenericFunction& g, const dolfin::GenericFunction& __discrete_primal_solution, const dolfin::GenericFunction& __cell_residual, const dolfin::GenericFunction& __cell_cone):
 
13855
    dolfin::Form(1, 5), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_residual(*this, 3), __cell_cone(*this, 4)
 
13856
  {
 
13857
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13858
 
 
13859
    this->f = f;
 
13860
    this->g = g;
 
13861
    this->__discrete_primal_solution = __discrete_primal_solution;
 
13862
    this->__cell_residual = __cell_residual;
 
13863
    this->__cell_cone = __cell_cone;
 
13864
 
 
13865
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_5());
 
13866
  }
 
13867
 
 
13868
  // Constructor
 
13869
  Form_5(const dolfin::FunctionSpace& V0, boost::shared_ptr<const dolfin::GenericFunction> f, boost::shared_ptr<const dolfin::GenericFunction> g, boost::shared_ptr<const dolfin::GenericFunction> __discrete_primal_solution, boost::shared_ptr<const dolfin::GenericFunction> __cell_residual, boost::shared_ptr<const dolfin::GenericFunction> __cell_cone):
 
13870
    dolfin::Form(1, 5), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_residual(*this, 3), __cell_cone(*this, 4)
 
13871
  {
 
13872
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
13873
 
 
13874
    this->f = *f;
 
13875
    this->g = *g;
 
13876
    this->__discrete_primal_solution = *__discrete_primal_solution;
 
13877
    this->__cell_residual = *__cell_residual;
 
13878
    this->__cell_cone = *__cell_cone;
 
13879
 
 
13880
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_5());
 
13881
  }
 
13882
 
 
13883
  // Constructor
 
13884
  Form_5(boost::shared_ptr<const dolfin::FunctionSpace> V0):
 
13885
    dolfin::Form(1, 5), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_residual(*this, 3), __cell_cone(*this, 4)
 
13886
  {
 
13887
    _function_spaces[0] = V0;
 
13888
 
 
13889
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_5());
 
13890
  }
 
13891
 
 
13892
  // Constructor
 
13893
  Form_5(boost::shared_ptr<const dolfin::FunctionSpace> V0, const dolfin::GenericFunction& f, const dolfin::GenericFunction& g, const dolfin::GenericFunction& __discrete_primal_solution, const dolfin::GenericFunction& __cell_residual, const dolfin::GenericFunction& __cell_cone):
 
13894
    dolfin::Form(1, 5), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_residual(*this, 3), __cell_cone(*this, 4)
 
13895
  {
 
13896
    _function_spaces[0] = V0;
 
13897
 
 
13898
    this->f = f;
 
13899
    this->g = g;
 
13900
    this->__discrete_primal_solution = __discrete_primal_solution;
 
13901
    this->__cell_residual = __cell_residual;
 
13902
    this->__cell_cone = __cell_cone;
 
13903
 
 
13904
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_5());
 
13905
  }
 
13906
 
 
13907
  // Constructor
 
13908
  Form_5(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::GenericFunction> f, boost::shared_ptr<const dolfin::GenericFunction> g, boost::shared_ptr<const dolfin::GenericFunction> __discrete_primal_solution, boost::shared_ptr<const dolfin::GenericFunction> __cell_residual, boost::shared_ptr<const dolfin::GenericFunction> __cell_cone):
 
13909
    dolfin::Form(1, 5), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __cell_residual(*this, 3), __cell_cone(*this, 4)
 
13910
  {
 
13911
    _function_spaces[0] = V0;
 
13912
 
 
13913
    this->f = *f;
 
13914
    this->g = *g;
 
13915
    this->__discrete_primal_solution = *__discrete_primal_solution;
 
13916
    this->__cell_residual = *__cell_residual;
 
13917
    this->__cell_cone = *__cell_cone;
 
13918
 
 
13919
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_5());
 
13920
  }
 
13921
 
 
13922
  // Destructor
 
13923
  ~Form_5()
 
13924
  {}
 
13925
 
 
13926
  /// Return the number of the coefficient with this name
 
13927
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
13928
  {
 
13929
    if (name == "f")
 
13930
      return 0;
 
13931
    else if (name == "g")
 
13932
      return 1;
 
13933
    else if (name == "__discrete_primal_solution")
 
13934
      return 2;
 
13935
    else if (name == "__cell_residual")
 
13936
      return 3;
 
13937
    else if (name == "__cell_cone")
 
13938
      return 4;
 
13939
 
 
13940
    dolfin::error("Invalid coefficient.");
 
13941
    return 0;
 
13942
  }
 
13943
 
 
13944
  /// Return the name of the coefficient with this number
 
13945
  virtual std::string coefficient_name(dolfin::uint i) const
 
13946
  {
 
13947
    switch (i)
 
13948
    {
 
13949
    case 0:
 
13950
      return "f";
 
13951
    case 1:
 
13952
      return "g";
 
13953
    case 2:
 
13954
      return "__discrete_primal_solution";
 
13955
    case 3:
 
13956
      return "__cell_residual";
 
13957
    case 4:
 
13958
      return "__cell_cone";
 
13959
    }
 
13960
 
 
13961
    dolfin::error("Invalid coefficient.");
 
13962
    return "unnamed";
 
13963
  }
 
13964
 
 
13965
  // Typedefs
 
13966
  typedef Form_5_FunctionSpace_0 TestSpace;
 
13967
  typedef Form_5_FunctionSpace_1 CoefficientSpace_f;
 
13968
  typedef Form_5_FunctionSpace_2 CoefficientSpace_g;
 
13969
  typedef Form_5_FunctionSpace_3 CoefficientSpace___discrete_primal_solution;
 
13970
  typedef Form_5_FunctionSpace_4 CoefficientSpace___cell_residual;
 
13971
  typedef Form_5_FunctionSpace_5 CoefficientSpace___cell_cone;
 
13972
 
 
13973
  // Coefficients
 
13974
  dolfin::CoefficientAssigner f;
 
13975
  dolfin::CoefficientAssigner g;
 
13976
  dolfin::CoefficientAssigner __discrete_primal_solution;
 
13977
  dolfin::CoefficientAssigner __cell_residual;
 
13978
  dolfin::CoefficientAssigner __cell_cone;
 
13979
};
 
13980
 
 
13981
typedef CoefficientSpace_f Form_6_FunctionSpace_0;
 
13982
 
 
13983
typedef CoefficientSpace_g Form_6_FunctionSpace_1;
 
13984
 
 
13985
typedef CoefficientSpace___discrete_primal_solution Form_6_FunctionSpace_2;
 
13986
 
 
13987
typedef CoefficientSpace___improved_dual Form_6_FunctionSpace_3;
 
13988
 
 
13989
class Form_6: public dolfin::Form
 
13990
{
 
13991
public:
 
13992
 
 
13993
  // Constructor
 
13994
  Form_6(const dolfin::Mesh& mesh):
 
13995
    dolfin::Form(0, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __improved_dual(*this, 3)
 
13996
  {
 
13997
    _mesh = reference_to_no_delete_pointer(mesh);
 
13998
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_6());
 
13999
  }
 
14000
 
 
14001
  // Constructor
 
14002
  Form_6(const dolfin::Mesh& mesh, const dolfin::GenericFunction& f, const dolfin::GenericFunction& g, const dolfin::GenericFunction& __discrete_primal_solution, const dolfin::GenericFunction& __improved_dual):
 
14003
    dolfin::Form(0, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __improved_dual(*this, 3)
 
14004
  {
 
14005
    _mesh = reference_to_no_delete_pointer(mesh);
 
14006
    this->f = f;
 
14007
    this->g = g;
 
14008
    this->__discrete_primal_solution = __discrete_primal_solution;
 
14009
    this->__improved_dual = __improved_dual;
 
14010
 
 
14011
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_6());
 
14012
  }
 
14013
 
 
14014
  // Constructor
 
14015
  Form_6(const dolfin::Mesh& mesh, boost::shared_ptr<const dolfin::GenericFunction> f, boost::shared_ptr<const dolfin::GenericFunction> g, boost::shared_ptr<const dolfin::GenericFunction> __discrete_primal_solution, boost::shared_ptr<const dolfin::GenericFunction> __improved_dual):
 
14016
    dolfin::Form(0, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __improved_dual(*this, 3)
 
14017
  {
 
14018
    _mesh = reference_to_no_delete_pointer(mesh);
 
14019
    this->f = *f;
 
14020
    this->g = *g;
 
14021
    this->__discrete_primal_solution = *__discrete_primal_solution;
 
14022
    this->__improved_dual = *__improved_dual;
 
14023
 
 
14024
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_6());
 
14025
  }
 
14026
 
 
14027
  // Constructor
 
14028
  Form_6(boost::shared_ptr<const dolfin::Mesh> mesh):
 
14029
    dolfin::Form(0, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __improved_dual(*this, 3)
 
14030
  {
 
14031
    _mesh = mesh;
 
14032
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_6());
 
14033
  }
 
14034
 
 
14035
  // Constructor
 
14036
  Form_6(boost::shared_ptr<const dolfin::Mesh> mesh, const dolfin::GenericFunction& f, const dolfin::GenericFunction& g, const dolfin::GenericFunction& __discrete_primal_solution, const dolfin::GenericFunction& __improved_dual):
 
14037
    dolfin::Form(0, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __improved_dual(*this, 3)
 
14038
  {
 
14039
    _mesh = mesh;
 
14040
    this->f = f;
 
14041
    this->g = g;
 
14042
    this->__discrete_primal_solution = __discrete_primal_solution;
 
14043
    this->__improved_dual = __improved_dual;
 
14044
 
 
14045
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_6());
 
14046
  }
 
14047
 
 
14048
  // Constructor
 
14049
  Form_6(boost::shared_ptr<const dolfin::Mesh> mesh, boost::shared_ptr<const dolfin::GenericFunction> f, boost::shared_ptr<const dolfin::GenericFunction> g, boost::shared_ptr<const dolfin::GenericFunction> __discrete_primal_solution, boost::shared_ptr<const dolfin::GenericFunction> __improved_dual):
 
14050
    dolfin::Form(0, 4), f(*this, 0), g(*this, 1), __discrete_primal_solution(*this, 2), __improved_dual(*this, 3)
 
14051
  {
 
14052
    _mesh = mesh;
 
14053
    this->f = *f;
 
14054
    this->g = *g;
 
14055
    this->__discrete_primal_solution = *__discrete_primal_solution;
 
14056
    this->__improved_dual = *__improved_dual;
 
14057
 
 
14058
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_6());
 
14059
  }
 
14060
 
 
14061
  // Destructor
 
14062
  ~Form_6()
 
14063
  {}
 
14064
 
 
14065
  /// Return the number of the coefficient with this name
 
14066
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
14067
  {
 
14068
    if (name == "f")
 
14069
      return 0;
 
14070
    else if (name == "g")
 
14071
      return 1;
 
14072
    else if (name == "__discrete_primal_solution")
 
14073
      return 2;
 
14074
    else if (name == "__improved_dual")
 
14075
      return 3;
 
14076
 
 
14077
    dolfin::error("Invalid coefficient.");
 
14078
    return 0;
 
14079
  }
 
14080
 
 
14081
  /// Return the name of the coefficient with this number
 
14082
  virtual std::string coefficient_name(dolfin::uint i) const
 
14083
  {
 
14084
    switch (i)
 
14085
    {
 
14086
    case 0:
 
14087
      return "f";
 
14088
    case 1:
 
14089
      return "g";
 
14090
    case 2:
 
14091
      return "__discrete_primal_solution";
 
14092
    case 3:
 
14093
      return "__improved_dual";
 
14094
    }
 
14095
 
 
14096
    dolfin::error("Invalid coefficient.");
 
14097
    return "unnamed";
 
14098
  }
 
14099
 
 
14100
  // Typedefs
 
14101
  typedef Form_6_FunctionSpace_0 CoefficientSpace_f;
 
14102
  typedef Form_6_FunctionSpace_1 CoefficientSpace_g;
 
14103
  typedef Form_6_FunctionSpace_2 CoefficientSpace___discrete_primal_solution;
 
14104
  typedef Form_6_FunctionSpace_3 CoefficientSpace___improved_dual;
 
14105
 
 
14106
  // Coefficients
 
14107
  dolfin::CoefficientAssigner f;
 
14108
  dolfin::CoefficientAssigner g;
 
14109
  dolfin::CoefficientAssigner __discrete_primal_solution;
 
14110
  dolfin::CoefficientAssigner __improved_dual;
 
14111
};
 
14112
 
 
14113
class Form_7_FunctionSpace_0: public dolfin::FunctionSpace
 
14114
{
 
14115
public:
 
14116
 
 
14117
  Form_7_FunctionSpace_0(const dolfin::Mesh& mesh):
 
14118
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
14119
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_0()))),
 
14120
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_0()), mesh)))
 
14121
  {
 
14122
    // Do nothing
 
14123
  }
 
14124
 
 
14125
  Form_7_FunctionSpace_0(dolfin::Mesh& mesh):
 
14126
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
14127
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_0()))),
 
14128
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_0()), mesh)))
 
14129
  {
 
14130
    // Do nothing
 
14131
  }
 
14132
 
 
14133
  Form_7_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
14134
    dolfin::FunctionSpace(mesh,
 
14135
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_0()))),
 
14136
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_0()), *mesh)))
 
14137
  {
 
14138
      // Do nothing
 
14139
  }
 
14140
 
 
14141
  Form_7_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
14142
    dolfin::FunctionSpace(mesh,
 
14143
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_0()))),
 
14144
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_0()), *mesh)))
 
14145
  {
 
14146
      // Do nothing
 
14147
  }
 
14148
 
 
14149
  ~Form_7_FunctionSpace_0()
 
14150
  {
 
14151
  }
 
14152
 
 
14153
};
 
14154
 
 
14155
typedef CoefficientSpace___improved_dual Form_7_FunctionSpace_1;
 
14156
 
 
14157
typedef CoefficientSpace___cell_residual Form_7_FunctionSpace_2;
 
14158
 
 
14159
typedef CoefficientSpace___facet_residual Form_7_FunctionSpace_3;
 
14160
 
 
14161
typedef CoefficientSpace___discrete_dual_solution Form_7_FunctionSpace_4;
 
14162
 
 
14163
class Form_7: public dolfin::Form
 
14164
{
 
14165
public:
 
14166
 
 
14167
  // Constructor
 
14168
  Form_7(const dolfin::FunctionSpace& V0):
 
14169
    dolfin::Form(1, 4), __improved_dual(*this, 0), __cell_residual(*this, 1), __facet_residual(*this, 2), __discrete_dual_solution(*this, 3)
 
14170
  {
 
14171
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
14172
 
 
14173
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_7());
 
14174
  }
 
14175
 
 
14176
  // Constructor
 
14177
  Form_7(const dolfin::FunctionSpace& V0, const dolfin::GenericFunction& __improved_dual, const dolfin::GenericFunction& __cell_residual, const dolfin::GenericFunction& __facet_residual, const dolfin::GenericFunction& __discrete_dual_solution):
 
14178
    dolfin::Form(1, 4), __improved_dual(*this, 0), __cell_residual(*this, 1), __facet_residual(*this, 2), __discrete_dual_solution(*this, 3)
 
14179
  {
 
14180
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
14181
 
 
14182
    this->__improved_dual = __improved_dual;
 
14183
    this->__cell_residual = __cell_residual;
 
14184
    this->__facet_residual = __facet_residual;
 
14185
    this->__discrete_dual_solution = __discrete_dual_solution;
 
14186
 
 
14187
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_7());
 
14188
  }
 
14189
 
 
14190
  // Constructor
 
14191
  Form_7(const dolfin::FunctionSpace& V0, boost::shared_ptr<const dolfin::GenericFunction> __improved_dual, boost::shared_ptr<const dolfin::GenericFunction> __cell_residual, boost::shared_ptr<const dolfin::GenericFunction> __facet_residual, boost::shared_ptr<const dolfin::GenericFunction> __discrete_dual_solution):
 
14192
    dolfin::Form(1, 4), __improved_dual(*this, 0), __cell_residual(*this, 1), __facet_residual(*this, 2), __discrete_dual_solution(*this, 3)
 
14193
  {
 
14194
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
14195
 
 
14196
    this->__improved_dual = *__improved_dual;
 
14197
    this->__cell_residual = *__cell_residual;
 
14198
    this->__facet_residual = *__facet_residual;
 
14199
    this->__discrete_dual_solution = *__discrete_dual_solution;
 
14200
 
 
14201
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_7());
 
14202
  }
 
14203
 
 
14204
  // Constructor
 
14205
  Form_7(boost::shared_ptr<const dolfin::FunctionSpace> V0):
 
14206
    dolfin::Form(1, 4), __improved_dual(*this, 0), __cell_residual(*this, 1), __facet_residual(*this, 2), __discrete_dual_solution(*this, 3)
 
14207
  {
 
14208
    _function_spaces[0] = V0;
 
14209
 
 
14210
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_7());
 
14211
  }
 
14212
 
 
14213
  // Constructor
 
14214
  Form_7(boost::shared_ptr<const dolfin::FunctionSpace> V0, const dolfin::GenericFunction& __improved_dual, const dolfin::GenericFunction& __cell_residual, const dolfin::GenericFunction& __facet_residual, const dolfin::GenericFunction& __discrete_dual_solution):
 
14215
    dolfin::Form(1, 4), __improved_dual(*this, 0), __cell_residual(*this, 1), __facet_residual(*this, 2), __discrete_dual_solution(*this, 3)
 
14216
  {
 
14217
    _function_spaces[0] = V0;
 
14218
 
 
14219
    this->__improved_dual = __improved_dual;
 
14220
    this->__cell_residual = __cell_residual;
 
14221
    this->__facet_residual = __facet_residual;
 
14222
    this->__discrete_dual_solution = __discrete_dual_solution;
 
14223
 
 
14224
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_7());
 
14225
  }
 
14226
 
 
14227
  // Constructor
 
14228
  Form_7(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::GenericFunction> __improved_dual, boost::shared_ptr<const dolfin::GenericFunction> __cell_residual, boost::shared_ptr<const dolfin::GenericFunction> __facet_residual, boost::shared_ptr<const dolfin::GenericFunction> __discrete_dual_solution):
 
14229
    dolfin::Form(1, 4), __improved_dual(*this, 0), __cell_residual(*this, 1), __facet_residual(*this, 2), __discrete_dual_solution(*this, 3)
 
14230
  {
 
14231
    _function_spaces[0] = V0;
 
14232
 
 
14233
    this->__improved_dual = *__improved_dual;
 
14234
    this->__cell_residual = *__cell_residual;
 
14235
    this->__facet_residual = *__facet_residual;
 
14236
    this->__discrete_dual_solution = *__discrete_dual_solution;
 
14237
 
 
14238
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_7());
 
14239
  }
 
14240
 
 
14241
  // Destructor
 
14242
  ~Form_7()
 
14243
  {}
 
14244
 
 
14245
  /// Return the number of the coefficient with this name
 
14246
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
14247
  {
 
14248
    if (name == "__improved_dual")
 
14249
      return 0;
 
14250
    else if (name == "__cell_residual")
 
14251
      return 1;
 
14252
    else if (name == "__facet_residual")
 
14253
      return 2;
 
14254
    else if (name == "__discrete_dual_solution")
 
14255
      return 3;
 
14256
 
 
14257
    dolfin::error("Invalid coefficient.");
 
14258
    return 0;
 
14259
  }
 
14260
 
 
14261
  /// Return the name of the coefficient with this number
 
14262
  virtual std::string coefficient_name(dolfin::uint i) const
 
14263
  {
 
14264
    switch (i)
 
14265
    {
 
14266
    case 0:
 
14267
      return "__improved_dual";
 
14268
    case 1:
 
14269
      return "__cell_residual";
 
14270
    case 2:
 
14271
      return "__facet_residual";
 
14272
    case 3:
 
14273
      return "__discrete_dual_solution";
 
14274
    }
 
14275
 
 
14276
    dolfin::error("Invalid coefficient.");
 
14277
    return "unnamed";
 
14278
  }
 
14279
 
 
14280
  // Typedefs
 
14281
  typedef Form_7_FunctionSpace_0 TestSpace;
 
14282
  typedef Form_7_FunctionSpace_1 CoefficientSpace___improved_dual;
 
14283
  typedef Form_7_FunctionSpace_2 CoefficientSpace___cell_residual;
 
14284
  typedef Form_7_FunctionSpace_3 CoefficientSpace___facet_residual;
 
14285
  typedef Form_7_FunctionSpace_4 CoefficientSpace___discrete_dual_solution;
 
14286
 
 
14287
  // Coefficients
 
14288
  dolfin::CoefficientAssigner __improved_dual;
 
14289
  dolfin::CoefficientAssigner __cell_residual;
 
14290
  dolfin::CoefficientAssigner __facet_residual;
 
14291
  dolfin::CoefficientAssigner __discrete_dual_solution;
 
14292
};
 
14293
 
 
14294
class Form_8_FunctionSpace_0: public dolfin::FunctionSpace
 
14295
{
 
14296
public:
 
14297
 
 
14298
  Form_8_FunctionSpace_0(const dolfin::Mesh& mesh):
 
14299
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
14300
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14301
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
14302
  {
 
14303
    // Do nothing
 
14304
  }
 
14305
 
 
14306
  Form_8_FunctionSpace_0(dolfin::Mesh& mesh):
 
14307
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
14308
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14309
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
14310
  {
 
14311
    // Do nothing
 
14312
  }
 
14313
 
 
14314
  Form_8_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
14315
    dolfin::FunctionSpace(mesh,
 
14316
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14317
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
14318
  {
 
14319
      // Do nothing
 
14320
  }
 
14321
 
 
14322
  Form_8_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
14323
    dolfin::FunctionSpace(mesh,
 
14324
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14325
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
14326
  {
 
14327
      // Do nothing
 
14328
  }
 
14329
 
 
14330
  ~Form_8_FunctionSpace_0()
 
14331
  {
 
14332
  }
 
14333
 
 
14334
};
 
14335
 
 
14336
class Form_8_FunctionSpace_1: public dolfin::FunctionSpace
 
14337
{
 
14338
public:
 
14339
 
 
14340
  Form_8_FunctionSpace_1(const dolfin::Mesh& mesh):
 
14341
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
14342
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14343
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
14344
  {
 
14345
    // Do nothing
 
14346
  }
 
14347
 
 
14348
  Form_8_FunctionSpace_1(dolfin::Mesh& mesh):
 
14349
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
14350
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14351
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
14352
  {
 
14353
    // Do nothing
 
14354
  }
 
14355
 
 
14356
  Form_8_FunctionSpace_1(boost::shared_ptr<dolfin::Mesh> mesh):
 
14357
    dolfin::FunctionSpace(mesh,
 
14358
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14359
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
14360
  {
 
14361
      // Do nothing
 
14362
  }
 
14363
 
 
14364
  Form_8_FunctionSpace_1(boost::shared_ptr<const dolfin::Mesh> mesh):
 
14365
    dolfin::FunctionSpace(mesh,
 
14366
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14367
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
14368
  {
 
14369
      // Do nothing
 
14370
  }
 
14371
 
 
14372
  ~Form_8_FunctionSpace_1()
 
14373
  {
 
14374
  }
 
14375
 
 
14376
};
 
14377
 
 
14378
class Form_8: public dolfin::Form
 
14379
{
 
14380
public:
 
14381
 
 
14382
  // Constructor
 
14383
  Form_8(const dolfin::FunctionSpace& V0, const dolfin::FunctionSpace& V1):
 
14384
    dolfin::Form(2, 0)
 
14385
  {
 
14386
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
14387
    _function_spaces[1] = reference_to_no_delete_pointer(V1);
 
14388
 
 
14389
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_8());
 
14390
  }
 
14391
 
 
14392
  // Constructor
 
14393
  Form_8(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::FunctionSpace> V1):
 
14394
    dolfin::Form(2, 0)
 
14395
  {
 
14396
    _function_spaces[0] = V0;
 
14397
    _function_spaces[1] = V1;
 
14398
 
 
14399
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_8());
 
14400
  }
 
14401
 
 
14402
  // Destructor
 
14403
  ~Form_8()
 
14404
  {}
 
14405
 
 
14406
  /// Return the number of the coefficient with this name
 
14407
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
14408
  {
 
14409
 
 
14410
    dolfin::error("No coefficients.");
 
14411
    return 0;
 
14412
  }
 
14413
 
 
14414
  /// Return the name of the coefficient with this number
 
14415
  virtual std::string coefficient_name(dolfin::uint i) const
 
14416
  {
 
14417
 
 
14418
    dolfin::error("No coefficients.");
 
14419
    return "unnamed";
 
14420
  }
 
14421
 
 
14422
  // Typedefs
 
14423
  typedef Form_8_FunctionSpace_0 TestSpace;
 
14424
  typedef Form_8_FunctionSpace_1 TrialSpace;
 
14425
 
 
14426
  // Coefficients
 
14427
};
 
14428
 
 
14429
class Form_9_FunctionSpace_0: public dolfin::FunctionSpace
 
14430
{
 
14431
public:
 
14432
 
 
14433
  Form_9_FunctionSpace_0(const dolfin::Mesh& mesh):
 
14434
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
14435
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14436
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
14437
  {
 
14438
    // Do nothing
 
14439
  }
 
14440
 
 
14441
  Form_9_FunctionSpace_0(dolfin::Mesh& mesh):
 
14442
    dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
 
14443
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14444
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), mesh)))
 
14445
  {
 
14446
    // Do nothing
 
14447
  }
 
14448
 
 
14449
  Form_9_FunctionSpace_0(boost::shared_ptr<dolfin::Mesh> mesh):
 
14450
    dolfin::FunctionSpace(mesh,
 
14451
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14452
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
14453
  {
 
14454
      // Do nothing
 
14455
  }
 
14456
 
 
14457
  Form_9_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
 
14458
    dolfin::FunctionSpace(mesh,
 
14459
                          boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new adaptivepoisson_finite_element_5()))),
 
14460
                          boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new adaptivepoisson_dofmap_5()), *mesh)))
 
14461
  {
 
14462
      // Do nothing
 
14463
  }
 
14464
 
 
14465
  ~Form_9_FunctionSpace_0()
 
14466
  {
 
14467
  }
 
14468
 
 
14469
};
 
14470
 
 
14471
typedef CoefficientSpace_f Form_9_FunctionSpace_1;
 
14472
 
 
14473
typedef CoefficientSpace_g Form_9_FunctionSpace_2;
 
14474
 
 
14475
class Form_9: public dolfin::Form
 
14476
{
 
14477
public:
 
14478
 
 
14479
  // Constructor
 
14480
  Form_9(const dolfin::FunctionSpace& V0):
 
14481
    dolfin::Form(1, 2), f(*this, 0), g(*this, 1)
 
14482
  {
 
14483
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
14484
 
 
14485
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_9());
 
14486
  }
 
14487
 
 
14488
  // Constructor
 
14489
  Form_9(const dolfin::FunctionSpace& V0, const dolfin::GenericFunction& f, const dolfin::GenericFunction& g):
 
14490
    dolfin::Form(1, 2), f(*this, 0), g(*this, 1)
 
14491
  {
 
14492
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
14493
 
 
14494
    this->f = f;
 
14495
    this->g = g;
 
14496
 
 
14497
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_9());
 
14498
  }
 
14499
 
 
14500
  // Constructor
 
14501
  Form_9(const dolfin::FunctionSpace& V0, boost::shared_ptr<const dolfin::GenericFunction> f, boost::shared_ptr<const dolfin::GenericFunction> g):
 
14502
    dolfin::Form(1, 2), f(*this, 0), g(*this, 1)
 
14503
  {
 
14504
    _function_spaces[0] = reference_to_no_delete_pointer(V0);
 
14505
 
 
14506
    this->f = *f;
 
14507
    this->g = *g;
 
14508
 
 
14509
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_9());
 
14510
  }
 
14511
 
 
14512
  // Constructor
 
14513
  Form_9(boost::shared_ptr<const dolfin::FunctionSpace> V0):
 
14514
    dolfin::Form(1, 2), f(*this, 0), g(*this, 1)
 
14515
  {
 
14516
    _function_spaces[0] = V0;
 
14517
 
 
14518
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_9());
 
14519
  }
 
14520
 
 
14521
  // Constructor
 
14522
  Form_9(boost::shared_ptr<const dolfin::FunctionSpace> V0, const dolfin::GenericFunction& f, const dolfin::GenericFunction& g):
 
14523
    dolfin::Form(1, 2), f(*this, 0), g(*this, 1)
 
14524
  {
 
14525
    _function_spaces[0] = V0;
 
14526
 
 
14527
    this->f = f;
 
14528
    this->g = g;
 
14529
 
 
14530
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_9());
 
14531
  }
 
14532
 
 
14533
  // Constructor
 
14534
  Form_9(boost::shared_ptr<const dolfin::FunctionSpace> V0, boost::shared_ptr<const dolfin::GenericFunction> f, boost::shared_ptr<const dolfin::GenericFunction> g):
 
14535
    dolfin::Form(1, 2), f(*this, 0), g(*this, 1)
 
14536
  {
 
14537
    _function_spaces[0] = V0;
 
14538
 
 
14539
    this->f = *f;
 
14540
    this->g = *g;
 
14541
 
 
14542
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_9());
 
14543
  }
 
14544
 
 
14545
  // Destructor
 
14546
  ~Form_9()
 
14547
  {}
 
14548
 
 
14549
  /// Return the number of the coefficient with this name
 
14550
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
14551
  {
 
14552
    if (name == "f")
 
14553
      return 0;
 
14554
    else if (name == "g")
 
14555
      return 1;
 
14556
 
 
14557
    dolfin::error("Invalid coefficient.");
 
14558
    return 0;
 
14559
  }
 
14560
 
 
14561
  /// Return the name of the coefficient with this number
 
14562
  virtual std::string coefficient_name(dolfin::uint i) const
 
14563
  {
 
14564
    switch (i)
 
14565
    {
 
14566
    case 0:
 
14567
      return "f";
 
14568
    case 1:
 
14569
      return "g";
 
14570
    }
 
14571
 
 
14572
    dolfin::error("Invalid coefficient.");
 
14573
    return "unnamed";
 
14574
  }
 
14575
 
 
14576
  // Typedefs
 
14577
  typedef Form_9_FunctionSpace_0 TestSpace;
 
14578
  typedef Form_9_FunctionSpace_1 CoefficientSpace_f;
 
14579
  typedef Form_9_FunctionSpace_2 CoefficientSpace_g;
 
14580
 
 
14581
  // Coefficients
 
14582
  dolfin::CoefficientAssigner f;
 
14583
  dolfin::CoefficientAssigner g;
 
14584
};
 
14585
 
 
14586
typedef CoefficientSpace___discrete_primal_solution Form_10_FunctionSpace_0;
 
14587
 
 
14588
class Form_10: public dolfin::GoalFunctional
 
14589
{
 
14590
public:
 
14591
 
 
14592
  // Constructor
 
14593
  Form_10(const dolfin::Mesh& mesh):
 
14594
    dolfin::GoalFunctional(0, 1), __discrete_primal_solution(*this, 0)
 
14595
  {
 
14596
    _mesh = reference_to_no_delete_pointer(mesh);
 
14597
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_10());
 
14598
  }
 
14599
 
 
14600
  // Constructor
 
14601
  Form_10(const dolfin::Mesh& mesh, const dolfin::GenericFunction& __discrete_primal_solution):
 
14602
    dolfin::GoalFunctional(0, 1), __discrete_primal_solution(*this, 0)
 
14603
  {
 
14604
    _mesh = reference_to_no_delete_pointer(mesh);
 
14605
    this->__discrete_primal_solution = __discrete_primal_solution;
 
14606
 
 
14607
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_10());
 
14608
  }
 
14609
 
 
14610
  // Constructor
 
14611
  Form_10(const dolfin::Mesh& mesh, boost::shared_ptr<const dolfin::GenericFunction> __discrete_primal_solution):
 
14612
    dolfin::GoalFunctional(0, 1), __discrete_primal_solution(*this, 0)
 
14613
  {
 
14614
    _mesh = reference_to_no_delete_pointer(mesh);
 
14615
    this->__discrete_primal_solution = *__discrete_primal_solution;
 
14616
 
 
14617
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_10());
 
14618
  }
 
14619
 
 
14620
  // Constructor
 
14621
  Form_10(boost::shared_ptr<const dolfin::Mesh> mesh):
 
14622
    dolfin::GoalFunctional(0, 1), __discrete_primal_solution(*this, 0)
 
14623
  {
 
14624
    _mesh = mesh;
 
14625
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_10());
 
14626
  }
 
14627
 
 
14628
  // Constructor
 
14629
  Form_10(boost::shared_ptr<const dolfin::Mesh> mesh, const dolfin::GenericFunction& __discrete_primal_solution):
 
14630
    dolfin::GoalFunctional(0, 1), __discrete_primal_solution(*this, 0)
 
14631
  {
 
14632
    _mesh = mesh;
 
14633
    this->__discrete_primal_solution = __discrete_primal_solution;
 
14634
 
 
14635
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_10());
 
14636
  }
 
14637
 
 
14638
  // Constructor
 
14639
  Form_10(boost::shared_ptr<const dolfin::Mesh> mesh, boost::shared_ptr<const dolfin::GenericFunction> __discrete_primal_solution):
 
14640
    dolfin::GoalFunctional(0, 1), __discrete_primal_solution(*this, 0)
 
14641
  {
 
14642
    _mesh = mesh;
 
14643
    this->__discrete_primal_solution = *__discrete_primal_solution;
 
14644
 
 
14645
    _ufc_form = boost::shared_ptr<const ufc::form>(new adaptivepoisson_form_10());
 
14646
  }
 
14647
 
 
14648
  // Destructor
 
14649
  ~Form_10()
 
14650
  {}
 
14651
 
 
14652
  /// Return the number of the coefficient with this name
 
14653
  virtual dolfin::uint coefficient_number(const std::string& name) const
 
14654
  {
 
14655
    if (name == "__discrete_primal_solution")
 
14656
      return 0;
 
14657
 
 
14658
    dolfin::error("Invalid coefficient.");
 
14659
    return 0;
 
14660
  }
 
14661
 
 
14662
  /// Return the name of the coefficient with this number
 
14663
  virtual std::string coefficient_name(dolfin::uint i) const
 
14664
  {
 
14665
    switch (i)
 
14666
    {
 
14667
    case 0:
 
14668
      return "__discrete_primal_solution";
 
14669
    }
 
14670
 
 
14671
    dolfin::error("Invalid coefficient.");
 
14672
    return "unnamed";
 
14673
  }
 
14674
 
 
14675
  // Typedefs
 
14676
  typedef Form_10_FunctionSpace_0 CoefficientSpace___discrete_primal_solution;
 
14677
 
 
14678
  // Coefficients
 
14679
  dolfin::CoefficientAssigner __discrete_primal_solution;
 
14680
 
 
14681
  /// Initialize all error control forms, attach coefficients and
 
14682
  /// (re-)set error control
 
14683
  virtual void update_ec(const dolfin::Form& a, const dolfin::Form& L)
 
14684
  {
 
14685
    // This stuff is created here and shipped elsewhere
 
14686
    boost::shared_ptr<dolfin::Form> a_star;           // Dual lhs
 
14687
    boost::shared_ptr<dolfin::Form> L_star;           // Dual rhs
 
14688
    boost::shared_ptr<dolfin::FunctionSpace> V_Ez_h;  // Extrapolation space
 
14689
    boost::shared_ptr<dolfin::Function> Ez_h;         // Extrapolated dual
 
14690
    boost::shared_ptr<dolfin::Form> residual;         // Residual (as functional)
 
14691
    boost::shared_ptr<dolfin::FunctionSpace> V_R_T;   // Trial space for cell residual
 
14692
    boost::shared_ptr<dolfin::Form> a_R_T;            // Cell residual lhs
 
14693
    boost::shared_ptr<dolfin::Form> L_R_T;            // Cell residual rhs
 
14694
    boost::shared_ptr<dolfin::FunctionSpace> V_b_T;   // Function space for cell bubble
 
14695
    boost::shared_ptr<dolfin::Function> b_T;          // Cell bubble
 
14696
    boost::shared_ptr<dolfin::FunctionSpace> V_R_dT;  // Trial space for facet residual
 
14697
    boost::shared_ptr<dolfin::Form> a_R_dT;           // Facet residual lhs
 
14698
    boost::shared_ptr<dolfin::Form> L_R_dT;           // Facet residual rhs
 
14699
    boost::shared_ptr<dolfin::FunctionSpace> V_b_e;   // Function space for cell cone
 
14700
    boost::shared_ptr<dolfin::Function> b_e;          // Cell cone
 
14701
    boost::shared_ptr<dolfin::FunctionSpace> V_eta_T; // Function space for indicators
 
14702
    boost::shared_ptr<dolfin::Form> eta_T;            // Indicator form
 
14703
 
 
14704
    // Some handy views
 
14705
    const dolfin::FunctionSpace& Vhat(*(a.function_space(0))); // Primal test
 
14706
    const dolfin::FunctionSpace& V(*(a.function_space(1)));    // Primal trial
 
14707
    const dolfin::Mesh& mesh(V.mesh());
 
14708
    std::string name;
 
14709
 
 
14710
    // Initialize dual forms
 
14711
    a_star.reset(new Form_0(V, Vhat));
 
14712
    L_star.reset(new Form_1(V));
 
14713
 
 
14714
    // Attach coefficients from a to a_star and from M to L_star
 
14715
    dolfin::uint coefficient_number = 0;
 
14716
    
 
14717
    for (dolfin::uint i = 0; i < a.num_coefficients(); i++)
 
14718
    {
 
14719
      name = a.coefficient_name(i);
 
14720
      // Don't attach discrete primal solution here (not computed.)
 
14721
      if (name == "__discrete_primal_solution")
 
14722
        continue;
 
14723
 
 
14724
      try {
 
14725
        coefficient_number = a_star->coefficient_number(name);
 
14726
      } catch (...) {
 
14727
        std::cout << "Attaching coefficient named: " << name << " to a_star";
 
14728
        std::cout << " failed! But this might be expected." << std::endl;
 
14729
        continue;
 
14730
      }
 
14731
      a_star->set_coefficient(name, a.coefficient(i));
 
14732
    }
 
14733
    
 
14734
    
 
14735
    for (dolfin::uint i = 0; i < (*this).num_coefficients(); i++)
 
14736
    {
 
14737
      name = (*this).coefficient_name(i);
 
14738
      // Don't attach discrete primal solution here (not computed.)
 
14739
      if (name == "__discrete_primal_solution")
 
14740
        continue;
 
14741
 
 
14742
      try {
 
14743
        coefficient_number = L_star->coefficient_number(name);
 
14744
      } catch (...) {
 
14745
        std::cout << "Attaching coefficient named: " << name << " to L_star";
 
14746
        std::cout << " failed! But this might be expected." << std::endl;
 
14747
        continue;
 
14748
      }
 
14749
      L_star->set_coefficient(name, (*this).coefficient(i));
 
14750
    }
 
14751
    
 
14752
 
 
14753
    // Initialize residual
 
14754
    residual.reset(new Form_6(mesh));
 
14755
 
 
14756
    // Attach coefficients (from a and L) in residual
 
14757
    
 
14758
    for (dolfin::uint i = 0; i < a.num_coefficients(); i++)
 
14759
    {
 
14760
      name = a.coefficient_name(i);
 
14761
      // Don't attach discrete primal solution here (not computed.)
 
14762
      if (name == "__discrete_primal_solution")
 
14763
        continue;
 
14764
 
 
14765
      try {
 
14766
        coefficient_number = residual->coefficient_number(name);
 
14767
      } catch (...) {
 
14768
        std::cout << "Attaching coefficient named: " << name << " to residual";
 
14769
        std::cout << " failed! But this might be expected." << std::endl;
 
14770
        continue;
 
14771
      }
 
14772
      residual->set_coefficient(name, a.coefficient(i));
 
14773
    }
 
14774
    
 
14775
 
 
14776
    for (dolfin::uint i = 0; i < L.num_coefficients(); i++)
 
14777
    {
 
14778
      name = L.coefficient_name(i);
 
14779
      // Don't attach discrete primal solution here (not computed.)
 
14780
      if (name == "__discrete_primal_solution")
 
14781
        continue;
 
14782
 
 
14783
      try {
 
14784
        coefficient_number = residual->coefficient_number(name);
 
14785
      } catch (...) {
 
14786
        std::cout << "Attaching coefficient named: " << name << " to residual";
 
14787
        std::cout << " failed! But this might be expected." << std::endl;
 
14788
        continue;
 
14789
      }
 
14790
      residual->set_coefficient(name, L.coefficient(i));
 
14791
    }
 
14792
    
 
14793
 
 
14794
    // Initialize extrapolation space and (fake) extrapolation
 
14795
    V_Ez_h.reset(new CoefficientSpace___improved_dual(mesh));
 
14796
    Ez_h.reset(new dolfin::Function(V_Ez_h));
 
14797
    residual->set_coefficient("__improved_dual", Ez_h);
 
14798
 
 
14799
    // Create bilinear and linear form for computing cell residual R_T
 
14800
    V_R_T.reset(new Form_3::TestSpace(mesh));
 
14801
    a_R_T.reset(new Form_2(V_R_T, V_R_T));
 
14802
    L_R_T.reset(new Form_3(V_R_T));
 
14803
 
 
14804
    // Initialize bubble and attach to a_R_T and L_R_T
 
14805
    V_b_T.reset(new CoefficientSpace___cell_bubble(mesh));
 
14806
    b_T.reset(new dolfin::Function(V_b_T));
 
14807
    b_T->vector() = 1.0;
 
14808
 
 
14809
    // Attach coefficients (from a and L) to L_R_T
 
14810
    
 
14811
    for (dolfin::uint i = 0; i < a.num_coefficients(); i++)
 
14812
    {
 
14813
      name = a.coefficient_name(i);
 
14814
      // Don't attach discrete primal solution here (not computed.)
 
14815
      if (name == "__discrete_primal_solution")
 
14816
        continue;
 
14817
 
 
14818
      try {
 
14819
        coefficient_number = L_R_T->coefficient_number(name);
 
14820
      } catch (...) {
 
14821
        std::cout << "Attaching coefficient named: " << name << " to L_R_T";
 
14822
        std::cout << " failed! But this might be expected." << std::endl;
 
14823
        continue;
 
14824
      }
 
14825
      L_R_T->set_coefficient(name, a.coefficient(i));
 
14826
    }
 
14827
    
 
14828
 
 
14829
    for (dolfin::uint i = 0; i < L.num_coefficients(); i++)
 
14830
    {
 
14831
      name = L.coefficient_name(i);
 
14832
      // Don't attach discrete primal solution here (not computed.)
 
14833
      if (name == "__discrete_primal_solution")
 
14834
        continue;
 
14835
 
 
14836
      try {
 
14837
        coefficient_number = L_R_T->coefficient_number(name);
 
14838
      } catch (...) {
 
14839
        std::cout << "Attaching coefficient named: " << name << " to L_R_T";
 
14840
        std::cout << " failed! But this might be expected." << std::endl;
 
14841
        continue;
 
14842
      }
 
14843
      L_R_T->set_coefficient(name, L.coefficient(i));
 
14844
    }
 
14845
    
 
14846
 
 
14847
    // Attach bubble function to _a_R_T and _L_R_T
 
14848
    a_R_T->set_coefficient("__cell_bubble", b_T);
 
14849
    L_R_T->set_coefficient("__cell_bubble", b_T);
 
14850
 
 
14851
    // Create bilinear and linear form for computing facet residual R_dT
 
14852
    V_R_dT.reset(new Form_5::TestSpace(mesh));
 
14853
    a_R_dT.reset(new Form_4(V_R_dT, V_R_dT));
 
14854
    L_R_dT.reset(new Form_5(V_R_dT));
 
14855
 
 
14856
    // Attach coefficients (from a and L) to L_R_dT
 
14857
    
 
14858
    for (dolfin::uint i = 0; i < a.num_coefficients(); i++)
 
14859
    {
 
14860
      name = a.coefficient_name(i);
 
14861
      // Don't attach discrete primal solution here (not computed.)
 
14862
      if (name == "__discrete_primal_solution")
 
14863
        continue;
 
14864
 
 
14865
      try {
 
14866
        coefficient_number = L_R_dT->coefficient_number(name);
 
14867
      } catch (...) {
 
14868
        std::cout << "Attaching coefficient named: " << name << " to L_R_dT";
 
14869
        std::cout << " failed! But this might be expected." << std::endl;
 
14870
        continue;
 
14871
      }
 
14872
      L_R_dT->set_coefficient(name, a.coefficient(i));
 
14873
    }
 
14874
    
 
14875
 
 
14876
    for (dolfin::uint i = 0; i < L.num_coefficients(); i++)
 
14877
    {
 
14878
      name = L.coefficient_name(i);
 
14879
      // Don't attach discrete primal solution here (not computed.)
 
14880
      if (name == "__discrete_primal_solution")
 
14881
        continue;
 
14882
 
 
14883
      try {
 
14884
        coefficient_number = L_R_dT->coefficient_number(name);
 
14885
      } catch (...) {
 
14886
        std::cout << "Attaching coefficient named: " << name << " to L_R_dT";
 
14887
        std::cout << " failed! But this might be expected." << std::endl;
 
14888
        continue;
 
14889
      }
 
14890
      L_R_dT->set_coefficient(name, L.coefficient(i));
 
14891
    }
 
14892
    
 
14893
 
 
14894
    // Initialize (fake) cone and attach to a_R_dT and L_R_dT
 
14895
    V_b_e.reset(new CoefficientSpace___cell_cone(mesh));
 
14896
    b_e.reset(new dolfin::Function(V_b_e));
 
14897
    a_R_dT->set_coefficient("__cell_cone", b_e);
 
14898
    L_R_dT->set_coefficient("__cell_cone", b_e);
 
14899
 
 
14900
    // Create error indicator form
 
14901
    V_eta_T.reset(new Form_7::TestSpace(mesh));
 
14902
    eta_T.reset(new Form_7(V_eta_T));
 
14903
 
 
14904
    // Update error control
 
14905
    _ec.reset(new dolfin::ErrorControl(a_star, L_star, residual,
 
14906
                                       a_R_T, L_R_T, a_R_dT, L_R_dT, eta_T,
 
14907
                                       true));
 
14908
 
 
14909
  }
 
14910
 
 
14911
};
 
14912
 
 
14913
 
 
14914
}
 
14915
 
 
14916
#endif