1
// This code conforms with the UFC specification version 1.4
2
// and was automatically generated by FFC version 0.9.0.
4
#ifndef __TENSORWEIGHTEDPOISSON_H
5
#define __TENSORWEIGHTEDPOISSON_H
12
/// This class defines the interface for a finite element.
14
class tensorweightedpoisson_finite_element_0: public ufc::finite_element
19
tensorweightedpoisson_finite_element_0() : ufc::finite_element()
25
virtual ~tensorweightedpoisson_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 tensorweightedpoisson_finite_element_1: public ufc::finite_element
422
tensorweightedpoisson_finite_element_1() : ufc::finite_element()
428
virtual ~tensorweightedpoisson_finite_element_1()
433
/// Return a string identifying the finite element
434
virtual const char* signature() const
436
return "TensorElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0, (2, 2), None)";
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
477
/// Evaluate basis function i at given point in cell
478
virtual void evaluate_basis(unsigned int i,
480
const double* coordinates,
481
const ufc::cell& c) const
483
// Extract vertex coordinates
485
// Compute Jacobian of affine map from reference cell
487
// Compute determinant of Jacobian
489
// Compute inverse of Jacobian
493
// Get coordinates and map to the reference (FIAT) element
496
values[0] = 0.00000000;
497
values[1] = 0.00000000;
498
values[2] = 0.00000000;
499
values[3] = 0.00000000;
500
if (0 <= i && i <= 0)
502
// Map degree of freedom to element degree of freedom
503
const unsigned int dof = i;
505
// Array of basisvalues
506
double basisvalues[1] = {0.00000000};
508
// Declare helper variables
510
// Compute basisvalues
511
basisvalues[0] = 1.00000000;
513
// Table(s) of coefficients
514
static const double coefficients0[1][1] = \
518
for (unsigned int r = 0; r < 1; r++)
520
values[0] += coefficients0[dof][r]*basisvalues[r];
521
}// end loop over 'r'
524
if (1 <= i && i <= 1)
526
// Map degree of freedom to element degree of freedom
527
const unsigned int dof = i - 1;
529
// Array of basisvalues
530
double basisvalues[1] = {0.00000000};
532
// Declare helper variables
534
// Compute basisvalues
535
basisvalues[0] = 1.00000000;
537
// Table(s) of coefficients
538
static const double coefficients0[1][1] = \
542
for (unsigned int r = 0; r < 1; r++)
544
values[1] += coefficients0[dof][r]*basisvalues[r];
545
}// end loop over 'r'
548
if (2 <= i && i <= 2)
550
// Map degree of freedom to element degree of freedom
551
const unsigned int dof = i - 2;
553
// Array of basisvalues
554
double basisvalues[1] = {0.00000000};
556
// Declare helper variables
558
// Compute basisvalues
559
basisvalues[0] = 1.00000000;
561
// Table(s) of coefficients
562
static const double coefficients0[1][1] = \
566
for (unsigned int r = 0; r < 1; r++)
568
values[2] += coefficients0[dof][r]*basisvalues[r];
569
}// end loop over 'r'
572
if (3 <= i && i <= 3)
574
// Map degree of freedom to element degree of freedom
575
const unsigned int dof = i - 3;
577
// Array of basisvalues
578
double basisvalues[1] = {0.00000000};
580
// Declare helper variables
582
// Compute basisvalues
583
basisvalues[0] = 1.00000000;
585
// Table(s) of coefficients
586
static const double coefficients0[1][1] = \
590
for (unsigned int r = 0; r < 1; r++)
592
values[3] += coefficients0[dof][r]*basisvalues[r];
593
}// end loop over 'r'
598
/// Evaluate all basis functions at given point in cell
599
virtual void evaluate_basis_all(double* values,
600
const double* coordinates,
601
const ufc::cell& c) const
603
// Helper variable to hold values of a single dof.
604
double dof_values[4] = {0.00000000, 0.00000000, 0.00000000, 0.00000000};
606
// Loop dofs and call evaluate_basis.
607
for (unsigned int r = 0; r < 4; r++)
609
evaluate_basis(r, dof_values, coordinates, c);
610
for (unsigned int s = 0; s < 4; s++)
612
values[r*4 + s] = dof_values[s];
613
}// end loop over 's'
614
}// end loop over 'r'
617
/// Evaluate order n derivatives of basis function i at given point in cell
618
virtual void evaluate_basis_derivatives(unsigned int i,
621
const double* coordinates,
622
const ufc::cell& c) const
624
// Extract vertex coordinates
625
const double * const * x = c.coordinates;
627
// Compute Jacobian of affine map from reference cell
628
const double J_00 = x[1][0] - x[0][0];
629
const double J_01 = x[2][0] - x[0][0];
630
const double J_10 = x[1][1] - x[0][1];
631
const double J_11 = x[2][1] - x[0][1];
633
// Compute determinant of Jacobian
634
double detJ = J_00*J_11 - J_01*J_10;
636
// Compute inverse of Jacobian
637
const double K_00 = J_11 / detJ;
638
const double K_01 = -J_01 / detJ;
639
const double K_10 = -J_10 / detJ;
640
const double K_11 = J_00 / detJ;
644
// Get coordinates and map to the reference (FIAT) element
646
// Compute number of derivatives.
647
unsigned int num_derivatives = 1;
649
for (unsigned int r = 0; r < n; r++)
651
num_derivatives *= 2;
652
}// end loop over 'r'
654
// Declare pointer to two dimensional array that holds combinations of derivatives and initialise
655
unsigned int **combinations = new unsigned int *[num_derivatives];
656
for (unsigned int row = 0; row < num_derivatives; row++)
658
combinations[row] = new unsigned int [n];
659
for (unsigned int col = 0; col < n; col++)
660
combinations[row][col] = 0;
663
// Generate combinations of derivatives
664
for (unsigned int row = 1; row < num_derivatives; row++)
666
for (unsigned int num = 0; num < row; num++)
668
for (unsigned int col = n-1; col+1 > 0; col--)
670
if (combinations[row][col] + 1 > 1)
671
combinations[row][col] = 0;
674
combinations[row][col] += 1;
681
// Compute inverse of Jacobian
682
const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
684
// Declare transformation matrix
685
// Declare pointer to two dimensional array and initialise
686
double **transform = new double *[num_derivatives];
688
for (unsigned int j = 0; j < num_derivatives; j++)
690
transform[j] = new double [num_derivatives];
691
for (unsigned int k = 0; k < num_derivatives; k++)
695
// Construct transformation matrix
696
for (unsigned int row = 0; row < num_derivatives; row++)
698
for (unsigned int col = 0; col < num_derivatives; col++)
700
for (unsigned int k = 0; k < n; k++)
701
transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
705
// Reset values. Assuming that values is always an array.
706
for (unsigned int r = 0; r < 4*num_derivatives; r++)
708
values[r] = 0.00000000;
709
}// end loop over 'r'
711
if (0 <= i && i <= 0)
713
// Map degree of freedom to element degree of freedom
714
const unsigned int dof = i;
716
// Array of basisvalues
717
double basisvalues[1] = {0.00000000};
719
// Declare helper variables
721
// Compute basisvalues
722
basisvalues[0] = 1.00000000;
724
// Table(s) of coefficients
725
static const double coefficients0[1][1] = \
728
// Tables of derivatives of the polynomial base (transpose).
729
static const double dmats0[1][1] = \
732
static const double dmats1[1][1] = \
735
// Compute reference derivatives
736
// Declare pointer to array of derivatives on FIAT element
737
double *derivatives = new double [num_derivatives];
738
for (unsigned int r = 0; r < num_derivatives; r++)
740
derivatives[r] = 0.00000000;
741
}// end loop over 'r'
743
// Declare derivative matrix (of polynomial basis).
744
double dmats[1][1] = \
747
// Declare (auxiliary) derivative matrix (of polynomial basis).
748
double dmats_old[1][1] = \
751
// Loop possible derivatives.
752
for (unsigned int r = 0; r < num_derivatives; r++)
754
// Resetting dmats values to compute next derivative.
755
for (unsigned int t = 0; t < 1; t++)
757
for (unsigned int u = 0; u < 1; u++)
759
dmats[t][u] = 0.00000000;
762
dmats[t][u] = 1.00000000;
765
}// end loop over 'u'
766
}// end loop over 't'
768
// Looping derivative order to generate dmats.
769
for (unsigned int s = 0; s < n; s++)
771
// Updating dmats_old with new values and resetting dmats.
772
for (unsigned int t = 0; t < 1; t++)
774
for (unsigned int u = 0; u < 1; u++)
776
dmats_old[t][u] = dmats[t][u];
777
dmats[t][u] = 0.00000000;
778
}// end loop over 'u'
779
}// end loop over 't'
781
// Update dmats using an inner product.
782
if (combinations[r][s] == 0)
784
for (unsigned int t = 0; t < 1; t++)
786
for (unsigned int u = 0; u < 1; u++)
788
for (unsigned int tu = 0; tu < 1; tu++)
790
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
791
}// end loop over 'tu'
792
}// end loop over 'u'
793
}// end loop over 't'
796
if (combinations[r][s] == 1)
798
for (unsigned int t = 0; t < 1; t++)
800
for (unsigned int u = 0; u < 1; u++)
802
for (unsigned int tu = 0; tu < 1; tu++)
804
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
805
}// end loop over 'tu'
806
}// end loop over 'u'
807
}// end loop over 't'
810
}// end loop over 's'
811
for (unsigned int s = 0; s < 1; s++)
813
for (unsigned int t = 0; t < 1; t++)
815
derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
816
}// end loop over 't'
817
}// end loop over 's'
818
}// end loop over 'r'
820
// Transform derivatives back to physical element
821
for (unsigned int row = 0; row < num_derivatives; row++)
823
for (unsigned int col = 0; col < num_derivatives; col++)
825
values[row] += transform[row][col]*derivatives[col];
829
// Delete pointer to array of derivatives on FIAT element
830
delete [] derivatives;
832
// Delete pointer to array of combinations of derivatives and transform
833
for (unsigned int r = 0; r < num_derivatives; r++)
835
delete [] combinations[r];
836
delete [] transform[r];
837
}// end loop over 'r'
838
delete [] combinations;
842
if (1 <= i && i <= 1)
844
// Map degree of freedom to element degree of freedom
845
const unsigned int dof = i - 1;
847
// Array of basisvalues
848
double basisvalues[1] = {0.00000000};
850
// Declare helper variables
852
// Compute basisvalues
853
basisvalues[0] = 1.00000000;
855
// Table(s) of coefficients
856
static const double coefficients0[1][1] = \
859
// Tables of derivatives of the polynomial base (transpose).
860
static const double dmats0[1][1] = \
863
static const double dmats1[1][1] = \
866
// Compute reference derivatives
867
// Declare pointer to array of derivatives on FIAT element
868
double *derivatives = new double [num_derivatives];
869
for (unsigned int r = 0; r < num_derivatives; r++)
871
derivatives[r] = 0.00000000;
872
}// end loop over 'r'
874
// Declare derivative matrix (of polynomial basis).
875
double dmats[1][1] = \
878
// Declare (auxiliary) derivative matrix (of polynomial basis).
879
double dmats_old[1][1] = \
882
// Loop possible derivatives.
883
for (unsigned int r = 0; r < num_derivatives; r++)
885
// Resetting dmats values to compute next derivative.
886
for (unsigned int t = 0; t < 1; t++)
888
for (unsigned int u = 0; u < 1; u++)
890
dmats[t][u] = 0.00000000;
893
dmats[t][u] = 1.00000000;
896
}// end loop over 'u'
897
}// end loop over 't'
899
// Looping derivative order to generate dmats.
900
for (unsigned int s = 0; s < n; s++)
902
// Updating dmats_old with new values and resetting dmats.
903
for (unsigned int t = 0; t < 1; t++)
905
for (unsigned int u = 0; u < 1; u++)
907
dmats_old[t][u] = dmats[t][u];
908
dmats[t][u] = 0.00000000;
909
}// end loop over 'u'
910
}// end loop over 't'
912
// Update dmats using an inner product.
913
if (combinations[r][s] == 0)
915
for (unsigned int t = 0; t < 1; t++)
917
for (unsigned int u = 0; u < 1; u++)
919
for (unsigned int tu = 0; tu < 1; tu++)
921
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
922
}// end loop over 'tu'
923
}// end loop over 'u'
924
}// end loop over 't'
927
if (combinations[r][s] == 1)
929
for (unsigned int t = 0; t < 1; t++)
931
for (unsigned int u = 0; u < 1; u++)
933
for (unsigned int tu = 0; tu < 1; tu++)
935
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
936
}// end loop over 'tu'
937
}// end loop over 'u'
938
}// end loop over 't'
941
}// end loop over 's'
942
for (unsigned int s = 0; s < 1; s++)
944
for (unsigned int t = 0; t < 1; t++)
946
derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
947
}// end loop over 't'
948
}// end loop over 's'
949
}// end loop over 'r'
951
// Transform derivatives back to physical element
952
for (unsigned int row = 0; row < num_derivatives; row++)
954
for (unsigned int col = 0; col < num_derivatives; col++)
956
values[num_derivatives + row] += transform[row][col]*derivatives[col];
960
// Delete pointer to array of derivatives on FIAT element
961
delete [] derivatives;
963
// Delete pointer to array of combinations of derivatives and transform
964
for (unsigned int r = 0; r < num_derivatives; r++)
966
delete [] combinations[r];
967
delete [] transform[r];
968
}// end loop over 'r'
969
delete [] combinations;
973
if (2 <= i && i <= 2)
975
// Map degree of freedom to element degree of freedom
976
const unsigned int dof = i - 2;
978
// Array of basisvalues
979
double basisvalues[1] = {0.00000000};
981
// Declare helper variables
983
// Compute basisvalues
984
basisvalues[0] = 1.00000000;
986
// Table(s) of coefficients
987
static const double coefficients0[1][1] = \
990
// Tables of derivatives of the polynomial base (transpose).
991
static const double dmats0[1][1] = \
994
static const double dmats1[1][1] = \
997
// Compute reference derivatives
998
// Declare pointer to array of derivatives on FIAT element
999
double *derivatives = new double [num_derivatives];
1000
for (unsigned int r = 0; r < num_derivatives; r++)
1002
derivatives[r] = 0.00000000;
1003
}// end loop over 'r'
1005
// Declare derivative matrix (of polynomial basis).
1006
double dmats[1][1] = \
1009
// Declare (auxiliary) derivative matrix (of polynomial basis).
1010
double dmats_old[1][1] = \
1013
// Loop possible derivatives.
1014
for (unsigned int r = 0; r < num_derivatives; r++)
1016
// Resetting dmats values to compute next derivative.
1017
for (unsigned int t = 0; t < 1; t++)
1019
for (unsigned int u = 0; u < 1; u++)
1021
dmats[t][u] = 0.00000000;
1024
dmats[t][u] = 1.00000000;
1027
}// end loop over 'u'
1028
}// end loop over 't'
1030
// Looping derivative order to generate dmats.
1031
for (unsigned int s = 0; s < n; s++)
1033
// Updating dmats_old with new values and resetting dmats.
1034
for (unsigned int t = 0; t < 1; t++)
1036
for (unsigned int u = 0; u < 1; u++)
1038
dmats_old[t][u] = dmats[t][u];
1039
dmats[t][u] = 0.00000000;
1040
}// end loop over 'u'
1041
}// end loop over 't'
1043
// Update dmats using an inner product.
1044
if (combinations[r][s] == 0)
1046
for (unsigned int t = 0; t < 1; t++)
1048
for (unsigned int u = 0; u < 1; u++)
1050
for (unsigned int tu = 0; tu < 1; tu++)
1052
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
1053
}// end loop over 'tu'
1054
}// end loop over 'u'
1055
}// end loop over 't'
1058
if (combinations[r][s] == 1)
1060
for (unsigned int t = 0; t < 1; t++)
1062
for (unsigned int u = 0; u < 1; u++)
1064
for (unsigned int tu = 0; tu < 1; tu++)
1066
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
1067
}// end loop over 'tu'
1068
}// end loop over 'u'
1069
}// end loop over 't'
1072
}// end loop over 's'
1073
for (unsigned int s = 0; s < 1; s++)
1075
for (unsigned int t = 0; t < 1; t++)
1077
derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
1078
}// end loop over 't'
1079
}// end loop over 's'
1080
}// end loop over 'r'
1082
// Transform derivatives back to physical element
1083
for (unsigned int row = 0; row < num_derivatives; row++)
1085
for (unsigned int col = 0; col < num_derivatives; col++)
1087
values[2*num_derivatives + row] += transform[row][col]*derivatives[col];
1091
// Delete pointer to array of derivatives on FIAT element
1092
delete [] derivatives;
1094
// Delete pointer to array of combinations of derivatives and transform
1095
for (unsigned int r = 0; r < num_derivatives; r++)
1097
delete [] combinations[r];
1098
delete [] transform[r];
1099
}// end loop over 'r'
1100
delete [] combinations;
1101
delete [] transform;
1104
if (3 <= i && i <= 3)
1106
// Map degree of freedom to element degree of freedom
1107
const unsigned int dof = i - 3;
1109
// Array of basisvalues
1110
double basisvalues[1] = {0.00000000};
1112
// Declare helper variables
1114
// Compute basisvalues
1115
basisvalues[0] = 1.00000000;
1117
// Table(s) of coefficients
1118
static const double coefficients0[1][1] = \
1121
// Tables of derivatives of the polynomial base (transpose).
1122
static const double dmats0[1][1] = \
1125
static const double dmats1[1][1] = \
1128
// Compute reference derivatives
1129
// Declare pointer to array of derivatives on FIAT element
1130
double *derivatives = new double [num_derivatives];
1131
for (unsigned int r = 0; r < num_derivatives; r++)
1133
derivatives[r] = 0.00000000;
1134
}// end loop over 'r'
1136
// Declare derivative matrix (of polynomial basis).
1137
double dmats[1][1] = \
1140
// Declare (auxiliary) derivative matrix (of polynomial basis).
1141
double dmats_old[1][1] = \
1144
// Loop possible derivatives.
1145
for (unsigned int r = 0; r < num_derivatives; r++)
1147
// Resetting dmats values to compute next derivative.
1148
for (unsigned int t = 0; t < 1; t++)
1150
for (unsigned int u = 0; u < 1; u++)
1152
dmats[t][u] = 0.00000000;
1155
dmats[t][u] = 1.00000000;
1158
}// end loop over 'u'
1159
}// end loop over 't'
1161
// Looping derivative order to generate dmats.
1162
for (unsigned int s = 0; s < n; s++)
1164
// Updating dmats_old with new values and resetting dmats.
1165
for (unsigned int t = 0; t < 1; t++)
1167
for (unsigned int u = 0; u < 1; u++)
1169
dmats_old[t][u] = dmats[t][u];
1170
dmats[t][u] = 0.00000000;
1171
}// end loop over 'u'
1172
}// end loop over 't'
1174
// Update dmats using an inner product.
1175
if (combinations[r][s] == 0)
1177
for (unsigned int t = 0; t < 1; t++)
1179
for (unsigned int u = 0; u < 1; u++)
1181
for (unsigned int tu = 0; tu < 1; tu++)
1183
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
1184
}// end loop over 'tu'
1185
}// end loop over 'u'
1186
}// end loop over 't'
1189
if (combinations[r][s] == 1)
1191
for (unsigned int t = 0; t < 1; t++)
1193
for (unsigned int u = 0; u < 1; u++)
1195
for (unsigned int tu = 0; tu < 1; tu++)
1197
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
1198
}// end loop over 'tu'
1199
}// end loop over 'u'
1200
}// end loop over 't'
1203
}// end loop over 's'
1204
for (unsigned int s = 0; s < 1; s++)
1206
for (unsigned int t = 0; t < 1; t++)
1208
derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
1209
}// end loop over 't'
1210
}// end loop over 's'
1211
}// end loop over 'r'
1213
// Transform derivatives back to physical element
1214
for (unsigned int row = 0; row < num_derivatives; row++)
1216
for (unsigned int col = 0; col < num_derivatives; col++)
1218
values[3*num_derivatives + row] += transform[row][col]*derivatives[col];
1222
// Delete pointer to array of derivatives on FIAT element
1223
delete [] derivatives;
1225
// Delete pointer to array of combinations of derivatives and transform
1226
for (unsigned int r = 0; r < num_derivatives; r++)
1228
delete [] combinations[r];
1229
delete [] transform[r];
1230
}// end loop over 'r'
1231
delete [] combinations;
1232
delete [] transform;
1237
/// Evaluate order n derivatives of all basis functions at given point in cell
1238
virtual void evaluate_basis_derivatives_all(unsigned int n,
1240
const double* coordinates,
1241
const ufc::cell& c) const
1243
// Compute number of derivatives.
1244
unsigned int num_derivatives = 1;
1246
for (unsigned int r = 0; r < n; r++)
1248
num_derivatives *= 2;
1249
}// end loop over 'r'
1251
// Helper variable to hold values of a single dof.
1252
double *dof_values = new double [4*num_derivatives];
1253
for (unsigned int r = 0; r < 4*num_derivatives; r++)
1255
dof_values[r] = 0.00000000;
1256
}// end loop over 'r'
1258
// Loop dofs and call evaluate_basis_derivatives.
1259
for (unsigned int r = 0; r < 4; r++)
1261
evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
1262
for (unsigned int s = 0; s < 4*num_derivatives; s++)
1264
values[r*4*num_derivatives + s] = dof_values[s];
1265
}// end loop over 's'
1266
}// end loop over 'r'
1269
delete [] dof_values;
1272
/// Evaluate linear functional for dof i on the function f
1273
virtual double evaluate_dof(unsigned int i,
1274
const ufc::function& f,
1275
const ufc::cell& c) const
1277
// Declare variables for result of evaluation
1280
// Declare variable for physical coordinates
1283
const double * const * x = c.coordinates;
1288
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1289
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1290
f.evaluate(vals, y, c);
1296
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1297
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1298
f.evaluate(vals, y, c);
1304
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1305
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1306
f.evaluate(vals, y, c);
1312
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1313
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1314
f.evaluate(vals, y, c);
1323
/// Evaluate linear functionals for all dofs on the function f
1324
virtual void evaluate_dofs(double* values,
1325
const ufc::function& f,
1326
const ufc::cell& c) const
1328
// Declare variables for result of evaluation
1331
// Declare variable for physical coordinates
1334
const double * const * x = c.coordinates;
1335
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1336
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1337
f.evaluate(vals, y, c);
1338
values[0] = vals[0];
1339
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1340
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1341
f.evaluate(vals, y, c);
1342
values[1] = vals[1];
1343
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1344
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1345
f.evaluate(vals, y, c);
1346
values[2] = vals[2];
1347
y[0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
1348
y[1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
1349
f.evaluate(vals, y, c);
1350
values[3] = vals[3];
1353
/// Interpolate vertex values from dof values
1354
virtual void interpolate_vertex_values(double* vertex_values,
1355
const double* dof_values,
1356
const ufc::cell& c) const
1358
// Evaluate function and change variables
1359
vertex_values[0] = dof_values[0];
1360
vertex_values[4] = dof_values[0];
1361
vertex_values[8] = dof_values[0];
1362
// Evaluate function and change variables
1363
vertex_values[1] = dof_values[1];
1364
vertex_values[5] = dof_values[1];
1365
vertex_values[9] = dof_values[1];
1366
// Evaluate function and change variables
1367
vertex_values[2] = dof_values[2];
1368
vertex_values[6] = dof_values[2];
1369
vertex_values[10] = dof_values[2];
1370
// Evaluate function and change variables
1371
vertex_values[3] = dof_values[3];
1372
vertex_values[7] = dof_values[3];
1373
vertex_values[11] = dof_values[3];
1376
/// Return the number of sub elements (for a mixed element)
1377
virtual unsigned int num_sub_elements() const
1382
/// Create a new finite element for sub element i (for a mixed element)
1383
virtual ufc::finite_element* create_sub_element(unsigned int i) const
1389
return new tensorweightedpoisson_finite_element_0();
1394
return new tensorweightedpoisson_finite_element_0();
1399
return new tensorweightedpoisson_finite_element_0();
1404
return new tensorweightedpoisson_finite_element_0();
1414
/// This class defines the interface for a finite element.
1416
class tensorweightedpoisson_finite_element_2: public ufc::finite_element
1421
tensorweightedpoisson_finite_element_2() : ufc::finite_element()
1427
virtual ~tensorweightedpoisson_finite_element_2()
1432
/// Return a string identifying the finite element
1433
virtual const char* signature() const
1435
return "FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1)";
1438
/// Return the cell shape
1439
virtual ufc::shape cell_shape() const
1441
return ufc::triangle;
1444
/// Return the dimension of the finite element function space
1445
virtual unsigned int space_dimension() const
1450
/// Return the rank of the value space
1451
virtual unsigned int value_rank() const
1456
/// Return the dimension of the value space for axis i
1457
virtual unsigned int value_dimension(unsigned int i) const
1462
/// Evaluate basis function i at given point in cell
1463
virtual void evaluate_basis(unsigned int i,
1465
const double* coordinates,
1466
const ufc::cell& c) const
1468
// Extract vertex coordinates
1469
const double * const * x = c.coordinates;
1471
// Compute Jacobian of affine map from reference cell
1472
const double J_00 = x[1][0] - x[0][0];
1473
const double J_01 = x[2][0] - x[0][0];
1474
const double J_10 = x[1][1] - x[0][1];
1475
const double J_11 = x[2][1] - x[0][1];
1477
// Compute determinant of Jacobian
1478
double detJ = J_00*J_11 - J_01*J_10;
1480
// Compute inverse of Jacobian
1482
// Compute constants
1483
const double C0 = x[1][0] + x[2][0];
1484
const double C1 = x[1][1] + x[2][1];
1486
// Get coordinates and map to the reference (FIAT) element
1487
double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
1488
double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
1491
*values = 0.00000000;
1493
// Map degree of freedom to element degree of freedom
1494
const unsigned int dof = i;
1496
// Array of basisvalues
1497
double basisvalues[3] = {0.00000000, 0.00000000, 0.00000000};
1499
// Declare helper variables
1500
unsigned int rr = 0;
1501
unsigned int ss = 0;
1502
double tmp0 = (1.00000000 + Y + 2.00000000*X)/2.00000000;
1504
// Compute basisvalues
1505
basisvalues[0] = 1.00000000;
1506
basisvalues[1] = tmp0;
1507
for (unsigned int r = 0; r < 1; r++)
1509
rr = (r + 1)*(r + 1 + 1)/2 + 1;
1511
basisvalues[rr] = basisvalues[ss]*(0.50000000 + r + Y*(1.50000000 + r));
1512
}// end loop over 'r'
1513
for (unsigned int r = 0; r < 2; r++)
1515
for (unsigned int s = 0; s < 2 - r; s++)
1517
rr = (r + s)*(r + s + 1)/2 + s;
1518
basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s));
1519
}// end loop over 's'
1520
}// end loop over 'r'
1522
// Table(s) of coefficients
1523
static const double coefficients0[3][3] = \
1524
{{0.47140452, -0.28867513, -0.16666667},
1525
{0.47140452, 0.28867513, -0.16666667},
1526
{0.47140452, 0.00000000, 0.33333333}};
1528
// Compute value(s).
1529
for (unsigned int r = 0; r < 3; r++)
1531
*values += coefficients0[dof][r]*basisvalues[r];
1532
}// end loop over 'r'
1535
/// Evaluate all basis functions at given point in cell
1536
virtual void evaluate_basis_all(double* values,
1537
const double* coordinates,
1538
const ufc::cell& c) const
1540
// Helper variable to hold values of a single dof.
1541
double dof_values = 0.00000000;
1543
// Loop dofs and call evaluate_basis.
1544
for (unsigned int r = 0; r < 3; r++)
1546
evaluate_basis(r, &dof_values, coordinates, c);
1547
values[r] = dof_values;
1548
}// end loop over 'r'
1551
/// Evaluate order n derivatives of basis function i at given point in cell
1552
virtual void evaluate_basis_derivatives(unsigned int i,
1555
const double* coordinates,
1556
const ufc::cell& c) const
1558
// Extract vertex coordinates
1559
const double * const * x = c.coordinates;
1561
// Compute Jacobian of affine map from reference cell
1562
const double J_00 = x[1][0] - x[0][0];
1563
const double J_01 = x[2][0] - x[0][0];
1564
const double J_10 = x[1][1] - x[0][1];
1565
const double J_11 = x[2][1] - x[0][1];
1567
// Compute determinant of Jacobian
1568
double detJ = J_00*J_11 - J_01*J_10;
1570
// Compute inverse of Jacobian
1571
const double K_00 = J_11 / detJ;
1572
const double K_01 = -J_01 / detJ;
1573
const double K_10 = -J_10 / detJ;
1574
const double K_11 = J_00 / detJ;
1576
// Compute constants
1577
const double C0 = x[1][0] + x[2][0];
1578
const double C1 = x[1][1] + x[2][1];
1580
// Get coordinates and map to the reference (FIAT) element
1581
double X = (J_01*(C1 - 2.0*coordinates[1]) + J_11*(2.0*coordinates[0] - C0)) / detJ;
1582
double Y = (J_00*(2.0*coordinates[1] - C1) + J_10*(C0 - 2.0*coordinates[0])) / detJ;
1584
// Compute number of derivatives.
1585
unsigned int num_derivatives = 1;
1587
for (unsigned int r = 0; r < n; r++)
1589
num_derivatives *= 2;
1590
}// end loop over 'r'
1592
// Declare pointer to two dimensional array that holds combinations of derivatives and initialise
1593
unsigned int **combinations = new unsigned int *[num_derivatives];
1594
for (unsigned int row = 0; row < num_derivatives; row++)
1596
combinations[row] = new unsigned int [n];
1597
for (unsigned int col = 0; col < n; col++)
1598
combinations[row][col] = 0;
1601
// Generate combinations of derivatives
1602
for (unsigned int row = 1; row < num_derivatives; row++)
1604
for (unsigned int num = 0; num < row; num++)
1606
for (unsigned int col = n-1; col+1 > 0; col--)
1608
if (combinations[row][col] + 1 > 1)
1609
combinations[row][col] = 0;
1612
combinations[row][col] += 1;
1619
// Compute inverse of Jacobian
1620
const double Jinv[2][2] = {{K_00, K_01}, {K_10, K_11}};
1622
// Declare transformation matrix
1623
// Declare pointer to two dimensional array and initialise
1624
double **transform = new double *[num_derivatives];
1626
for (unsigned int j = 0; j < num_derivatives; j++)
1628
transform[j] = new double [num_derivatives];
1629
for (unsigned int k = 0; k < num_derivatives; k++)
1630
transform[j][k] = 1;
1633
// Construct transformation matrix
1634
for (unsigned int row = 0; row < num_derivatives; row++)
1636
for (unsigned int col = 0; col < num_derivatives; col++)
1638
for (unsigned int k = 0; k < n; k++)
1639
transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
1643
// Reset values. Assuming that values is always an array.
1644
for (unsigned int r = 0; r < num_derivatives; r++)
1646
values[r] = 0.00000000;
1647
}// end loop over 'r'
1649
// Map degree of freedom to element degree of freedom
1650
const unsigned int dof = i;
1652
// Array of basisvalues
1653
double basisvalues[3] = {0.00000000, 0.00000000, 0.00000000};
1655
// Declare helper variables
1656
unsigned int rr = 0;
1657
unsigned int ss = 0;
1658
double tmp0 = (1.00000000 + Y + 2.00000000*X)/2.00000000;
1660
// Compute basisvalues
1661
basisvalues[0] = 1.00000000;
1662
basisvalues[1] = tmp0;
1663
for (unsigned int r = 0; r < 1; r++)
1665
rr = (r + 1)*(r + 1 + 1)/2 + 1;
1667
basisvalues[rr] = basisvalues[ss]*(0.50000000 + r + Y*(1.50000000 + r));
1668
}// end loop over 'r'
1669
for (unsigned int r = 0; r < 2; r++)
1671
for (unsigned int s = 0; s < 2 - r; s++)
1673
rr = (r + s)*(r + s + 1)/2 + s;
1674
basisvalues[rr] *= std::sqrt((0.50000000 + r)*(1.00000000 + r + s));
1675
}// end loop over 's'
1676
}// end loop over 'r'
1678
// Table(s) of coefficients
1679
static const double coefficients0[3][3] = \
1680
{{0.47140452, -0.28867513, -0.16666667},
1681
{0.47140452, 0.28867513, -0.16666667},
1682
{0.47140452, 0.00000000, 0.33333333}};
1684
// Tables of derivatives of the polynomial base (transpose).
1685
static const double dmats0[3][3] = \
1686
{{0.00000000, 0.00000000, 0.00000000},
1687
{4.89897949, 0.00000000, 0.00000000},
1688
{0.00000000, 0.00000000, 0.00000000}};
1690
static const double dmats1[3][3] = \
1691
{{0.00000000, 0.00000000, 0.00000000},
1692
{2.44948974, 0.00000000, 0.00000000},
1693
{4.24264069, 0.00000000, 0.00000000}};
1695
// Compute reference derivatives
1696
// Declare pointer to array of derivatives on FIAT element
1697
double *derivatives = new double [num_derivatives];
1698
for (unsigned int r = 0; r < num_derivatives; r++)
1700
derivatives[r] = 0.00000000;
1701
}// end loop over 'r'
1703
// Declare derivative matrix (of polynomial basis).
1704
double dmats[3][3] = \
1705
{{1.00000000, 0.00000000, 0.00000000},
1706
{0.00000000, 1.00000000, 0.00000000},
1707
{0.00000000, 0.00000000, 1.00000000}};
1709
// Declare (auxiliary) derivative matrix (of polynomial basis).
1710
double dmats_old[3][3] = \
1711
{{1.00000000, 0.00000000, 0.00000000},
1712
{0.00000000, 1.00000000, 0.00000000},
1713
{0.00000000, 0.00000000, 1.00000000}};
1715
// Loop possible derivatives.
1716
for (unsigned int r = 0; r < num_derivatives; r++)
1718
// Resetting dmats values to compute next derivative.
1719
for (unsigned int t = 0; t < 3; t++)
1721
for (unsigned int u = 0; u < 3; u++)
1723
dmats[t][u] = 0.00000000;
1726
dmats[t][u] = 1.00000000;
1729
}// end loop over 'u'
1730
}// end loop over 't'
1732
// Looping derivative order to generate dmats.
1733
for (unsigned int s = 0; s < n; s++)
1735
// Updating dmats_old with new values and resetting dmats.
1736
for (unsigned int t = 0; t < 3; t++)
1738
for (unsigned int u = 0; u < 3; u++)
1740
dmats_old[t][u] = dmats[t][u];
1741
dmats[t][u] = 0.00000000;
1742
}// end loop over 'u'
1743
}// end loop over 't'
1745
// Update dmats using an inner product.
1746
if (combinations[r][s] == 0)
1748
for (unsigned int t = 0; t < 3; t++)
1750
for (unsigned int u = 0; u < 3; u++)
1752
for (unsigned int tu = 0; tu < 3; tu++)
1754
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
1755
}// end loop over 'tu'
1756
}// end loop over 'u'
1757
}// end loop over 't'
1760
if (combinations[r][s] == 1)
1762
for (unsigned int t = 0; t < 3; t++)
1764
for (unsigned int u = 0; u < 3; u++)
1766
for (unsigned int tu = 0; tu < 3; tu++)
1768
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
1769
}// end loop over 'tu'
1770
}// end loop over 'u'
1771
}// end loop over 't'
1774
}// end loop over 's'
1775
for (unsigned int s = 0; s < 3; s++)
1777
for (unsigned int t = 0; t < 3; t++)
1779
derivatives[r] += coefficients0[dof][s]*dmats[s][t]*basisvalues[t];
1780
}// end loop over 't'
1781
}// end loop over 's'
1782
}// end loop over 'r'
1784
// Transform derivatives back to physical element
1785
for (unsigned int row = 0; row < num_derivatives; row++)
1787
for (unsigned int col = 0; col < num_derivatives; col++)
1789
values[row] += transform[row][col]*derivatives[col];
1793
// Delete pointer to array of derivatives on FIAT element
1794
delete [] derivatives;
1796
// Delete pointer to array of combinations of derivatives and transform
1797
for (unsigned int r = 0; r < num_derivatives; r++)
1799
delete [] combinations[r];
1800
delete [] transform[r];
1801
}// end loop over 'r'
1802
delete [] combinations;
1803
delete [] transform;
1806
/// Evaluate order n derivatives of all basis functions at given point in cell
1807
virtual void evaluate_basis_derivatives_all(unsigned int n,
1809
const double* coordinates,
1810
const ufc::cell& c) const
1812
// Compute number of derivatives.
1813
unsigned int num_derivatives = 1;
1815
for (unsigned int r = 0; r < n; r++)
1817
num_derivatives *= 2;
1818
}// end loop over 'r'
1820
// Helper variable to hold values of a single dof.
1821
double *dof_values = new double [num_derivatives];
1822
for (unsigned int r = 0; r < num_derivatives; r++)
1824
dof_values[r] = 0.00000000;
1825
}// end loop over 'r'
1827
// Loop dofs and call evaluate_basis_derivatives.
1828
for (unsigned int r = 0; r < 3; r++)
1830
evaluate_basis_derivatives(r, n, dof_values, coordinates, c);
1831
for (unsigned int s = 0; s < num_derivatives; s++)
1833
values[r*num_derivatives + s] = dof_values[s];
1834
}// end loop over 's'
1835
}// end loop over 'r'
1838
delete [] dof_values;
1841
/// Evaluate linear functional for dof i on the function f
1842
virtual double evaluate_dof(unsigned int i,
1843
const ufc::function& f,
1844
const ufc::cell& c) const
1846
// Declare variables for result of evaluation
1849
// Declare variable for physical coordinates
1852
const double * const * x = c.coordinates;
1859
f.evaluate(vals, y, c);
1867
f.evaluate(vals, y, c);
1875
f.evaluate(vals, y, c);
1884
/// Evaluate linear functionals for all dofs on the function f
1885
virtual void evaluate_dofs(double* values,
1886
const ufc::function& f,
1887
const ufc::cell& c) const
1889
// Declare variables for result of evaluation
1892
// Declare variable for physical coordinates
1895
const double * const * x = c.coordinates;
1898
f.evaluate(vals, y, c);
1899
values[0] = vals[0];
1902
f.evaluate(vals, y, c);
1903
values[1] = vals[0];
1906
f.evaluate(vals, y, c);
1907
values[2] = vals[0];
1910
/// Interpolate vertex values from dof values
1911
virtual void interpolate_vertex_values(double* vertex_values,
1912
const double* dof_values,
1913
const ufc::cell& c) const
1915
// Evaluate function and change variables
1916
vertex_values[0] = dof_values[0];
1917
vertex_values[1] = dof_values[1];
1918
vertex_values[2] = dof_values[2];
1921
/// Return the number of sub elements (for a mixed element)
1922
virtual unsigned int num_sub_elements() const
1927
/// Create a new finite element for sub element i (for a mixed element)
1928
virtual ufc::finite_element* create_sub_element(unsigned int i) const
1935
/// This class defines the interface for a local-to-global mapping of
1936
/// degrees of freedom (dofs).
1938
class tensorweightedpoisson_dof_map_0: public ufc::dof_map
1942
unsigned int _global_dimension;
1947
tensorweightedpoisson_dof_map_0() : ufc::dof_map()
1949
_global_dimension = 0;
1953
virtual ~tensorweightedpoisson_dof_map_0()
1958
/// Return a string identifying the dof map
1959
virtual const char* signature() const
1961
return "FFC dofmap for FiniteElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0)";
1964
/// Return true iff mesh entities of topological dimension d are needed
1965
virtual bool needs_mesh_entities(unsigned int d) const
1989
/// Initialize dof map for mesh (return true iff init_cell() is needed)
1990
virtual bool init_mesh(const ufc::mesh& m)
1992
_global_dimension = m.num_entities[2];
1996
/// Initialize dof map for given cell
1997
virtual void init_cell(const ufc::mesh& m,
2003
/// Finish initialization of dof map for cells
2004
virtual void init_cell_finalize()
2009
/// Return the dimension of the global finite element function space
2010
virtual unsigned int global_dimension() const
2012
return _global_dimension;
2015
/// Return the dimension of the local finite element function space for a cell
2016
virtual unsigned int local_dimension(const ufc::cell& c) const
2021
/// Return the maximum dimension of the local finite element function space
2022
virtual unsigned int max_local_dimension() const
2027
// Return the geometric dimension of the coordinates this dof map provides
2028
virtual unsigned int geometric_dimension() const
2033
/// Return the number of dofs on each cell facet
2034
virtual unsigned int num_facet_dofs() const
2039
/// Return the number of dofs associated with each cell entity of dimension d
2040
virtual unsigned int num_entity_dofs(unsigned int d) const
2064
/// Tabulate the local-to-global mapping of dofs on a cell
2065
virtual void tabulate_dofs(unsigned int* dofs,
2067
const ufc::cell& c) const
2069
dofs[0] = c.entity_indices[2][0];
2072
/// Tabulate the local-to-local mapping from facet dofs to cell dofs
2073
virtual void tabulate_facet_dofs(unsigned int* dofs,
2074
unsigned int facet) const
2097
/// Tabulate the local-to-local mapping of dofs on entity (d, i)
2098
virtual void tabulate_entity_dofs(unsigned int* dofs,
2099
unsigned int d, unsigned int i) const
2103
std::cerr << "*** FFC warning: " << "d is larger than dimension (2)" << std::endl;
2122
std::cerr << "*** FFC warning: " << "i is larger than number of entities (0)" << std::endl;
2132
/// Tabulate the coordinates of all dofs on a cell
2133
virtual void tabulate_coordinates(double** coordinates,
2134
const ufc::cell& c) const
2136
const double * const * x = c.coordinates;
2138
coordinates[0][0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
2139
coordinates[0][1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
2142
/// Return the number of sub dof maps (for a mixed element)
2143
virtual unsigned int num_sub_dof_maps() const
2148
/// Create a new dof_map for sub dof map i (for a mixed element)
2149
virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
2156
/// This class defines the interface for a local-to-global mapping of
2157
/// degrees of freedom (dofs).
2159
class tensorweightedpoisson_dof_map_1: public ufc::dof_map
2163
unsigned int _global_dimension;
2168
tensorweightedpoisson_dof_map_1() : ufc::dof_map()
2170
_global_dimension = 0;
2174
virtual ~tensorweightedpoisson_dof_map_1()
2179
/// Return a string identifying the dof map
2180
virtual const char* signature() const
2182
return "FFC dofmap for TensorElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0, (2, 2), None)";
2185
/// Return true iff mesh entities of topological dimension d are needed
2186
virtual bool needs_mesh_entities(unsigned int d) const
2210
/// Initialize dof map for mesh (return true iff init_cell() is needed)
2211
virtual bool init_mesh(const ufc::mesh& m)
2213
_global_dimension = 4*m.num_entities[2];
2217
/// Initialize dof map for given cell
2218
virtual void init_cell(const ufc::mesh& m,
2224
/// Finish initialization of dof map for cells
2225
virtual void init_cell_finalize()
2230
/// Return the dimension of the global finite element function space
2231
virtual unsigned int global_dimension() const
2233
return _global_dimension;
2236
/// Return the dimension of the local finite element function space for a cell
2237
virtual unsigned int local_dimension(const ufc::cell& c) const
2242
/// Return the maximum dimension of the local finite element function space
2243
virtual unsigned int max_local_dimension() const
2248
// Return the geometric dimension of the coordinates this dof map provides
2249
virtual unsigned int geometric_dimension() const
2254
/// Return the number of dofs on each cell facet
2255
virtual unsigned int num_facet_dofs() const
2260
/// Return the number of dofs associated with each cell entity of dimension d
2261
virtual unsigned int num_entity_dofs(unsigned int d) const
2285
/// Tabulate the local-to-global mapping of dofs on a cell
2286
virtual void tabulate_dofs(unsigned int* dofs,
2288
const ufc::cell& c) const
2290
unsigned int offset = 0;
2292
dofs[0] = offset + c.entity_indices[2][0];
2293
offset += m.num_entities[2];
2294
dofs[1] = offset + c.entity_indices[2][0];
2295
offset += m.num_entities[2];
2296
dofs[2] = offset + c.entity_indices[2][0];
2297
offset += m.num_entities[2];
2298
dofs[3] = offset + c.entity_indices[2][0];
2299
offset += m.num_entities[2];
2302
/// Tabulate the local-to-local mapping from facet dofs to cell dofs
2303
virtual void tabulate_facet_dofs(unsigned int* dofs,
2304
unsigned int facet) const
2327
/// Tabulate the local-to-local mapping of dofs on entity (d, i)
2328
virtual void tabulate_entity_dofs(unsigned int* dofs,
2329
unsigned int d, unsigned int i) const
2333
std::cerr << "*** FFC warning: " << "d is larger than dimension (2)" << std::endl;
2352
std::cerr << "*** FFC warning: " << "i is larger than number of entities (0)" << std::endl;
2365
/// Tabulate the coordinates of all dofs on a cell
2366
virtual void tabulate_coordinates(double** coordinates,
2367
const ufc::cell& c) const
2369
const double * const * x = c.coordinates;
2371
coordinates[0][0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
2372
coordinates[0][1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
2373
coordinates[1][0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
2374
coordinates[1][1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
2375
coordinates[2][0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
2376
coordinates[2][1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
2377
coordinates[3][0] = 0.333333333333*x[0][0] + 0.333333333333*x[1][0] + 0.333333333333*x[2][0];
2378
coordinates[3][1] = 0.333333333333*x[0][1] + 0.333333333333*x[1][1] + 0.333333333333*x[2][1];
2381
/// Return the number of sub dof maps (for a mixed element)
2382
virtual unsigned int num_sub_dof_maps() const
2387
/// Create a new dof_map for sub dof map i (for a mixed element)
2388
virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
2394
return new tensorweightedpoisson_dof_map_0();
2399
return new tensorweightedpoisson_dof_map_0();
2404
return new tensorweightedpoisson_dof_map_0();
2409
return new tensorweightedpoisson_dof_map_0();
2419
/// This class defines the interface for a local-to-global mapping of
2420
/// degrees of freedom (dofs).
2422
class tensorweightedpoisson_dof_map_2: public ufc::dof_map
2426
unsigned int _global_dimension;
2431
tensorweightedpoisson_dof_map_2() : ufc::dof_map()
2433
_global_dimension = 0;
2437
virtual ~tensorweightedpoisson_dof_map_2()
2442
/// Return a string identifying the dof map
2443
virtual const char* signature() const
2445
return "FFC dofmap for FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1)";
2448
/// Return true iff mesh entities of topological dimension d are needed
2449
virtual bool needs_mesh_entities(unsigned int d) const
2473
/// Initialize dof map for mesh (return true iff init_cell() is needed)
2474
virtual bool init_mesh(const ufc::mesh& m)
2476
_global_dimension = m.num_entities[0];
2480
/// Initialize dof map for given cell
2481
virtual void init_cell(const ufc::mesh& m,
2487
/// Finish initialization of dof map for cells
2488
virtual void init_cell_finalize()
2493
/// Return the dimension of the global finite element function space
2494
virtual unsigned int global_dimension() const
2496
return _global_dimension;
2499
/// Return the dimension of the local finite element function space for a cell
2500
virtual unsigned int local_dimension(const ufc::cell& c) const
2505
/// Return the maximum dimension of the local finite element function space
2506
virtual unsigned int max_local_dimension() const
2511
// Return the geometric dimension of the coordinates this dof map provides
2512
virtual unsigned int geometric_dimension() const
2517
/// Return the number of dofs on each cell facet
2518
virtual unsigned int num_facet_dofs() const
2523
/// Return the number of dofs associated with each cell entity of dimension d
2524
virtual unsigned int num_entity_dofs(unsigned int d) const
2548
/// Tabulate the local-to-global mapping of dofs on a cell
2549
virtual void tabulate_dofs(unsigned int* dofs,
2551
const ufc::cell& c) const
2553
dofs[0] = c.entity_indices[0][0];
2554
dofs[1] = c.entity_indices[0][1];
2555
dofs[2] = c.entity_indices[0][2];
2558
/// Tabulate the local-to-local mapping from facet dofs to cell dofs
2559
virtual void tabulate_facet_dofs(unsigned int* dofs,
2560
unsigned int facet) const
2586
/// Tabulate the local-to-local mapping of dofs on entity (d, i)
2587
virtual void tabulate_entity_dofs(unsigned int* dofs,
2588
unsigned int d, unsigned int i) const
2592
std::cerr << "*** FFC warning: " << "d is larger than dimension (2)" << std::endl;
2601
std::cerr << "*** FFC warning: " << "i is larger than number of entities (2)" << std::endl;
2639
/// Tabulate the coordinates of all dofs on a cell
2640
virtual void tabulate_coordinates(double** coordinates,
2641
const ufc::cell& c) const
2643
const double * const * x = c.coordinates;
2645
coordinates[0][0] = x[0][0];
2646
coordinates[0][1] = x[0][1];
2647
coordinates[1][0] = x[1][0];
2648
coordinates[1][1] = x[1][1];
2649
coordinates[2][0] = x[2][0];
2650
coordinates[2][1] = x[2][1];
2653
/// Return the number of sub dof maps (for a mixed element)
2654
virtual unsigned int num_sub_dof_maps() const
2659
/// Create a new dof_map for sub dof map i (for a mixed element)
2660
virtual ufc::dof_map* create_sub_dof_map(unsigned int i) const
2667
/// This class defines the interface for the tabulation of the cell
2668
/// tensor corresponding to the local contribution to a form from
2669
/// the integral over a cell.
2671
class tensorweightedpoisson_cell_integral_0_0: public ufc::cell_integral
2676
tensorweightedpoisson_cell_integral_0_0() : ufc::cell_integral()
2682
virtual ~tensorweightedpoisson_cell_integral_0_0()
2687
/// Tabulate the tensor for the contribution from a local cell
2688
virtual void tabulate_tensor(double* A,
2689
const double * const * w,
2690
const ufc::cell& c) const
2692
// Extract vertex coordinates
2693
const double * const * x = c.coordinates;
2695
// Compute Jacobian of affine map from reference cell
2696
const double J_00 = x[1][0] - x[0][0];
2697
const double J_01 = x[2][0] - x[0][0];
2698
const double J_10 = x[1][1] - x[0][1];
2699
const double J_11 = x[2][1] - x[0][1];
2701
// Compute determinant of Jacobian
2702
double detJ = J_00*J_11 - J_01*J_10;
2704
// Compute inverse of Jacobian
2705
const double K_00 = J_11 / detJ;
2706
const double K_01 = -J_01 / detJ;
2707
const double K_10 = -J_10 / detJ;
2708
const double K_11 = J_00 / detJ;
2711
const double det = std::abs(detJ);
2713
// Array of quadrature weights
2714
static const double W1 = 0.50000000;
2715
// Quadrature points on the UFC reference element: (0.33333333, 0.33333333)
2717
// Value of basis functions at quadrature points.
2718
static const double FE0_D01[1][3] = \
2719
{{-1.00000000, 0.00000000, 1.00000000}};
2721
static const double FE0_D10[1][3] = \
2722
{{-1.00000000, 1.00000000, 0.00000000}};
2724
static const double FE1_C0[1][4] = \
2725
{{1.00000000, 0.00000000, 0.00000000, 0.00000000}};
2727
static const double FE1_C1[1][4] = \
2728
{{0.00000000, 1.00000000, 0.00000000, 0.00000000}};
2730
static const double FE1_C2[1][4] = \
2731
{{0.00000000, 0.00000000, 1.00000000, 0.00000000}};
2733
static const double FE1_C3[1][4] = \
2734
{{0.00000000, 0.00000000, 0.00000000, 1.00000000}};
2736
for (unsigned int r = 0; r < 9; r++)
2739
}// end loop over 'r'
2741
// Compute element tensor using UFL quadrature representation
2742
// Optimisations: ('simplify expressions', False), ('ignore zero tables', False), ('non zero columns', False), ('remove zero terms', False), ('ignore ones', False)
2744
// Loop quadrature points for integral
2745
// Number of operations to compute element tensor for following IP loop = 302
2746
// Only 1 integration point, omitting IP loop.
2748
// Coefficient declarations
2749
double F0 = 0.00000000;
2750
double F1 = 0.00000000;
2751
double F2 = 0.00000000;
2752
double F3 = 0.00000000;
2754
// Total number of operations to compute function values = 32
2755
for (unsigned int r = 0; r < 4; r++)
2757
F0 += FE1_C0[0][r]*w[0][r];
2758
F1 += FE1_C1[0][r]*w[0][r];
2759
F2 += FE1_C2[0][r]*w[0][r];
2760
F3 += FE1_C3[0][r]*w[0][r];
2761
}// end loop over 'r'
2763
// Number of operations for primary indices: 270
2764
for (unsigned int j = 0; j < 3; j++)
2766
for (unsigned int k = 0; k < 3; k++)
2768
// Number of operations to compute entry: 30
2769
A[j*3 + k] += ((((((K_00*FE0_D10[0][k] + K_10*FE0_D01[0][k]))*F0 + ((K_01*FE0_D10[0][k] + K_11*FE0_D01[0][k]))*F1))*((K_00*FE0_D10[0][j] + K_10*FE0_D01[0][j])) + ((((K_01*FE0_D10[0][k] + K_11*FE0_D01[0][k]))*F3 + ((K_00*FE0_D10[0][k] + K_10*FE0_D01[0][k]))*F2))*((K_01*FE0_D10[0][j] + K_11*FE0_D01[0][j]))))*W1*det;
2770
}// end loop over 'k'
2771
}// end loop over 'j'
2776
/// This class defines the interface for the assembly of the global
2777
/// tensor corresponding to a form with r + n arguments, that is, a
2780
/// a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
2782
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
2783
/// global tensor A is defined by
2785
/// A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
2787
/// where each argument Vj represents the application to the
2788
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
2789
/// fixed functions (coefficients).
2791
class tensorweightedpoisson_form_0: public ufc::form
2796
tensorweightedpoisson_form_0() : ufc::form()
2802
virtual ~tensorweightedpoisson_form_0()
2807
/// Return a string identifying the form
2808
virtual const char* signature() const
2810
return "Form([Integral(IndexSum(Product(Indexed(ComponentTensor(IndexSum(Product(Indexed(Coefficient(TensorElement('Discontinuous Lagrange', Cell('triangle', 1, Space(2)), 0, (2, 2), None), 0), MultiIndex((Index(0), Index(1)), {Index(0): 2, 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})), MultiIndex((Index(0),), {Index(0): 2})), MultiIndex((Index(3),), {Index(3): 2})), Indexed(ComponentTensor(SpatialDerivative(Argument(FiniteElement('Lagrange', Cell('triangle', 1, Space(2)), 1), 0), MultiIndex((Index(4),), {Index(4): 2})), MultiIndex((Index(4),), {Index(4): 2})), MultiIndex((Index(3),), {Index(3): 2}))), MultiIndex((Index(3),), {Index(3): 2})), Measure('cell', 0, None))])";
2813
/// Return the rank of the global tensor (r)
2814
virtual unsigned int rank() const
2819
/// Return the number of coefficients (n)
2820
virtual unsigned int num_coefficients() const
2825
/// Return the number of cell integrals
2826
virtual unsigned int num_cell_integrals() const
2831
/// Return the number of exterior facet integrals
2832
virtual unsigned int num_exterior_facet_integrals() const
2837
/// Return the number of interior facet integrals
2838
virtual unsigned int num_interior_facet_integrals() const
2843
/// Create a new finite element for argument function i
2844
virtual ufc::finite_element* create_finite_element(unsigned int i) const
2850
return new tensorweightedpoisson_finite_element_2();
2855
return new tensorweightedpoisson_finite_element_2();
2860
return new tensorweightedpoisson_finite_element_1();
2868
/// Create a new dof map for argument function i
2869
virtual ufc::dof_map* create_dof_map(unsigned int i) const
2875
return new tensorweightedpoisson_dof_map_2();
2880
return new tensorweightedpoisson_dof_map_2();
2885
return new tensorweightedpoisson_dof_map_1();
2893
/// Create a new cell integral on sub domain i
2894
virtual ufc::cell_integral* create_cell_integral(unsigned int i) const
2900
return new tensorweightedpoisson_cell_integral_0_0();
2908
/// Create a new exterior facet integral on sub domain i
2909
virtual ufc::exterior_facet_integral* create_exterior_facet_integral(unsigned int i) const
2914
/// Create a new interior facet integral on sub domain i
2915
virtual ufc::interior_facet_integral* create_interior_facet_integral(unsigned int i) const