1
// This code conforms with the UFC specification version 1.4
2
// and was automatically generated by FFC version 0.9.0.
12
/// This class defines the interface for a finite element.
14
class heat_finite_element_0: public ufc::finite_element
19
heat_finite_element_0() : ufc::finite_element()
25
virtual ~heat_finite_element_0()
30
/// Return a string identifying the finite element
31
virtual const char* signature() const
33
return "FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0)";
36
/// Return the cell shape
37
virtual ufc::shape cell_shape() const
42
/// Return the dimension of the finite element function space
43
virtual unsigned int space_dimension() const
48
/// Return the rank of the value space
49
virtual unsigned int value_rank() const
54
/// Return the dimension of the value space for axis i
55
virtual unsigned int value_dimension(unsigned int i) const
60
/// Evaluate basis function i at given point in cell
61
virtual void evaluate_basis(unsigned int i,
63
const double* coordinates,
64
const ufc::cell& c) const
66
// Extract vertex coordinates
68
// Compute Jacobian of affine map from reference cell
70
// Compute determinant of Jacobian
72
// Compute inverse of Jacobian
76
// Get coordinates and map to the reference (FIAT) element
81
// Map degree of freedom to element degree of freedom
82
const unsigned int dof = i;
84
// Array of basisvalues
85
double basisvalues[1] = {0.00000000};
87
// Declare helper variables
89
// Compute basisvalues
90
basisvalues[0] = 1.00000000;
92
// Table(s) of coefficients
93
static const double coefficients0[1][1] = \
97
for (unsigned int r = 0; r < 1; r++)
99
*values += coefficients0[dof][r]*basisvalues[r];
100
}// end loop over 'r'
103
/// Evaluate all basis functions at given point in cell
104
virtual void evaluate_basis_all(double* values,
105
const double* coordinates,
106
const ufc::cell& c) const
108
// Element is constant, calling evaluate_basis.
109
evaluate_basis(0, values, coordinates, c);
112
/// Evaluate order n derivatives of basis function i at given point in cell
113
virtual void evaluate_basis_derivatives(unsigned int i,
116
const double* coordinates,
117
const ufc::cell& c) const
119
// Extract vertex coordinates
120
const double * const * x = c.coordinates;
122
// Compute Jacobian of affine map from reference cell
123
const double J_00 = x[1][0] - x[0][0];
124
const double J_01 = x[2][0] - x[0][0];
125
const double J_10 = x[1][1] - x[0][1];
126
const double J_11 = x[2][1] - x[0][1];
128
// Compute determinant of Jacobian
129
double detJ = J_00*J_11 - J_01*J_10;
131
// Compute inverse of Jacobian
132
const double K_00 = J_11 / detJ;
133
const double K_01 = -J_01 / detJ;
134
const double K_10 = -J_10 / detJ;
135
const double K_11 = J_00 / detJ;
139
// Get coordinates and map to the reference (FIAT) element
141
// Compute number of derivatives.
142
unsigned int num_derivatives = 1;
144
for (unsigned int r = 0; r < n; r++)
146
num_derivatives *= 2;
147
}// end loop over 'r'
149
// Declare pointer to two dimensional array that holds combinations of derivatives and initialise
150
unsigned int **combinations = new unsigned int *[num_derivatives];
151
for (unsigned int row = 0; row < num_derivatives; row++)
153
combinations[row] = new unsigned int [n];
154
for (unsigned int col = 0; col < n; col++)
155
combinations[row][col] = 0;
158
// Generate combinations of derivatives
159
for (unsigned int row = 1; row < num_derivatives; row++)
161
for (unsigned int num = 0; num < row; num++)
163
for (unsigned int col = n-1; col+1 > 0; col--)
165
if (combinations[row][col] + 1 > 1)
166
combinations[row][col] = 0;
169
combinations[row][col] += 1;
176
// Compute inverse of Jacobian
177
const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
179
// Declare transformation matrix
180
// Declare pointer to two dimensional array and initialise
181
double **transform = new double *[num_derivatives];
183
for (unsigned int j = 0; j < num_derivatives; j++)
185
transform[j] = new double [num_derivatives];
186
for (unsigned int k = 0; k < num_derivatives; k++)
190
// Construct transformation matrix
191
for (unsigned int row = 0; row < num_derivatives; row++)
193
for (unsigned int col = 0; col < num_derivatives; col++)
195
for (unsigned int k = 0; k < n; k++)
196
transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
200
// Reset values. Assuming that values is always an array.
201
for (unsigned int r = 0; r < num_derivatives; r++)
203
values[r] = 0.00000000;
204
}// end loop over 'r'
206
// Map degree of freedom to element degree of freedom
207
const unsigned int dof = i;
209
// Array of basisvalues
210
double basisvalues[1] = {0.00000000};
212
// Declare helper variables
214
// Compute basisvalues
215
basisvalues[0] = 1.00000000;
217
// Table(s) of coefficients
218
static const double coefficients0[1][1] = \
221
// Tables of derivatives of the polynomial base (transpose).
222
static const double dmats0[1][1] = \
225
static const double dmats1[1][1] = \
228
// Compute reference derivatives
229
// Declare pointer to array of derivatives on FIAT element
230
double *derivatives = new double [num_derivatives];
231
for (unsigned int r = 0; r < num_derivatives; r++)
233
derivatives[r] = 0.00000000;
234
}// end loop over 'r'
236
// Declare derivative matrix (of polynomial basis).
237
double dmats[1][1] = \
240
// Declare (auxiliary) derivative matrix (of polynomial basis).
241
double dmats_old[1][1] = \
244
// Loop possible derivatives.
245
for (unsigned int r = 0; r < num_derivatives; r++)
247
// Resetting dmats values to compute next derivative.
248
for (unsigned int t = 0; t < 1; t++)
250
for (unsigned int u = 0; u < 1; u++)
252
dmats[t][u] = 0.00000000;
255
dmats[t][u] = 1.00000000;
258
}// end loop over 'u'
259
}// end loop over 't'
261
// Looping derivative order to generate dmats.
262
for (unsigned int s = 0; s < n; s++)
264
// Updating dmats_old with new values and resetting dmats.
265
for (unsigned int t = 0; t < 1; t++)
267
for (unsigned int u = 0; u < 1; u++)
269
dmats_old[t][u] = dmats[t][u];
270
dmats[t][u] = 0.00000000;
271
}// end loop over 'u'
272
}// end loop over 't'
274
// Update dmats using an inner product.
275
if (combinations[r][s] == 0)
277
for (unsigned int t = 0; t < 1; t++)
279
for (unsigned int u = 0; u < 1; u++)
281
for (unsigned int tu = 0; tu < 1; tu++)
283
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
284
}// end loop over 'tu'
285
}// end loop over 'u'
286
}// end loop over 't'
289
if (combinations[r][s] == 1)
291
for (unsigned int t = 0; t < 1; t++)
293
for (unsigned int u = 0; u < 1; u++)
295
for (unsigned int tu = 0; tu < 1; tu++)
297
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
298
}// end loop over 'tu'
299
}// end loop over 'u'
300
}// end loop over 't'
303
}// end loop over 's'
304
for (unsigned int s = 0; s < 1; s++)
306
for (unsigned int t = 0; t < 1; t++)
308
derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
309
}// end loop over 't'
310
}// end loop over 's'
311
}// end loop over 'r'
313
// Transform derivatives back to physical element
314
for (unsigned int row = 0; row < num_derivatives; row++)
316
for (unsigned int col = 0; col < num_derivatives; col++)
318
values[row] += transform[row][col]*derivatives[col];
322
// Delete pointer to array of derivatives on FIAT element
323
delete [] derivatives;
325
// Delete pointer to array of combinations of derivatives and transform
326
for (unsigned int r = 0; r < num_derivatives; r++)
328
delete [] combinations[r];
329
delete [] transform[r];
330
}// end loop over 'r'
331
delete [] combinations;
335
/// Evaluate order n derivatives of all basis functions at given point in cell
336
virtual void evaluate_basis_derivatives_all(unsigned int n,
338
const double* coordinates,
339
const ufc::cell& c) const
341
// Element is constant, calling evaluate_basis_derivatives.
342
evaluate_basis_derivatives(0, n, values, coordinates, c);
345
/// Evaluate linear functional for dof i on the function f
346
virtual double evaluate_dof(unsigned int i,
347
const ufc::function& f,
348
const ufc::cell& c) const
350
// Declare variables for result of evaluation
353
// Declare variable for physical coordinates
356
const double * const * x = c.coordinates;
361
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
362
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
363
f.evaluate(vals, y, c);
372
/// Evaluate linear functionals for all dofs on the function f
373
virtual void evaluate_dofs(double* values,
374
const ufc::function& f,
375
const ufc::cell& c) const
377
// Declare variables for result of evaluation
380
// Declare variable for physical coordinates
383
const double * const * x = c.coordinates;
384
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
385
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
386
f.evaluate(vals, y, c);
390
/// Interpolate vertex values from dof values
391
virtual void interpolate_vertex_values(double* vertex_values,
392
const double* dof_values,
393
const ufc::cell& c) const
395
// Evaluate function and change variables
396
vertex_values[0] = dof_values[0];
397
vertex_values[1] = dof_values[0];
398
vertex_values[2] = dof_values[0];
401
/// Return the number of sub elements (for a mixed element)
402
virtual unsigned int num_sub_elements() const
407
/// Create a new finite element for sub element i (for a mixed element)
408
virtual ufc::finite_element* create_sub_element(unsigned int i) const
415
/// This class defines the interface for a finite element.
417
class heat_finite_element_1: public ufc::finite_element
422
heat_finite_element_1() : ufc::finite_element()
428
virtual ~heat_finite_element_1()
433
/// Return a string identifying the finite element
434
virtual const char* signature() const
436
return "FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1)";
439
/// Return the cell shape
440
virtual ufc::shape cell_shape() const
442
return ufc::triangle;
445
/// Return the dimension of the finite element function space
446
virtual unsigned int space_dimension() const
451
/// Return the rank of the value space
452
virtual unsigned int value_rank() const
457
/// Return the dimension of the value space for axis i
458
virtual unsigned int value_dimension(unsigned int i) const
463
/// Evaluate basis function i at given point in cell
464
virtual void evaluate_basis(unsigned int i,
466
const double* coordinates,
467
const ufc::cell& c) const
469
// Extract vertex coordinates
470
const double * const * x = c.coordinates;
472
// Compute Jacobian of affine map from reference cell
473
const double J_00 = x[1][0] - x[0][0];
474
const double J_01 = x[2][0] - x[0][0];
475
const double J_10 = x[1][1] - x[0][1];
476
const double J_11 = x[2][1] - x[0][1];
478
// Compute determinant of Jacobian
479
double detJ = J_00*J_11 - J_01*J_10;
481
// Compute inverse of Jacobian
484
const double C0 = x[1][0] + x[2][0];
485
const double C1 = x[1][1] + x[2][1];
487
// Get coordinates and map to the reference (FIAT) element
488
double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
489
double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
492
*values = 0.00000000;
494
// Map degree of freedom to element degree of freedom
495
const unsigned int dof = i;
497
// Array of basisvalues
498
double basisvalues[3] = {0.00000000, 0.00000000, 0.00000000};
500
// Declare helper variables
503
double tmp0 = (1.00000000 + Y + 2.00000000*X)/2.00000000;
505
// Compute basisvalues
506
basisvalues[0] = 1.00000000;
507
basisvalues[1] = tmp0;
508
for (unsigned int r = 0; r < 1; r++)
510
rr = (r + 1)*(r + 1 + 1)/2 + 1;
512
basisvalues[rr] = basisvalues[ss]*(0.50000000 + r + Y*(1.50000000 + r));
513
}// end loop over 'r'
514
for (unsigned int r = 0; r < 2; r++)
516
for (unsigned int s = 0; s < 2 - r; s++)
518
rr = (r + s)*(r + s + 1)/2 + s;
519
basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s));
520
}// end loop over 's'
521
}// end loop over 'r'
523
// Table(s) of coefficients
524
static const double coefficients0[3][3] = \
525
{{0.47140452, -0.28867513, -0.16666667},
526
{0.47140452, 0.28867513, -0.16666667},
527
{0.47140452, 0.00000000, 0.33333333}};
530
for (unsigned int r = 0; r < 3; r++)
532
*values += coefficients0[dof][r]*basisvalues[r];
533
}// end loop over 'r'
536
/// Evaluate all basis functions at given point in cell
537
virtual void evaluate_basis_all(double* values,
538
const double* coordinates,
539
const ufc::cell& c) const
541
// Helper variable to hold values of a single dof.
542
double dof_values = 0.00000000;
544
// Loop dofs and call evaluate_basis.
545
for (unsigned int r = 0; r < 3; r++)
547
evaluate_basis(r, &dof_values, coordinates, c);
548
values[r] = dof_values;
549
}// end loop over 'r'
552
/// Evaluate order n derivatives of basis function i at given point in cell
553
virtual void evaluate_basis_derivatives(unsigned int i,
556
const double* coordinates,
557
const ufc::cell& c) const
559
// Extract vertex coordinates
560
const double * const * x = c.coordinates;
562
// Compute Jacobian of affine map from reference cell
563
const double J_00 = x[1][0] - x[0][0];
564
const double J_01 = x[2][0] - x[0][0];
565
const double J_10 = x[1][1] - x[0][1];
566
const double J_11 = x[2][1] - x[0][1];
568
// Compute determinant of Jacobian
569
double detJ = J_00*J_11 - J_01*J_10;
571
// Compute inverse of Jacobian
572
const double K_00 = J_11 / detJ;
573
const double K_01 = -J_01 / detJ;
574
const double K_10 = -J_10 / detJ;
575
const double K_11 = J_00 / detJ;
578
const double C0 = x[1][0] + x[2][0];
579
const double C1 = x[1][1] + x[2][1];
581
// Get coordinates and map to the reference (FIAT) element
582
double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
583
double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
585
// Compute number of derivatives.
586
unsigned int num_derivatives = 1;
588
for (unsigned int r = 0; r < n; r++)
590
num_derivatives *= 2;
591
}// end loop over 'r'
593
// Declare pointer to two dimensional array that holds combinations of derivatives and initialise
594
unsigned int **combinations = new unsigned int *[num_derivatives];
595
for (unsigned int row = 0; row < num_derivatives; row++)
597
combinations[row] = new unsigned int [n];
598
for (unsigned int col = 0; col < n; col++)
599
combinations[row][col] = 0;
602
// Generate combinations of derivatives
603
for (unsigned int row = 1; row < num_derivatives; row++)
605
for (unsigned int num = 0; num < row; num++)
607
for (unsigned int col = n-1; col+1 > 0; col--)
609
if (combinations[row][col] + 1 > 1)
610
combinations[row][col] = 0;
613
combinations[row][col] += 1;
620
// Compute inverse of Jacobian
621
const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
623
// Declare transformation matrix
624
// Declare pointer to two dimensional array and initialise
625
double **transform = new double *[num_derivatives];
627
for (unsigned int j = 0; j < num_derivatives; j++)
629
transform[j] = new double [num_derivatives];
630
for (unsigned int k = 0; k < num_derivatives; k++)
634
// Construct transformation matrix
635
for (unsigned int row = 0; row < num_derivatives; row++)
637
for (unsigned int col = 0; col < num_derivatives; col++)
639
for (unsigned int k = 0; k < n; k++)
640
transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
644
// Reset values. Assuming that values is always an array.
645
for (unsigned int r = 0; r < num_derivatives; r++)
647
values[r] = 0.00000000;
648
}// end loop over 'r'
650
// Map degree of freedom to element degree of freedom
651
const unsigned int dof = i;
653
// Array of basisvalues
654
double basisvalues[3] = {0.00000000, 0.00000000, 0.00000000};
656
// Declare helper variables
659
double tmp0 = (1.00000000 + Y + 2.00000000*X)/2.00000000;
661
// Compute basisvalues
662
basisvalues[0] = 1.00000000;
663
basisvalues[1] = tmp0;
664
for (unsigned int r = 0; r < 1; r++)
666
rr = (r + 1)*(r + 1 + 1)/2 + 1;
668
basisvalues[rr] = basisvalues[ss]*(0.50000000 + r + Y*(1.50000000 + r));
669
}// end loop over 'r'
670
for (unsigned int r = 0; r < 2; r++)
672
for (unsigned int s = 0; s < 2 - r; s++)
674
rr = (r + s)*(r + s + 1)/2 + s;
675
basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s));
676
}// end loop over 's'
677
}// end loop over 'r'
679
// Table(s) of coefficients
680
static const double coefficients0[3][3] = \
681
{{0.47140452, -0.28867513, -0.16666667},
682
{0.47140452, 0.28867513, -0.16666667},
683
{0.47140452, 0.00000000, 0.33333333}};
685
// Tables of derivatives of the polynomial base (transpose).
686
static const double dmats0[3][3] = \
687
{{0.00000000, 0.00000000, 0.00000000},
688
{4.89897949, 0.00000000, 0.00000000},
689
{0.00000000, 0.00000000, 0.00000000}};
691
static const double dmats1[3][3] = \
692
{{0.00000000, 0.00000000, 0.00000000},
693
{2.44948974, 0.00000000, 0.00000000},
694
{4.24264069, 0.00000000, 0.00000000}};
696
// Compute reference derivatives
697
// Declare pointer to array of derivatives on FIAT element
698
double *derivatives = new double [num_derivatives];
699
for (unsigned int r = 0; r < num_derivatives; r++)
701
derivatives[r] = 0.00000000;
702
}// end loop over 'r'
704
// Declare derivative matrix (of polynomial basis).
705
double dmats[3][3] = \
706
{{1.00000000, 0.00000000, 0.00000000},
707
{0.00000000, 1.00000000, 0.00000000},
708
{0.00000000, 0.00000000, 1.00000000}};
710
// Declare (auxiliary) derivative matrix (of polynomial basis).
711
double dmats_old[3][3] = \
712
{{1.00000000, 0.00000000, 0.00000000},
713
{0.00000000, 1.00000000, 0.00000000},
714
{0.00000000, 0.00000000, 1.00000000}};
716
// Loop possible derivatives.
717
for (unsigned int r = 0; r < num_derivatives; r++)
719
// Resetting dmats values to compute next derivative.
720
for (unsigned int t = 0; t < 3; t++)
722
for (unsigned int u = 0; u < 3; u++)
724
dmats[t][u] = 0.00000000;
727
dmats[t][u] = 1.00000000;
730
}// end loop over 'u'
731
}// end loop over 't'
733
// Looping derivative order to generate dmats.
734
for (unsigned int s = 0; s < n; s++)
736
// Updating dmats_old with new values and resetting dmats.
737
for (unsigned int t = 0; t < 3; t++)
739
for (unsigned int u = 0; u < 3; u++)
741
dmats_old[t][u] = dmats[t][u];
742
dmats[t][u] = 0.00000000;
743
}// end loop over 'u'
744
}// end loop over 't'
746
// Update dmats using an inner product.
747
if (combinations[r][s] == 0)
749
for (unsigned int t = 0; t < 3; t++)
751
for (unsigned int u = 0; u < 3; u++)
753
for (unsigned int tu = 0; tu < 3; tu++)
755
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
756
}// end loop over 'tu'
757
}// end loop over 'u'
758
}// end loop over 't'
761
if (combinations[r][s] == 1)
763
for (unsigned int t = 0; t < 3; t++)
765
for (unsigned int u = 0; u < 3; u++)
767
for (unsigned int tu = 0; tu < 3; tu++)
769
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
770
}// end loop over 'tu'
771
}// end loop over 'u'
772
}// end loop over 't'
775
}// end loop over 's'
776
for (unsigned int s = 0; s < 3; s++)
778
for (unsigned int t = 0; t < 3; t++)
780
derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
781
}// end loop over 't'
782
}// end loop over 's'
783
}// end loop over 'r'
785
// Transform derivatives back to physical element
786
for (unsigned int row = 0; row < num_derivatives; row++)
788
for (unsigned int col = 0; col < num_derivatives; col++)
790
values[row] += transform[row][col]*derivatives[col];
794
// Delete pointer to array of derivatives on FIAT element
795
delete [] derivatives;
797
// Delete pointer to array of combinations of derivatives and transform
798
for (unsigned int r = 0; r < num_derivatives; r++)
800
delete [] combinations[r];
801
delete [] transform[r];
802
}// end loop over 'r'
803
delete [] combinations;
807
/// Evaluate order n derivatives of all basis functions at given point in cell
808
virtual void evaluate_basis_derivatives_all(unsigned int n,
810
const double* coordinates,
811
const ufc::cell& c) const
813
// Compute number of derivatives.
814
unsigned int num_derivatives = 1;
816
for (unsigned int r = 0; r < n; r++)
818
num_derivatives *= 2;
819
}// end loop over 'r'
821
// Helper variable to hold values of a single dof.
822
double *dof_values = new double [num_derivatives];
823
for (unsigned int r = 0; r < num_derivatives; r++)
825
dof_values[r] = 0.00000000;
826
}// end loop over 'r'
828
// Loop dofs and call evaluate_basis_derivatives.
829
for (unsigned int r = 0; r < 3; r++)
831
evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
832
for (unsigned int s = 0; s < num_derivatives; s++)
834
values[r*num_derivatives + s] = dof_values[s];
835
}// end loop over 's'
836
}// end loop over 'r'
839
delete [] dof_values;
842
/// Evaluate linear functional for dof i on the function f
843
virtual double evaluate_dof(unsigned int i,
844
const ufc::function& f,
845
const ufc::cell& c) const
847
// Declare variables for result of evaluation
850
// Declare variable for physical coordinates
853
const double * const * x = c.coordinates;
860
f.evaluate(vals, y, c);
868
f.evaluate(vals, y, c);
876
f.evaluate(vals, y, c);
885
/// Evaluate linear functionals for all dofs on the function f
886
virtual void evaluate_dofs(double* values,
887
const ufc::function& f,
888
const ufc::cell& c) const
890
// Declare variables for result of evaluation
893
// Declare variable for physical coordinates
896
const double * const * x = c.coordinates;
899
f.evaluate(vals, y, c);
903
f.evaluate(vals, y, c);
907
f.evaluate(vals, y, c);
911
/// Interpolate vertex values from dof values
912
virtual void interpolate_vertex_values(double* vertex_values,
913
const double* dof_values,
914
const ufc::cell& c) const
916
// Evaluate function and change variables
917
vertex_values[0] = dof_values[0];
918
vertex_values[1] = dof_values[1];
919
vertex_values[2] = dof_values[2];
922
/// Return the number of sub elements (for a mixed element)
923
virtual unsigned int num_sub_elements() const
928
/// Create a new finite element for sub element i (for a mixed element)
929
virtual ufc::finite_element* create_sub_element(unsigned int i) const
936
/// This class defines the interface for a local-to-global mapping of
937
/// degrees of freedom (dofs).
939
class heat_dof_map_0: public ufc::dof_map
943
unsigned int _global_dimension;
948
heat_dof_map_0() : ufc::dof_map()
950
_global_dimension = 0;
954
virtual ~heat_dof_map_0()
959
/// Return a string identifying the dof map
960
virtual const char* signature() const
962
return "FFC dofmap for FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0)";
965
/// Return true iff mesh entities of topological dimension d are needed
966
virtual bool needs_mesh_entities(unsigned int d) const
990
/// Initialize dof map for mesh (return true iff init_cell() is needed)
991
virtual bool init_mesh(const ufc::mesh& m)
993
_global_dimension = m.num_entities[2];
997
/// Initialize dof map for given cell
998
virtual void init_cell(const ufc::mesh& m,
1004
/// Finish initialization of dof map for cells
1005
virtual void init_cell_finalize()
1010
/// Return the dimension of the global finite element function space
1011
virtual unsigned int global_dimension() const
1013
return _global_dimension;
1016
/// Return the dimension of the local finite element function space for a cell
1017
virtual unsigned int local_dimension(const ufc::cell& c) const
1022
/// Return the maximum dimension of the local finite element function space
1023
virtual unsigned int max_local_dimension() const
1028
// Return the geometric dimension of the coordinates this dof map provides
1029
virtual unsigned int geometric_dimension() const
1034
/// Return the number of dofs on each cell facet
1035
virtual unsigned int num_facet_dofs() const
1040
/// Return the number of dofs associated with each cell entity of dimension d
1041
virtual unsigned int num_entity_dofs(unsigned int d) const
1065
/// Tabulate the local-to-global mapping of dofs on a cell
1066
virtual void tabulate_dofs(unsigned int* dofs,
1068
const ufc::cell& c) const
1070
dofs[0] = c.entity_indices[2][0];
1073
/// Tabulate the local-to-local mapping from facet dofs to cell dofs
1074
virtual void tabulate_facet_dofs(unsigned int* dofs,
1075
unsigned int facet) const
1098
/// Tabulate the local-to-local mapping of dofs on entity (d, i)
1099
virtual void tabulate_entity_dofs(unsigned int* dofs,
1100
unsigned int d, unsigned int i) const
1104
std::cerr << "*** FFC warning: " << "d is larger than dimension (2)" << std::endl;
1123
std::cerr << "*** FFC warning: " << "i is larger than number of entities (0)" << std::endl;
1133
/// Tabulate the coordinates of all dofs on a cell
1134
virtual void tabulate_coordinates(double** coordinates,
1135
const ufc::cell& c) const
1137
const double * const * x = c.coordinates;
1139
coordinates[0][0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1140
coordinates[0][1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1143
/// Return the number of sub dof maps (for a mixed element)
1144
virtual unsigned int num_sub_dof_maps() const
1149
/// Create a new dof_map for sub dof map i (for a mixed element)
1150
virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
1157
/// This class defines the interface for a local-to-global mapping of
1158
/// degrees of freedom (dofs).
1160
class heat_dof_map_1: public ufc::dof_map
1164
unsigned int _global_dimension;
1169
heat_dof_map_1() : ufc::dof_map()
1171
_global_dimension = 0;
1175
virtual ~heat_dof_map_1()
1180
/// Return a string identifying the dof map
1181
virtual const char* signature() const
1183
return "FFC dofmap for FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1)";
1186
/// Return true iff mesh entities of topological dimension d are needed
1187
virtual bool needs_mesh_entities(unsigned int d) const
1211
/// Initialize dof map for mesh (return true iff init_cell() is needed)
1212
virtual bool init_mesh(const ufc::mesh& m)
1214
_global_dimension = m.num_entities[0];
1218
/// Initialize dof map for given cell
1219
virtual void init_cell(const ufc::mesh& m,
1225
/// Finish initialization of dof map for cells
1226
virtual void init_cell_finalize()
1231
/// Return the dimension of the global finite element function space
1232
virtual unsigned int global_dimension() const
1234
return _global_dimension;
1237
/// Return the dimension of the local finite element function space for a cell
1238
virtual unsigned int local_dimension(const ufc::cell& c) const
1243
/// Return the maximum dimension of the local finite element function space
1244
virtual unsigned int max_local_dimension() const
1249
// Return the geometric dimension of the coordinates this dof map provides
1250
virtual unsigned int geometric_dimension() const
1255
/// Return the number of dofs on each cell facet
1256
virtual unsigned int num_facet_dofs() const
1261
/// Return the number of dofs associated with each cell entity of dimension d
1262
virtual unsigned int num_entity_dofs(unsigned int d) const
1286
/// Tabulate the local-to-global mapping of dofs on a cell
1287
virtual void tabulate_dofs(unsigned int* dofs,
1289
const ufc::cell& c) const
1291
dofs[0] = c.entity_indices[0][0];
1292
dofs[1] = c.entity_indices[0][1];
1293
dofs[2] = c.entity_indices[0][2];
1296
/// Tabulate the local-to-local mapping from facet dofs to cell dofs
1297
virtual void tabulate_facet_dofs(unsigned int* dofs,
1298
unsigned int facet) const
1324
/// Tabulate the local-to-local mapping of dofs on entity (d, i)
1325
virtual void tabulate_entity_dofs(unsigned int* dofs,
1326
unsigned int d, unsigned int i) const
1330
std::cerr << "*** FFC warning: " << "d is larger than dimension (2)" << std::endl;
1339
std::cerr << "*** FFC warning: " << "i is larger than number of entities (2)" << std::endl;
1377
/// Tabulate the coordinates of all dofs on a cell
1378
virtual void tabulate_coordinates(double** coordinates,
1379
const ufc::cell& c) const
1381
const double * const * x = c.coordinates;
1383
coordinates[0][0] = x[0][0];
1384
coordinates[0][1] = x[0][1];
1385
coordinates[1][0] = x[1][0];
1386
coordinates[1][1] = x[1][1];
1387
coordinates[2][0] = x[2][0];
1388
coordinates[2][1] = x[2][1];
1391
/// Return the number of sub dof maps (for a mixed element)
1392
virtual unsigned int num_sub_dof_maps() const
1397
/// Create a new dof_map for sub dof map i (for a mixed element)
1398
virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
1405
/// This class defines the interface for the tabulation of the cell
1406
/// tensor corresponding to the local contribution to a form from
1407
/// the integral over a cell.
1409
class heat_cell_integral_0_0: public ufc::cell_integral
1414
heat_cell_integral_0_0() : ufc::cell_integral()
1420
virtual ~heat_cell_integral_0_0()
1425
/// Tabulate the tensor for the contribution from a local cell
1426
virtual void tabulate_tensor(double* A,
1427
const double * const * w,
1428
const ufc::cell& c) const
1430
// Extract vertex coordinates
1431
const double * const * x = c.coordinates;
1433
// Compute Jacobian of affine map from reference cell
1434
const double J_00 = x[1][0] - x[0][0];
1435
const double J_01 = x[2][0] - x[0][0];
1436
const double J_10 = x[1][1] - x[0][1];
1437
const double J_11 = x[2][1] - x[0][1];
1439
// Compute determinant of Jacobian
1440
double detJ = J_00*J_11 - J_01*J_10;
1442
// Compute inverse of Jacobian
1443
const double K_00 = J_11 / detJ;
1444
const double K_01 = -J_01 / detJ;
1445
const double K_10 = -J_10 / detJ;
1446
const double K_11 = J_00 / detJ;
1449
const double det = std::abs(detJ);
1451
// Array of quadrature weights
1452
static const double W4[4] = {0.15902069, 0.09097931, 0.15902069, 0.09097931};
1453
// Quadrature points on the UFC reference element: (0.17855873, 0.15505103), (0.07503111, 0.64494897), (0.66639025, 0.15505103), (0.28001992, 0.64494897)
1455
// Value of basis functions at quadrature points.
1456
static const double FE0[4][3] = \
1457
{{0.66639025, 0.17855873, 0.15505103},
1458
{0.28001992, 0.07503111, 0.64494897},
1459
{0.17855873, 0.66639025, 0.15505103},
1460
{0.07503111, 0.28001992, 0.64494897}};
1462
static const double FE0_D01[4][3] = \
1463
{{-1.00000000, 0.00000000, 1.00000000},
1464
{-1.00000000, 0.00000000, 1.00000000},
1465
{-1.00000000, 0.00000000, 1.00000000},
1466
{-1.00000000, 0.00000000, 1.00000000}};
1468
static const double FE0_D10[4][3] = \
1469
{{-1.00000000, 1.00000000, 0.00000000},
1470
{-1.00000000, 1.00000000, 0.00000000},
1471
{-1.00000000, 1.00000000, 0.00000000},
1472
{-1.00000000, 1.00000000, 0.00000000}};
1474
for (unsigned int r = 0; r < 9; r++)
1477
}// end loop over 'r'
1479
// Compute element tensor using UFL quadrature representation
1480
// Optimisations: ('simplify expressions', False), ('ignore zero tables', False), ('non zero columns', False), ('remove zero terms', False), ('ignore ones', False)
1482
// Loop quadrature points for integral
1483
// Number of operations to compute element tensor for following IP loop = 816
1484
for (unsigned int ip = 0; ip < 4; ip++)
1487
// Coefficient declarations
1488
double F0 = 0.00000000;
1490
// Total number of operations to compute function values = 6
1491
for (unsigned int r = 0; r < 3; r++)
1493
F0 += FE0[ip][r]*w[0][r];
1494
}// end loop over 'r'
1496
// Number of operations for primary indices: 198
1497
for (unsigned int j = 0; j < 3; j++)
1499
for (unsigned int k = 0; k < 3; k++)
1501
// Number of operations to compute entry: 22
1502
A[j*3 + k] += ((FE0[ip][j]*FE0[ip][k] + ((((K_00*FE0_D10[ip][j] + K_10*FE0_D01[ip][j]))*((K_00*FE0_D10[ip][k] + K_10*FE0_D01[ip][k])) + ((K_01*FE0_D10[ip][j] + K_11*FE0_D01[ip][j]))*((K_01*FE0_D10[ip][k] + K_11*FE0_D01[ip][k]))))*F0*w[1][0]))*W4[ip]*det;
1503
}// end loop over 'k'
1504
}// end loop over 'j'
1505
}// end loop over 'ip'
1510
/// This class defines the interface for the tabulation of the cell
1511
/// tensor corresponding to the local contribution to a form from
1512
/// the integral over a cell.
1514
class heat_cell_integral_1_0: public ufc::cell_integral
1519
heat_cell_integral_1_0() : ufc::cell_integral()
1525
virtual ~heat_cell_integral_1_0()
1530
/// Tabulate the tensor for the contribution from a local cell
1531
virtual void tabulate_tensor(double* A,
1532
const double * const * w,
1533
const ufc::cell& c) const
1535
// Number of operations (multiply-add pairs) for Jacobian data: 12
1536
// Number of operations (multiply-add pairs) for geometry tensor: 7
1537
// Number of operations (multiply-add pairs) for tensor contraction: 16
1538
// Total number of operations (multiply-add pairs): 35
1540
// Extract vertex coordinates
1541
const double * const * x = c.coordinates;
1543
// Compute Jacobian of affine map from reference cell
1544
const double J_00 = x[1][0] - x[0][0];
1545
const double J_01 = x[2][0] - x[0][0];
1546
const double J_10 = x[1][1] - x[0][1];
1547
const double J_11 = x[2][1] - x[0][1];
1549
// Compute determinant of Jacobian
1550
double detJ = J_00*J_11 - J_01*J_10;
1552
// Compute inverse of Jacobian
1555
const double det = std::abs(detJ);
1557
// Compute geometry tensor
1558
const double G0_0 = det*w[0][0]*(1.0);
1559
const double G0_1 = det*w[0][1]*(1.0);
1560
const double G0_2 = det*w[0][2]*(1.0);
1561
const double G1_0_0 = det*w[1][0]*w[2][0]*(1.0);
1562
const double G1_1_0 = det*w[1][1]*w[2][0]*(1.0);
1563
const double G1_2_0 = det*w[1][2]*w[2][0]*(1.0);
1565
// Compute element tensor
1566
A[0] = 0.08333333*G0_0 + 0.04166667*G0_1 + 0.04166667*G0_2 + 0.08333333*G1_0_0 + 0.04166667*G1_1_0 + 0.04166667*G1_2_0;
1567
A[1] = 0.04166667*G0_0 + 0.08333333*G0_1 + 0.04166667*G0_2 + 0.04166667*G1_0_0 + 0.08333333*G1_1_0 + 0.04166667*G1_2_0;
1568
A[2] = 0.04166667*G0_0 + 0.04166667*G0_1 + 0.08333333*G0_2 + 0.04166667*G1_0_0 + 0.04166667*G1_1_0 + 0.08333333*G1_2_0;
1573
/// This class defines the interface for the assembly of the global
1574
/// tensor corresponding to a form with r + n arguments, that is, a
1577
/// a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
1579
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
1580
/// global tensor A is defined by
1582
/// A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
1584
/// where each argument Vj represents the application to the
1585
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
1586
/// fixed functions (coefficients).
1588
class heat_form_0: public ufc::form
1593
heat_form_0() : ufc::form()
1599
virtual ~heat_form_0()
1604
/// Return a string identifying the form
1605
virtual const char* signature() const
1607
return "Form([Integral(Sum(Product(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 1)), Product(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})), Product(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Constant(Cell('triangle', 1, Space(2)), 1)))), Measure('cell', 0, None))])";
1610
/// Return the rank of the global tensor (r)
1611
virtual unsigned int rank() const
1616
/// Return the number of coefficients (n)
1617
virtual unsigned int num_coefficients() const
1622
/// Return the number of cell integrals
1623
virtual unsigned int num_cell_integrals() const
1628
/// Return the number of exterior facet integrals
1629
virtual unsigned int num_exterior_facet_integrals() const
1634
/// Return the number of interior facet integrals
1635
virtual unsigned int num_interior_facet_integrals() const
1640
/// Create a new finite element for argument function i
1641
virtual ufc::finite_element* create_finite_element(unsigned int i) const
1647
return new heat_finite_element_1();
1652
return new heat_finite_element_1();
1657
return new heat_finite_element_1();
1662
return new heat_finite_element_0();
1670
/// Create a new dof map for argument function i
1671
virtual ufc::dof_map* create_dof_map(unsigned int i) const
1677
return new heat_dof_map_1();
1682
return new heat_dof_map_1();
1687
return new heat_dof_map_1();
1692
return new heat_dof_map_0();
1700
/// Create a new cell integral on sub domain i
1701
virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
1707
return new heat_cell_integral_0_0();
1715
/// Create a new exterior facet integral on sub domain i
1716
virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
1721
/// Create a new interior facet integral on sub domain i
1722
virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const
1729
/// This class defines the interface for the assembly of the global
1730
/// tensor corresponding to a form with r + n arguments, that is, a
1733
/// a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
1735
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
1736
/// global tensor A is defined by
1738
/// A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
1740
/// where each argument Vj represents the application to the
1741
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
1742
/// fixed functions (coefficients).
1744
class heat_form_1: public ufc::form
1749
heat_form_1() : ufc::form()
1755
virtual ~heat_form_1()
1760
/// Return a string identifying the form
1761
virtual const char* signature() const
1763
return "Form([Integral(Sum(Product(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0)), Product(Coefficient(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 1), Product(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), Constant(Cell('triangle', 1, Space(2)), 2)))), Measure('cell', 0, None))])";
1766
/// Return the rank of the global tensor (r)
1767
virtual unsigned int rank() const
1772
/// Return the number of coefficients (n)
1773
virtual unsigned int num_coefficients() const
1778
/// Return the number of cell integrals
1779
virtual unsigned int num_cell_integrals() const
1784
/// Return the number of exterior facet integrals
1785
virtual unsigned int num_exterior_facet_integrals() const
1790
/// Return the number of interior facet integrals
1791
virtual unsigned int num_interior_facet_integrals() const
1796
/// Create a new finite element for argument function i
1797
virtual ufc::finite_element* create_finite_element(unsigned int i) const
1803
return new heat_finite_element_1();
1808
return new heat_finite_element_1();
1813
return new heat_finite_element_1();
1818
return new heat_finite_element_0();
1826
/// Create a new dof map for argument function i
1827
virtual ufc::dof_map* create_dof_map(unsigned int i) const
1833
return new heat_dof_map_1();
1838
return new heat_dof_map_1();
1843
return new heat_dof_map_1();
1848
return new heat_dof_map_0();
1856
/// Create a new cell integral on sub domain i
1857
virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
1863
return new heat_cell_integral_1_0();
1871
/// Create a new exterior facet integral on sub domain i
1872
virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
1877
/// Create a new interior facet integral on sub domain i
1878
virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const