/usr/include/dolfin/ale/Poisson1D.h is in libdolfin1.3-dev 1.3.0+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 | // This code conforms with the UFC specification version 2.3.0
// and was automatically generated by FFC version 1.3.0.
//
// This code was generated with the option '-l dolfin' and
// contains DOLFIN-specific wrappers that depend on DOLFIN.
//
// This code was generated with the following parameters:
//
// cache_dir: ''
// convert_exceptions_to_warnings: False
// cpp_optimize: True
// cpp_optimize_flags: '-O2'
// epsilon: 1e-14
// error_control: False
// form_postfix: True
// format: 'dolfin'
// log_level: 10
// log_prefix: ''
// no_ferari: True
// optimize: True
// output_dir: '.'
// precision: 15
// quadrature_degree: 'auto'
// quadrature_rule: 'auto'
// representation: 'auto'
// restrict_keyword: ''
// split: False
#ifndef __POISSON1D_H
#define __POISSON1D_H
#include <cmath>
#include <stdexcept>
#include <fstream>
#include <ufc.h>
/// This class defines the interface for a finite element.
class poisson1d_finite_element_0: public ufc::finite_element
{
public:
/// Constructor
poisson1d_finite_element_0() : ufc::finite_element()
{
// Do nothing
}
/// Destructor
virtual ~poisson1d_finite_element_0()
{
// Do nothing
}
/// Return a string identifying the finite element
virtual const char* signature() const
{
return "FiniteElement('Lagrange', Domain(Cell('interval', 1), 'interval_multiverse', 1, 1), 1, None)";
}
/// Return the cell shape
virtual ufc::shape cell_shape() const
{
return ufc::interval;
}
/// Return the topological dimension of the cell shape
virtual std::size_t topological_dimension() const
{
return 1;
}
/// Return the geometric dimension of the cell shape
virtual std::size_t geometric_dimension() const
{
return 1;
}
/// Return the dimension of the finite element function space
virtual std::size_t space_dimension() const
{
return 2;
}
/// Return the rank of the value space
virtual std::size_t value_rank() const
{
return 0;
}
/// Return the dimension of the value space for axis i
virtual std::size_t value_dimension(std::size_t i) const
{
return 1;
}
/// Evaluate basis function i at given point x in cell
virtual void evaluate_basis(std::size_t i,
double* values,
const double* x,
const double* vertex_coordinates,
int cell_orientation) const
{
// Compute Jacobian
double J[1];
compute_jacobian_interval_1d(J, vertex_coordinates);
// Compute Jacobian inverse and determinant
double K[1];
double detJ;
compute_jacobian_inverse_interval_1d(K, detJ, J);
// Get coordinates and map to the reference (FIAT) element
double X = (2.0*x[0] - vertex_coordinates[0] - vertex_coordinates[1]) / J[0];
// Reset values
*values = 0.0;
switch (i)
{
case 0:
{
// Array of basisvalues
double basisvalues[2] = {0.0, 0.0};
// Declare helper variables
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = X;
for (unsigned int r = 0; r < 2; r++)
{
basisvalues[r] *= std::sqrt((0.5 + r));
}// end loop over 'r'
// Table(s) of coefficients
static const double coefficients0[2] = \
{0.707106781186547, -0.408248290463863};
// Compute value(s)
for (unsigned int r = 0; r < 2; r++)
{
*values += coefficients0[r]*basisvalues[r];
}// end loop over 'r'
break;
}
case 1:
{
// Array of basisvalues
double basisvalues[2] = {0.0, 0.0};
// Declare helper variables
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = X;
for (unsigned int r = 0; r < 2; r++)
{
basisvalues[r] *= std::sqrt((0.5 + r));
}// end loop over 'r'
// Table(s) of coefficients
static const double coefficients0[2] = \
{0.707106781186547, 0.408248290463863};
// Compute value(s)
for (unsigned int r = 0; r < 2; r++)
{
*values += coefficients0[r]*basisvalues[r];
}// end loop over 'r'
break;
}
}
}
/// Evaluate all basis functions at given point x in cell
virtual void evaluate_basis_all(double* values,
const double* x,
const double* vertex_coordinates,
int cell_orientation) const
{
// Helper variable to hold values of a single dof.
double dof_values = 0.0;
// Loop dofs and call evaluate_basis
for (unsigned int r = 0; r < 2; r++)
{
evaluate_basis(r, &dof_values, x, vertex_coordinates, cell_orientation);
values[r] = dof_values;
}// end loop over 'r'
}
/// Evaluate order n derivatives of basis function i at given point x in cell
virtual void evaluate_basis_derivatives(std::size_t i,
std::size_t n,
double* values,
const double* x,
const double* vertex_coordinates,
int cell_orientation) const
{
// Compute number of derivatives.
unsigned int num_derivatives = 1;
for (unsigned int r = 0; r < n; r++)
{
num_derivatives *= 1;
}// end loop over 'r'
// Reset values. Assuming that values is always an array.
for (unsigned int r = 0; r < num_derivatives; r++)
{
values[r] = 0.0;
}// end loop over 'r'
// Call evaluate_basis if order of derivatives is equal to zero.
if (n == 0)
{
evaluate_basis(i, values, x, vertex_coordinates, cell_orientation);
return ;
}
// If order of derivatives is greater than the maximum polynomial degree, return zeros.
if (n > 1)
{
return ;
}
// Compute Jacobian
double J[1];
compute_jacobian_interval_1d(J, vertex_coordinates);
// Compute Jacobian inverse and determinant
double K[1];
double detJ;
compute_jacobian_inverse_interval_1d(K, detJ, J);
// Get coordinates and map to the reference (FIAT) element
double X = (2.0*x[0] - vertex_coordinates[0] - vertex_coordinates[1]) / J[0];
// Declare two dimensional array that holds combinations of derivatives and initialise
unsigned int combinations[1][1];
for (unsigned int row = 0; row < 1; row++)
{
for (unsigned int col = 0; col < 1; col++)
combinations[row][col] = 0;
}
// Generate combinations of derivatives
for (unsigned int row = 1; row < num_derivatives; row++)
{
for (unsigned int num = 0; num < row; num++)
{
for (unsigned int col = n-1; col+1 > 0; col--)
{
if (combinations[row][col] + 1 > 0)
combinations[row][col] = 0;
else
{
combinations[row][col] += 1;
break;
}
}
}
}
// Compute inverse of Jacobian
const double Jinv[1][1] = {{K[0]}};
// Declare transformation matrix
// Declare pointer to two dimensional array and initialise
double transform[1][1];
for (unsigned int j = 0; j < num_derivatives; j++)
{
for (unsigned int k = 0; k < num_derivatives; k++)
transform[j][k] = 1;
}
// Construct transformation matrix
for (unsigned int row = 0; row < num_derivatives; row++)
{
for (unsigned int col = 0; col < num_derivatives; col++)
{
for (unsigned int k = 0; k < n; k++)
transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
}
}
switch (i)
{
case 0:
{
// Array of basisvalues
double basisvalues[2] = {0.0, 0.0};
// Declare helper variables
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = X;
for (unsigned int r = 0; r < 2; r++)
{
basisvalues[r] *= std::sqrt((0.5 + r));
}// end loop over 'r'
// Table(s) of coefficients
static const double coefficients0[2] = \
{0.707106781186547, -0.408248290463863};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[2][2] = \
{{0.0, 0.0},
{3.46410161513775, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[1];
for (unsigned int r = 0; r < 1; r++)
{
derivatives[r] = 0.0;
}// end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[2][2] = \
{{1.0, 0.0},
{0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[2][2] = \
{{1.0, 0.0},
{0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 2; t++)
{
for (unsigned int u = 0; u < 2; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
}// end loop over 'u'
}// end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 2; t++)
{
for (unsigned int u = 0; u < 2; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
}// end loop over 'u'
}// end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 2; t++)
{
for (unsigned int u = 0; u < 2; u++)
{
for (unsigned int tu = 0; tu < 2; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
}// end loop over 'tu'
}// end loop over 'u'
}// end loop over 't'
}
}// end loop over 's'
for (unsigned int s = 0; s < 2; s++)
{
for (unsigned int t = 0; t < 2; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
}// end loop over 't'
}// end loop over 's'
}// end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r] += transform[r][s]*derivatives[s];
}// end loop over 's'
}// end loop over 'r'
break;
}
case 1:
{
// Array of basisvalues
double basisvalues[2] = {0.0, 0.0};
// Declare helper variables
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = X;
for (unsigned int r = 0; r < 2; r++)
{
basisvalues[r] *= std::sqrt((0.5 + r));
}// end loop over 'r'
// Table(s) of coefficients
static const double coefficients0[2] = \
{0.707106781186547, 0.408248290463863};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[2][2] = \
{{0.0, 0.0},
{3.46410161513775, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[1];
for (unsigned int r = 0; r < 1; r++)
{
derivatives[r] = 0.0;
}// end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[2][2] = \
{{1.0, 0.0},
{0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[2][2] = \
{{1.0, 0.0},
{0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 2; t++)
{
for (unsigned int u = 0; u < 2; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
}// end loop over 'u'
}// end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 2; t++)
{
for (unsigned int u = 0; u < 2; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
}// end loop over 'u'
}// end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 2; t++)
{
for (unsigned int u = 0; u < 2; u++)
{
for (unsigned int tu = 0; tu < 2; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
}// end loop over 'tu'
}// end loop over 'u'
}// end loop over 't'
}
}// end loop over 's'
for (unsigned int s = 0; s < 2; s++)
{
for (unsigned int t = 0; t < 2; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
}// end loop over 't'
}// end loop over 's'
}// end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r] += transform[r][s]*derivatives[s];
}// end loop over 's'
}// end loop over 'r'
break;
}
}
}
/// Evaluate order n derivatives of all basis functions at given point x in cell
virtual void evaluate_basis_derivatives_all(std::size_t n,
double* values,
const double* x,
const double* vertex_coordinates,
int cell_orientation) const
{
// Call evaluate_basis_all if order of derivatives is equal to zero.
if (n == 0)
{
evaluate_basis_all(values, x, vertex_coordinates, cell_orientation);
return ;
}
// Compute number of derivatives.
unsigned int num_derivatives = 1;
for (unsigned int r = 0; r < n; r++)
{
num_derivatives *= 1;
}// end loop over 'r'
// Set values equal to zero.
for (unsigned int r = 0; r < 2; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r*num_derivatives + s] = 0.0;
}// end loop over 's'
}// end loop over 'r'
// If order of derivatives is greater than the maximum polynomial degree, return zeros.
if (n > 1)
{
return ;
}
// Helper variable to hold values of a single dof.
double dof_values[1];
for (unsigned int r = 0; r < 1; r++)
{
dof_values[r] = 0.0;
}// end loop over 'r'
// Loop dofs and call evaluate_basis_derivatives.
for (unsigned int r = 0; r < 2; r++)
{
evaluate_basis_derivatives(r, n, dof_values, x, vertex_coordinates, cell_orientation);
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r*num_derivatives + s] = dof_values[s];
}// end loop over 's'
}// end loop over 'r'
}
/// Evaluate linear functional for dof i on the function f
virtual double evaluate_dof(std::size_t i,
const ufc::function& f,
const double* vertex_coordinates,
int cell_orientation,
const ufc::cell& c) const
{
// Declare variables for result of evaluation
double vals[1];
// Declare variable for physical coordinates
double y[1];
switch (i)
{
case 0:
{
y[0] = vertex_coordinates[0];
f.evaluate(vals, y, c);
return vals[0];
break;
}
case 1:
{
y[0] = vertex_coordinates[1];
f.evaluate(vals, y, c);
return vals[0];
break;
}
}
return 0.0;
}
/// Evaluate linear functionals for all dofs on the function f
virtual void evaluate_dofs(double* values,
const ufc::function& f,
const double* vertex_coordinates,
int cell_orientation,
const ufc::cell& c) const
{
// Declare variables for result of evaluation
double vals[1];
// Declare variable for physical coordinates
double y[1];
y[0] = vertex_coordinates[0];
f.evaluate(vals, y, c);
values[0] = vals[0];
y[0] = vertex_coordinates[1];
f.evaluate(vals, y, c);
values[1] = vals[0];
}
/// Interpolate vertex values from dof values
virtual void interpolate_vertex_values(double* vertex_values,
const double* dof_values,
const double* vertex_coordinates,
int cell_orientation,
const ufc::cell& c) const
{
// Evaluate function and change variables
vertex_values[0] = dof_values[0];
vertex_values[1] = dof_values[1];
}
/// Map coordinate xhat from reference cell to coordinate x in cell
virtual void map_from_reference_cell(double* x,
const double* xhat,
const ufc::cell& c) const
{
throw std::runtime_error("map_from_reference_cell not yet implemented.");
}
/// Map from coordinate x in cell to coordinate xhat in reference cell
virtual void map_to_reference_cell(double* xhat,
const double* x,
const ufc::cell& c) const
{
throw std::runtime_error("map_to_reference_cell not yet implemented.");
}
/// Return the number of sub elements (for a mixed element)
virtual std::size_t num_sub_elements() const
{
return 0;
}
/// Create a new finite element for sub element i (for a mixed element)
virtual ufc::finite_element* create_sub_element(std::size_t i) const
{
return 0;
}
/// Create a new class instance
virtual ufc::finite_element* create() const
{
return new poisson1d_finite_element_0();
}
};
/// This class defines the interface for a local-to-global mapping of
/// degrees of freedom (dofs).
class poisson1d_dofmap_0: public ufc::dofmap
{
public:
/// Constructor
poisson1d_dofmap_0() : ufc::dofmap()
{
// Do nothing
}
/// Destructor
virtual ~poisson1d_dofmap_0()
{
// Do nothing
}
/// Return a string identifying the dofmap
virtual const char* signature() const
{
return "FFC dofmap for FiniteElement('Lagrange', Domain(Cell('interval', 1), 'interval_multiverse', 1, 1), 1, None)";
}
/// Return true iff mesh entities of topological dimension d are needed
virtual bool needs_mesh_entities(std::size_t d) const
{
switch (d)
{
case 0:
{
return true;
break;
}
case 1:
{
return false;
break;
}
}
return false;
}
/// Return the topological dimension of the associated cell shape
virtual std::size_t topological_dimension() const
{
return 1;
}
/// Return the geometric dimension of the associated cell shape
virtual std::size_t geometric_dimension() const
{
return 1;
}
/// Return the dimension of the global finite element function space
virtual std::size_t global_dimension(const std::vector<std::size_t>&
num_global_entities) const
{
return num_global_entities[0];
}
/// Return the dimension of the local finite element function space for a cell
virtual std::size_t local_dimension() const
{
return 2;
}
/// Return the number of dofs on each cell facet
virtual std::size_t num_facet_dofs() const
{
return 1;
}
/// Return the number of dofs associated with each cell entity of dimension d
virtual std::size_t num_entity_dofs(std::size_t d) const
{
switch (d)
{
case 0:
{
return 1;
break;
}
case 1:
{
return 0;
break;
}
}
return 0;
}
/// Tabulate the local-to-global mapping of dofs on a cell
virtual void tabulate_dofs(std::size_t* dofs,
const std::vector<std::size_t>& num_global_entities,
const ufc::cell& c) const
{
dofs[0] = c.entity_indices[0][0];
dofs[1] = c.entity_indices[0][1];
}
/// Tabulate the local-to-local mapping from facet dofs to cell dofs
virtual void tabulate_facet_dofs(std::size_t* dofs,
std::size_t facet) const
{
switch (facet)
{
case 0:
{
dofs[0] = 0;
break;
}
case 1:
{
dofs[0] = 1;
break;
}
}
}
/// Tabulate the local-to-local mapping of dofs on entity (d, i)
virtual void tabulate_entity_dofs(std::size_t* dofs,
std::size_t d, std::size_t i) const
{
if (d > 1)
{
throw std::runtime_error("d is larger than dimension (1)");
}
switch (d)
{
case 0:
{
if (i > 1)
{
throw std::runtime_error("i is larger than number of entities (1)");
}
switch (i)
{
case 0:
{
dofs[0] = 0;
break;
}
case 1:
{
dofs[0] = 1;
break;
}
}
break;
}
case 1:
{
break;
}
}
}
/// Tabulate the coordinates of all dofs on a cell
virtual void tabulate_coordinates(double** dof_coordinates,
const double* vertex_coordinates) const
{
dof_coordinates[0][0] = vertex_coordinates[0];
dof_coordinates[1][0] = vertex_coordinates[1];
}
/// Return the number of sub dofmaps (for a mixed element)
virtual std::size_t num_sub_dofmaps() const
{
return 0;
}
/// Create a new dofmap for sub dofmap i (for a mixed element)
virtual ufc::dofmap* create_sub_dofmap(std::size_t i) const
{
return 0;
}
/// Create a new class instance
virtual ufc::dofmap* create() const
{
return new poisson1d_dofmap_0();
}
};
/// This class defines the interface for the tabulation of the cell
/// tensor corresponding to the local contribution to a form from
/// the integral over a cell.
class poisson1d_cell_integral_0_otherwise: public ufc::cell_integral
{
public:
/// Constructor
poisson1d_cell_integral_0_otherwise() : ufc::cell_integral()
{
// Do nothing
}
/// Destructor
virtual ~poisson1d_cell_integral_0_otherwise()
{
// Do nothing
}
/// Tabulate the tensor for the contribution from a local cell
virtual void tabulate_tensor(double* A,
const double * const * w,
const double* vertex_coordinates,
int cell_orientation) const
{
// Number of operations (multiply-add pairs) for Jacobian data: 3
// Number of operations (multiply-add pairs) for geometry tensor: 1
// Number of operations (multiply-add pairs) for tensor contraction: 0
// Total number of operations (multiply-add pairs): 4
// Compute Jacobian
double J[1];
compute_jacobian_interval_1d(J, vertex_coordinates);
// Compute Jacobian inverse and determinant
double K[1];
double detJ;
compute_jacobian_inverse_interval_1d(K, detJ, J);
// Set scale factor
const double det = std::abs(detJ);
// Compute geometry tensor
const double G0_0_0 = det*K[0]*K[0];
// Compute element tensor
A[0] = G0_0_0;
A[1] = -G0_0_0;
A[2] = -G0_0_0;
A[3] = G0_0_0;
}
};
/// This class defines the interface for the assembly of the global
/// tensor corresponding to a form with r + n arguments, that is, a
/// mapping
///
/// a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R
///
/// with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r
/// global tensor A is defined by
///
/// A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
///
/// where each argument Vj represents the application to the
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
/// fixed functions (coefficients).
class poisson1d_form_0: public ufc::form
{
public:
/// Constructor
poisson1d_form_0() : ufc::form()
{
// Do nothing
}
/// Destructor
virtual ~poisson1d_form_0()
{
// Do nothing
}
/// Return a string identifying the form
virtual const char* signature() const
{
return "0650dbc51220f29e2586c728bd7ff63ddc121dfb080da1f1825fa375afb7929126d3d472127a5f95d45bd64dca28c6bd6e6493190e393656e2ccc6a979b5f538";
}
/// Return the rank of the global tensor (r)
virtual std::size_t rank() const
{
return 2;
}
/// Return the number of coefficients (n)
virtual std::size_t num_coefficients() const
{
return 0;
}
/// Return the number of cell domains
virtual std::size_t num_cell_domains() const
{
return 0;
}
/// Return the number of exterior facet domains
virtual std::size_t num_exterior_facet_domains() const
{
return 0;
}
/// Return the number of interior facet domains
virtual std::size_t num_interior_facet_domains() const
{
return 0;
}
/// Return the number of point domains
virtual std::size_t num_point_domains() const
{
return 0;
}
/// Return whether the form has any cell integrals
virtual bool has_cell_integrals() const
{
return true;
}
/// Return whether the form has any exterior facet integrals
virtual bool has_exterior_facet_integrals() const
{
return false;
}
/// Return whether the form has any interior facet integrals
virtual bool has_interior_facet_integrals() const
{
return false;
}
/// Return whether the form has any point integrals
virtual bool has_point_integrals() const
{
return false;
}
/// Create a new finite element for argument function i
virtual ufc::finite_element* create_finite_element(std::size_t i) const
{
switch (i)
{
case 0:
{
return new poisson1d_finite_element_0();
break;
}
case 1:
{
return new poisson1d_finite_element_0();
break;
}
}
return 0;
}
/// Create a new dofmap for argument function i
virtual ufc::dofmap* create_dofmap(std::size_t i) const
{
switch (i)
{
case 0:
{
return new poisson1d_dofmap_0();
break;
}
case 1:
{
return new poisson1d_dofmap_0();
break;
}
}
return 0;
}
/// Create a new cell integral on sub domain i
virtual ufc::cell_integral* create_cell_integral(std::size_t i) const
{
return 0;
}
/// Create a new exterior facet integral on sub domain i
virtual ufc::exterior_facet_integral* create_exterior_facet_integral(std::size_t i) const
{
return 0;
}
/// Create a new interior facet integral on sub domain i
virtual ufc::interior_facet_integral* create_interior_facet_integral(std::size_t i) const
{
return 0;
}
/// Create a new point integral on sub domain i
virtual ufc::point_integral* create_point_integral(std::size_t i) const
{
return 0;
}
/// Create a new cell integral on everywhere else
virtual ufc::cell_integral* create_default_cell_integral() const
{
return new poisson1d_cell_integral_0_otherwise();
}
/// Create a new exterior facet integral on everywhere else
virtual ufc::exterior_facet_integral* create_default_exterior_facet_integral() const
{
return 0;
}
/// Create a new interior facet integral on everywhere else
virtual ufc::interior_facet_integral* create_default_interior_facet_integral() const
{
return 0;
}
/// Create a new point integral on everywhere else
virtual ufc::point_integral* create_default_point_integral() const
{
return 0;
}
};
// DOLFIN wrappers
// Standard library includes
#include <string>
// DOLFIN includes
#include <dolfin/common/NoDeleter.h>
#include <dolfin/mesh/Restriction.h>
#include <dolfin/fem/FiniteElement.h>
#include <dolfin/fem/DofMap.h>
#include <dolfin/fem/Form.h>
#include <dolfin/function/FunctionSpace.h>
#include <dolfin/function/GenericFunction.h>
#include <dolfin/function/CoefficientAssigner.h>
#include <dolfin/adaptivity/ErrorControl.h>
#include <dolfin/adaptivity/GoalFunctional.h>
namespace Poisson1D
{
class Form_a_FunctionSpace_0: public dolfin::FunctionSpace
{
public:
//--- Constructors for standard function space, 2 different versions ---
// Create standard function space (reference version)
Form_a_FunctionSpace_0(const dolfin::Mesh& mesh):
dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()), mesh)))
{
// Do nothing
}
// Create standard function space (shared pointer version)
Form_a_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh):
dolfin::FunctionSpace(mesh,
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()), *mesh)))
{
// Do nothing
}
//--- Constructors for constrained function space, 2 different versions ---
// Create standard function space (reference version)
Form_a_FunctionSpace_0(const dolfin::Mesh& mesh, const dolfin::SubDomain& constrained_domain):
dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()), mesh,
dolfin::reference_to_no_delete_pointer(constrained_domain))))
{
// Do nothing
}
// Create standard function space (shared pointer version)
Form_a_FunctionSpace_0(boost::shared_ptr<const dolfin::Mesh> mesh, boost::shared_ptr<const dolfin::SubDomain> constrained_domain):
dolfin::FunctionSpace(mesh,
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()), *mesh, constrained_domain)))
{
// Do nothing
}
//--- Constructors for restricted function space, 2 different versions ---
// Create restricted function space (reference version)
Form_a_FunctionSpace_0(const dolfin::Restriction& restriction):
dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(restriction.mesh()),
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()),
reference_to_no_delete_pointer(restriction))))
{
// Do nothing
}
// Create restricted function space (shared pointer version)
Form_a_FunctionSpace_0(boost::shared_ptr<const dolfin::Restriction> restriction):
dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(restriction->mesh()),
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()),
restriction)))
{
// Do nothing
}
// Copy constructor
~Form_a_FunctionSpace_0()
{
}
};
class Form_a_FunctionSpace_1: public dolfin::FunctionSpace
{
public:
//--- Constructors for standard function space, 2 different versions ---
// Create standard function space (reference version)
Form_a_FunctionSpace_1(const dolfin::Mesh& mesh):
dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()), mesh)))
{
// Do nothing
}
// Create standard function space (shared pointer version)
Form_a_FunctionSpace_1(boost::shared_ptr<const dolfin::Mesh> mesh):
dolfin::FunctionSpace(mesh,
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()), *mesh)))
{
// Do nothing
}
//--- Constructors for constrained function space, 2 different versions ---
// Create standard function space (reference version)
Form_a_FunctionSpace_1(const dolfin::Mesh& mesh, const dolfin::SubDomain& constrained_domain):
dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(mesh),
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()), mesh,
dolfin::reference_to_no_delete_pointer(constrained_domain))))
{
// Do nothing
}
// Create standard function space (shared pointer version)
Form_a_FunctionSpace_1(boost::shared_ptr<const dolfin::Mesh> mesh, boost::shared_ptr<const dolfin::SubDomain> constrained_domain):
dolfin::FunctionSpace(mesh,
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()), *mesh, constrained_domain)))
{
// Do nothing
}
//--- Constructors for restricted function space, 2 different versions ---
// Create restricted function space (reference version)
Form_a_FunctionSpace_1(const dolfin::Restriction& restriction):
dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(restriction.mesh()),
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()),
reference_to_no_delete_pointer(restriction))))
{
// Do nothing
}
// Create restricted function space (shared pointer version)
Form_a_FunctionSpace_1(boost::shared_ptr<const dolfin::Restriction> restriction):
dolfin::FunctionSpace(dolfin::reference_to_no_delete_pointer(restriction->mesh()),
boost::shared_ptr<const dolfin::FiniteElement>(new dolfin::FiniteElement(boost::shared_ptr<ufc::finite_element>(new poisson1d_finite_element_0()))),
boost::shared_ptr<const dolfin::DofMap>(new dolfin::DofMap(boost::shared_ptr<ufc::dofmap>(new poisson1d_dofmap_0()),
restriction)))
{
// Do nothing
}
// Copy constructor
~Form_a_FunctionSpace_1()
{
}
};
class Form_a: public dolfin::Form
{
public:
// Constructor
Form_a(const dolfin::FunctionSpace& V1, const dolfin::FunctionSpace& V0):
dolfin::Form(2, 0)
{
_function_spaces[0] = reference_to_no_delete_pointer(V0);
_function_spaces[1] = reference_to_no_delete_pointer(V1);
_ufc_form = boost::shared_ptr<const ufc::form>(new poisson1d_form_0());
}
// Constructor
Form_a(boost::shared_ptr<const dolfin::FunctionSpace> V1, boost::shared_ptr<const dolfin::FunctionSpace> V0):
dolfin::Form(2, 0)
{
_function_spaces[0] = V0;
_function_spaces[1] = V1;
_ufc_form = boost::shared_ptr<const ufc::form>(new poisson1d_form_0());
}
// Destructor
~Form_a()
{}
/// Return the number of the coefficient with this name
virtual std::size_t coefficient_number(const std::string& name) const
{
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"There are no coefficients");
return 0;
}
/// Return the name of the coefficient with this number
virtual std::string coefficient_name(std::size_t i) const
{
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"There are no coefficients");
return "unnamed";
}
// Typedefs
typedef Form_a_FunctionSpace_0 TestSpace;
typedef Form_a_FunctionSpace_1 TrialSpace;
// Coefficients
};
// Class typedefs
typedef Form_a BilinearForm;
typedef Form_a JacobianForm;
typedef Form_a::TestSpace FunctionSpace;
}
#endif
|