/usr/include/dune/grid/alugrid/3d/mappings_imp.cc is in libdune-grid-dev 2.4.1-1.
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 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ALUGRID_MAPPINGS_IMP_CC
#define DUNE_ALUGRID_MAPPINGS_IMP_CC
#include "mappings.hh"
namespace Dune {
//- Trilinear mapping (from alu3dmappings.hh)
alu_inline TrilinearMapping ::
TrilinearMapping (const coord_t& p0, const coord_t& p1,
const coord_t& p2, const coord_t& p3,
const coord_t& p4, const coord_t& p5,
const coord_t& p6, const coord_t& p7)
{
buildMapping(p0,p1,p2,p3,p4,p5,p6,p7);
return ;
}
template <class vector_t>
alu_inline void TrilinearMapping ::
buildMapping(const vector_t& p0, const vector_t& p1,
const vector_t& p2, const vector_t& p3,
const vector_t& p4, const vector_t& p5,
const vector_t& p6, const vector_t& p7)
{
// build mapping
a [0][0] = p0 [0] ;
a [0][1] = p0 [1] ;
a [0][2] = p0 [2] ;
a [1][0] = p1 [0] - p0 [0] ;
a [1][1] = p1 [1] - p0 [1] ;
a [1][2] = p1 [2] - p0 [2] ;
a [2][0] = p2 [0] - p0 [0] ;
a [2][1] = p2 [1] - p0 [1] ;
a [2][2] = p2 [2] - p0 [2] ;
a [3][0] = p4 [0] - p0 [0] ;
a [3][1] = p4 [1] - p0 [1] ;
a [3][2] = p4 [2] - p0 [2] ;
a [4][0] = p3 [0] - p2 [0] - a [1][0] ;
a [4][1] = p3 [1] - p2 [1] - a [1][1] ;
a [4][2] = p3 [2] - p2 [2] - a [1][2] ;
a [5][0] = p6 [0] - p4 [0] - a [2][0] ;
a [5][1] = p6 [1] - p4 [1] - a [2][1] ;
a [5][2] = p6 [2] - p4 [2] - a [2][2] ;
a [6][0] = p5 [0] - p1 [0] - a [3][0] ;
a [6][1] = p5 [1] - p1 [1] - a [3][1] ;
a [6][2] = p5 [2] - p1 [2] - a [3][2] ;
a [7][0] = p7 [0] - p5 [0] + p4 [0] - p6 [0] - p3 [0] + p1 [0] + a [2][0] ;
a [7][1] = p7 [1] - p5 [1] + p4 [1] - p6 [1] - p3 [1] + p1 [1] + a [2][1] ;
a [7][2] = p7 [2] - p5 [2] + p4 [2] - p6 [2] - p3 [2] + p1 [2] + a [2][2] ;
{
alu3d_ctype sum = 0.0;
// sum all factor from non-linear terms
for(int i=4; i<8; ++i)
{
for(int j=0; j<3; ++j)
{
sum += std::abs(a[i][j]);
}
}
// mapping is affine when all higher terms are zero
affine_ = (sum < _epsilon);
}
// initialize flags
calcedDet_ = calcedLinear_ = calcedInv_ = false;
return ;
}
alu_inline TrilinearMapping :: TrilinearMapping (const TrilinearMapping & map)
{
// copy mapping
for (int i = 0 ; i < 8 ; ++i)
for (int j = 0 ; j < 3 ; ++j)
a [i][j] = map.a [i][j] ;
// copy flags
affine_ = map.affine_;
calcedDet_ = calcedLinear_ = calcedInv_ = false;
return ;
}
alu_inline const FieldMatrix<alu3d_ctype, 3, 3>&
TrilinearMapping::jacobianTransposed(const coord_t& p)
{
linear( p );
return Df;
}
alu_inline const FieldMatrix<alu3d_ctype, 3, 3>&
TrilinearMapping::jacobianInverseTransposed(const coord_t& p)
{
// calculate inverse if not calculated or not affine
inverse (p);
// return reference when already calculated
if( calcedInv_ )
{
return Dfi;
}
else
{
// make a copy since Dfi could change during world2map
invTransposed_ = Dfi;
return invTransposed_;
}
}
alu_inline void TrilinearMapping ::
map2world(const coord_t& p, coord_t& world) const
{
map2world(p[0], p[1], p[2], world);
return ;
}
alu_inline void TrilinearMapping ::
map2world(const alu3d_ctype x, const alu3d_ctype y,
const alu3d_ctype z, coord_t& world ) const
{
const alu3d_ctype yz = y * z ;
const alu3d_ctype xz = x * z ;
const alu3d_ctype xy = x * y ;
const alu3d_ctype xyz = x * yz ;
world [0] = a [0][0] + a [1][0] * x + a [2][0] * y + a [3][0] * z + a [4][0] * xy + a [5][0] * yz + a [6][0] * xz + a [7][0] * xyz ;
world [1] = a [0][1] + a [1][1] * x + a [2][1] * y + a [3][1] * z + a [4][1] * xy + a [5][1] * yz + a [6][1] * xz + a [7][1] * xyz ;
world [2] = a [0][2] + a [1][2] * x + a [2][2] * y + a [3][2] * z + a [4][2] * xy + a [5][2] * yz + a [6][2] * xz + a [7][2] * xyz ;
return ;
}
alu_inline void TrilinearMapping :: linear(const coord_t& p )
{
linear(p[0], p[1], p[2]);
}
alu_inline void TrilinearMapping :: linear(const alu3d_ctype x,
const alu3d_ctype y,
const alu3d_ctype z)
{
if( ! calcedLinear_ )
{
const alu3d_ctype yz = y * z ;
const alu3d_ctype xz = x * z ;
const alu3d_ctype xy = x * y ;
// derivatives with respect to x
Df[0][0] = a[1][0] + y * a[4][0] + z * a[6][0] + yz * a[7][0] ;
Df[0][1] = a[1][1] + y * a[4][1] + z * a[6][1] + yz * a[7][1] ;
Df[0][2] = a[1][2] + y * a[4][2] + z * a[6][2] + yz * a[7][2] ;
// derivatives with respect to y
Df[1][0] = a[2][0] + x * a[4][0] + z * a[5][0] + xz * a[7][0] ;
Df[1][1] = a[2][1] + x * a[4][1] + z * a[5][1] + xz * a[7][1] ;
Df[1][2] = a[2][2] + x * a[4][2] + z * a[5][2] + xz * a[7][2] ;
// derivatives with respect to z
Df[2][0] = a[3][0] + y * a[5][0] + x * a[6][0] + xy * a[7][0] ;
Df[2][1] = a[3][1] + y * a[5][1] + x * a[6][1] + xy * a[7][1] ;
Df[2][2] = a[3][2] + y * a[5][2] + x * a[6][2] + xy * a[7][2] ;
// set calced det to affine (true if affine false otherwise)
calcedLinear_ = affine_ ;
}
}
alu_inline alu3d_ctype TrilinearMapping :: det(const coord_t& point)
{
// use cached value of determinant
if( calcedDet_ ) return DetDf;
// Determinante der Abbildung f:[-1,1]^3 -> Hexaeder im Punkt point.
linear (point) ;
// code generated by maple
const alu3d_ctype t4 = Df[0][0] * Df[1][1];
const alu3d_ctype t6 = Df[0][0] * Df[1][2];
const alu3d_ctype t8 = Df[0][1] * Df[1][0];
const alu3d_ctype t10 = Df[0][2] * Df[1][0];
const alu3d_ctype t12 = Df[0][1] * Df[2][0];
const alu3d_ctype t14 = Df[0][2] * Df[2][0];
// determinant
DetDf = (t4*Df[2][2]-t6*Df[2][1]-t8*Df[2][2]+
t10*Df[2][1]+t12*Df[1][2]-t14*Df[1][1]);
assert( DetDf > 0 );
//: ( std::cout << "DetDf wrong: " << DetDf << std::endl,false ) );
// set calced det to affine (true if affine false otherwise)
calcedDet_ = affine_ ;
return DetDf;
}
alu_inline void TrilinearMapping :: inverse(const coord_t& point)
{
// return when inverse already calculated
if( calcedInv_ ) return ;
// Kramer - Regel, det() rechnet Df und DetDf neu aus.
const alu3d_ctype val = 1.0 / det(point) ;
// calculate inverse^T
Dfi[0][0] = ( Df[1][1] * Df[2][2] - Df[2][1] * Df[1][2] ) * val ;
Dfi[1][0] = ( Df[2][0] * Df[1][2] - Df[1][0] * Df[2][2] ) * val ;
Dfi[2][0] = ( Df[1][0] * Df[2][1] - Df[2][0] * Df[1][1] ) * val ;
Dfi[0][1] = ( Df[2][1] * Df[0][2] - Df[0][1] * Df[2][2] ) * val ;
Dfi[1][1] = ( Df[0][0] * Df[2][2] - Df[2][0] * Df[0][2] ) * val ;
Dfi[2][1] = ( Df[2][0] * Df[0][1] - Df[0][0] * Df[2][1] ) * val ;
Dfi[0][2] = ( Df[0][1] * Df[1][2] - Df[1][1] * Df[0][2] ) * val ;
Dfi[1][2] = ( Df[1][0] * Df[0][2] - Df[0][0] * Df[1][2] ) * val ;
Dfi[2][2] = ( Df[0][0] * Df[1][1] - Df[1][0] * Df[0][1] ) * val ;
// set calcedInv_ to affine (true if affine false otherwise)
calcedInv_ = affine_;
return ;
}
alu_inline void TrilinearMapping::world2map (const coord_t& wld , coord_t& map )
{
// Newton - Iteration zum Invertieren der Abbildung f.
double err = 10.0 * _epsilon ;
#ifndef NDEBUG
int count = 0 ;
#endif
// start with barycenter
map [0] = map [1] = map [2] = 0.5 ;
coord_t upd ;
do {
// do mapping
map2world (map, upd) ;
// get inverse
inverse ( map ) ;
const alu3d_ctype u0 = upd [0] - wld [0] ;
const alu3d_ctype u1 = upd [1] - wld [1] ;
const alu3d_ctype u2 = upd [2] - wld [2] ;
// jacobian is stored as transposed
const alu3d_ctype c0 = Dfi [0][0] * u0 + Dfi [1][0] * u1 + Dfi [2][0] * u2 ;
const alu3d_ctype c1 = Dfi [0][1] * u0 + Dfi [1][1] * u1 + Dfi [2][1] * u2 ;
const alu3d_ctype c2 = Dfi [0][2] * u0 + Dfi [1][2] * u1 + Dfi [2][2] * u2 ;
map [0] -= c0 ;
map [1] -= c1 ;
map [2] -= c2 ;
err = std::abs (c0) + std::abs (c1) + std::abs (c2) ;
assert (count ++ < 1000) ;
} while (err > _epsilon) ;
return ;
}
//- Bilinear surface mapping
// Constructor for FieldVectors
alu_inline SurfaceNormalCalculator :: SurfaceNormalCalculator()
{
alu3d_ctype p[3] = {0.0,0.0,0.0};
//initialize with zero
buildMapping(p,p,p,p);
}
// the real constructor, this can be called for FieldVectors
// and double[3], we dont have to convert one type
template <class vector_t>
alu_inline void SurfaceNormalCalculator ::
buildMapping (const vector_t & _p0, const vector_t & _p1,
const vector_t & _p2, const vector_t & _p3)
{
alu3d_ctype b[4][3];
buildMapping( _p0, _p1, _p2, _p3, b );
}
// the real constructor, this can be called for FieldVectors
// and double[3], we dont have to convert one type
template <class vector_t>
alu_inline void SurfaceNormalCalculator ::
buildMapping (const vector_t & _p0, const vector_t & _p1,
const vector_t & _p2, const vector_t & _p3,
alu3d_ctype (&_b)[4][3])
{
_b [0][0] = _p0 [0] ;
_b [0][1] = _p0 [1] ;
_b [0][2] = _p0 [2] ;
_b [1][0] = _p1 [0] - _p0 [0] ;
_b [1][1] = _p1 [1] - _p0 [1] ;
_b [1][2] = _p1 [2] - _p0 [2] ;
_b [2][0] = _p2 [0] - _p0 [0] ;
_b [2][1] = _p2 [1] - _p0 [1] ;
_b [2][2] = _p2 [2] - _p0 [2] ;
_b [3][0] = _p3 [0] - _p2 [0] - _b [1][0] ;
_b [3][1] = _p3 [1] - _p2 [1] - _b [1][1] ;
_b [3][2] = _p3 [2] - _p2 [2] - _b [1][2] ;
_n [0][0] = _b [1][1] * _b [2][2] - _b [1][2] * _b [2][1] ;
_n [0][1] = _b [1][2] * _b [2][0] - _b [1][0] * _b [2][2] ;
_n [0][2] = _b [1][0] * _b [2][1] - _b [1][1] * _b [2][0] ;
_n [1][0] = _b [1][1] * _b [3][2] - _b [1][2] * _b [3][1] ;
_n [1][1] = _b [1][2] * _b [3][0] - _b [1][0] * _b [3][2] ;
_n [1][2] = _b [1][0] * _b [3][1] - _b [1][1] * _b [3][0] ;
_n [2][0] = _b [3][1] * _b [2][2] - _b [3][2] * _b [2][1] ;
_n [2][1] = _b [3][2] * _b [2][0] - _b [3][0] * _b [2][2] ;
_n [2][2] = _b [3][0] * _b [2][1] - _b [3][1] * _b [2][0] ;
{
alu3d_ctype sum = 0.0;
// sum all factor from non-linear terms
for(int j=0; j<3; ++j)
{
sum += std::abs(_b[3][j]);
}
// mapping is affine when all higher terms are zero
_affine = (sum < _epsilon);
}
return ;
}
alu_inline SurfaceNormalCalculator ::
SurfaceNormalCalculator(const SurfaceNormalCalculator & m)
{
// copy n
{
for (int i = 0 ; i < 3 ; ++i)
for (int j = 0 ; j < 3 ; ++j)
_n [i][j] = m._n [i][j] ;
}
_affine = m._affine;
return ;
}
alu_inline void SurfaceNormalCalculator::
normal (const coord2_t& map, coord3_t& norm) const
{
normal(map[0],map[1],norm);
return ;
}
alu_inline void SurfaceNormalCalculator ::
normal (const alu3d_ctype x, const alu3d_ctype y, coord3_t& norm) const {
norm [0] = -(_n [0][0] + _n [1][0] * x + _n [2][0] * y);
norm [1] = -(_n [0][1] + _n [1][1] * x + _n [2][1] * y);
norm [2] = -(_n [0][2] + _n [1][2] * x + _n [2][2] * y);
return ;
}
alu_inline void SurfaceNormalCalculator ::
negativeNormal (const coord2_t& map, coord3_t& norm) const
{
negativeNormal(map[0],map[1],norm);
return ;
}
alu_inline void SurfaceNormalCalculator ::
negativeNormal(const alu3d_ctype x, const alu3d_ctype y, coord3_t& norm) const {
norm [0] = (_n [0][0] + _n [1][0] * x + _n [2][0] * y);
norm [1] = (_n [0][1] + _n [1][1] * x + _n [2][1] * y);
norm [2] = (_n [0][2] + _n [1][2] * x + _n [2][2] * y);
return ;
}
// BilinearSurfaceMapping
// ----------------------
// Constructor for FieldVectors
alu_inline BilinearSurfaceMapping ::
BilinearSurfaceMapping ()
{
alu3d_ctype p[3] = {0.0,0.0,0.0};
//initialize with zero
buildMapping(p,p,p,p);
}
//- Bilinear surface mapping
// Constructor for FieldVectors
alu_inline BilinearSurfaceMapping ::
BilinearSurfaceMapping (const coord3_t& x0, const coord3_t& x1,
const coord3_t& x2, const coord3_t& x3)
{
buildMapping(x0,x1,x2,x3);
}
// Constructor for double[3]
alu_inline BilinearSurfaceMapping ::
BilinearSurfaceMapping (const double3_t & x0, const double3_t & x1,
const double3_t & x2, const double3_t & x3)
{
buildMapping(x0,x1,x2,x3);
}
// the real constructor, this can be called for FieldVectors
// and double[3], we dont have to convert one type
template <class vector_t>
alu_inline void BilinearSurfaceMapping ::
buildMapping (const vector_t & _p0, const vector_t & _p1,
const vector_t & _p2, const vector_t & _p3)
{
BaseType :: buildMapping( _p0, _p1, _p2, _p3, _b );
// initialize flags
_calcedInv = _calcedTransposed = _calcedMatrix = false ;
return ;
}
alu_inline BilinearSurfaceMapping ::
BilinearSurfaceMapping (const BilinearSurfaceMapping & m)
: BaseType(m)
{
// copy _b
{
for (int i = 0 ; i < 4 ; ++i)
for (int j = 0 ; j < 3 ; ++j)
_b [i][j] = m._b [i][j] ;
}
// initialize flags
_calcedInv = _calcedTransposed = _calcedMatrix = false ;
return ;
}
alu_inline void BilinearSurfaceMapping ::
map2world (const coord2_t& map, coord3_t& wld) const
{
map2world(map[0],map[1],wld);
}
alu_inline void BilinearSurfaceMapping ::
map2world (const alu3d_ctype x, const alu3d_ctype y, coord3_t& w) const
{
const alu3d_ctype xy = x * y ;
w[0] = _b [0][0] + x * _b [1][0] + y * _b [2][0] + xy * _b [3][0] ;
w[1] = _b [0][1] + x * _b [1][1] + y * _b [2][1] + xy * _b [3][1] ;
w[2] = _b [0][2] + x * _b [1][2] + y * _b [2][2] + xy * _b [3][2] ;
return ;
}
alu_inline void BilinearSurfaceMapping ::
map2worldnormal (const alu3d_ctype x,
const alu3d_ctype y,
const alu3d_ctype z,
coord3_t& w) const
{
normal(x,y,normal_);
const alu3d_ctype xy = x * y ;
w[0] = _b [0][0] + x * _b [1][0] + y * _b [2][0] + xy * _b [3][0] + z*normal_[0];
w[1] = _b [0][1] + x * _b [1][1] + y * _b [2][1] + xy * _b [3][1] + z*normal_[1];
w[2] = _b [0][2] + x * _b [1][2] + y * _b [2][2] + xy * _b [3][2] + z*normal_[2];
return ;
}
alu_inline void BilinearSurfaceMapping ::
map2worldlinear(const alu3d_ctype x, const alu3d_ctype y, const alu3d_ctype z) const
{
normal(x,y,normal_);
Df[0][0] = _b [1][0] + y * _b [3][0] + z * _n[1][0] ;
Df[1][0] = _b [1][1] + y * _b [3][1] + z * _n[1][1] ;
Df[2][0] = _b [1][2] + y * _b [3][2] + z * _n[1][2] ;
Df[0][1] = _b [2][0] + x * _b [3][0] + z * _n[2][0] ;
Df[1][1] = _b [2][1] + x * _b [3][1] + z * _n[2][1] ;
Df[2][1] = _b [2][2] + x * _b [3][2] + z * _n[2][2] ;
Df[0][2] = normal_[0];
Df[1][2] = normal_[1];
Df[2][2] = normal_[2];
return ;
}
alu_inline const BilinearSurfaceMapping:: matrix_t&
BilinearSurfaceMapping::jacobianTransposed(const coord2_t & local) const
{
if( ! _calcedMatrix )
{
const alu3d_ctype x = local[0];
const alu3d_ctype y = local[1];
matrix_[0][0] = _b [1][0] + y * _b [3][0] ;
matrix_[0][1] = _b [1][1] + y * _b [3][1] ;
matrix_[0][2] = _b [1][2] + y * _b [3][2] ;
matrix_[1][0] = _b [2][0] + x * _b [3][0] ;
matrix_[1][1] = _b [2][1] + x * _b [3][1] ;
matrix_[1][2] = _b [2][2] + x * _b [3][2] ;
// only true for affine mappings
_calcedMatrix = _affine ;
}
return matrix_;
}
// calculates determinant of face mapping
alu_inline alu3d_ctype BilinearSurfaceMapping :: det(const coord2_t& point ) const
{
// calculate normal
normal(point[0], point[1], normal_);
// return length
return normal_.two_norm();
}
alu_inline void BilinearSurfaceMapping :: inverse(const coord3_t& point ) const
{
if( _calcedInv ) return ;
// Determinante der Abbildung f:[-1,1]^3 -> Hexaeder im Punkt point.
map2worldlinear (point[0],point[1],point[2]) ;
// Kramer - Regel, det() rechnet Df und DetDf neu aus.
const alu3d_ctype val = 1.0 / Df.determinant();
Dfi[0][0] = ( Df[1][1] * Df[2][2] - Df[1][2] * Df[2][1] ) * val ;
Dfi[0][1] = ( Df[0][2] * Df[2][1] - Df[0][1] * Df[2][2] ) * val ;
Dfi[0][2] = ( Df[0][1] * Df[1][2] - Df[0][2] * Df[1][1] ) * val ;
Dfi[1][0] = ( Df[1][2] * Df[2][0] - Df[1][0] * Df[2][2] ) * val ;
Dfi[1][1] = ( Df[0][0] * Df[2][2] - Df[0][2] * Df[2][0] ) * val ;
Dfi[1][2] = ( Df[0][2] * Df[1][0] - Df[0][0] * Df[1][2] ) * val ;
Dfi[2][0] = ( Df[1][0] * Df[2][1] - Df[1][1] * Df[2][0] ) * val ;
Dfi[2][1] = ( Df[0][1] * Df[2][0] - Df[0][0] * Df[2][1] ) * val ;
Dfi[2][2] = ( Df[0][0] * Df[1][1] - Df[0][1] * Df[1][0] ) * val ;
// only true for affine mappings
_calcedInv = _affine ;
return ;
}
alu_inline const BilinearSurfaceMapping:: inv_t&
BilinearSurfaceMapping::jacobianInverseTransposed(const coord2_t & local) const
{
// if calculated return
if( _calcedTransposed) return invTransposed_;
tmp_[0] = local[0];
tmp_[1] = local[1];
tmp_[2] = 0.0;
inverse (tmp_) ;
// calculate transposed inverse
invTransposed_[0][0] = Dfi[0][0];
invTransposed_[0][1] = Dfi[1][0];
invTransposed_[1][0] = Dfi[0][1];
invTransposed_[1][1] = Dfi[1][1];
invTransposed_[2][0] = Dfi[0][2];
invTransposed_[2][1] = Dfi[1][2];
// only true for affine mappings
_calcedTransposed = _affine ;
return invTransposed_;
}
alu_inline void BilinearSurfaceMapping::world2map (const coord3_t& wld , coord2_t& map ) const
{
// Newton - Iteration zum Invertieren der Abbildung f.
double err = 10.0 * _epsilon ;
coord3_t map_ (0.5);
#ifndef NDEBUG
int count = 0 ;
#endif
coord3_t upd ;
do {
// apply mapping
map2worldnormal (map_[0],map_[1],map_[2], upd) ;
// calculate inverse
inverse (map_) ;
const alu3d_ctype u0 = upd [0] - wld [0] ;
const alu3d_ctype u1 = upd [1] - wld [1] ;
const alu3d_ctype u2 = upd [2] - wld [2] ;
const alu3d_ctype c0 = Dfi [0][0] * u0 + Dfi [0][1] * u1 + Dfi [0][2] * u2 ;
const alu3d_ctype c1 = Dfi [1][0] * u0 + Dfi [1][1] * u1 + Dfi [1][2] * u2 ;
const alu3d_ctype c2 = Dfi [2][0] * u0 + Dfi [2][1] * u1 + Dfi [2][2] * u2 ;
map_ [0] -= c0 ;
map_ [1] -= c1 ;
map_ [2] -= c2 ;
err = std::abs (c0) + std::abs (c1) + std::abs (c2) ;
assert (count ++ < 3000);
}
while (err > _epsilon) ;
// get local coordinates
map[0] = map_[0];
map[1] = map_[1];
return ;
}
// BilinearMapping
// ---------------
template< int cdim >
alu_inline BilinearMapping< cdim >::BilinearMapping ()
: calcedMatrix_( false ),
calcedDet_( false ),
calcedInv_( false )
{
for( int i = 0; i < 4; ++i )
for( int j = 0; j < cdim; ++j )
_b[ i ][ j ] = ctype( 0 );
affine_ = true;
}
template< int cdim >
alu_inline BilinearMapping< cdim >
::BilinearMapping ( const world_t &p0, const world_t &p1,
const world_t &p2, const world_t &p3 )
{
buildMapping( p0, p1, p2, p3 );
}
template< int cdim >
alu_inline BilinearMapping< cdim >
::BilinearMapping ( const ctype (&p0)[ cdim ], const ctype (&p1)[ cdim ],
const ctype (&p2)[ cdim ], const ctype (&p3)[ cdim ] )
{
buildMapping( p0, p1, p2, p3 );
}
template< int cdim >
alu_inline bool BilinearMapping< cdim >::affine () const
{
return affine_;
}
template< int cdim >
alu_inline void BilinearMapping< cdim >::map2world ( const map_t &m, world_t &w ) const
{
map2world( m[0], m[1], w );
}
template< int cdim >
alu_inline void BilinearMapping< cdim >::map2world ( const ctype x, const ctype y, world_t &w ) const
{
const alu3d_ctype xy = x * y;
for( int i = 0; i < cdim; ++i )
w[i] = _b [0][i] + x * _b [1][i] + y * _b [2][i] + xy * _b [3][i];
}
template< int cdim >
alu_inline void BilinearMapping< cdim >::world2map ( const world_t &w, map_t &m ) const
{
world_t dw;
m[0] = m[1] = 0.5;
map2world( m, dw );
dw -= w;
alu3d_ctype step;
do {
step = 0;
for( int j = 0; j < 2; ++j )
{
world_t d;
for( int i = 0; i < cdim; ++i )
d[i] = _b [j+1][i] + m[1-j] * _b [3][i];
const ctype dd = d*d;
if( dd < ALUnumericEpsilon*ALUnumericEpsilon )
continue;
const ctype alpha = -(dw*d) / dd;
dw.axpy( alpha, d );
m[j] += alpha;
step += std::abs( alpha );
}
}
while( step > ALUnumericEpsilon );
//while( dw.two_norm2() > ALUnumericEpsilon*ALUnumericEpsilon );
}
template< int cdim >
alu_inline typename BilinearMapping< cdim >::ctype
BilinearMapping< cdim >::det ( const map_t &m ) const
{
inverse( m );
return det_;
}
template<>
alu_inline BilinearMapping< 2 >::ctype
BilinearMapping< 2 >::det ( const map_t &m ) const
{
if( !calcedDet_ )
{
map2worldlinear( m[0], m[1] );
const world_t &u = matrix_[0];
const world_t &v = matrix_[1];
det_ = std::abs( u[0] * v[1] - u[1] * v[0] );
calcedDet_ = affine();
}
return det_;
}
template<>
alu_inline BilinearMapping< 3 >::ctype
BilinearMapping< 3 >::det ( const map_t &m ) const
{
if( !calcedDet_ )
{
map2worldlinear( m[0], m[1] );
const world_t &u = matrix_[0];
const world_t &v = matrix_[1];
world_t n;
for ( int i = 0; i < 3; ++i )
n[i] = v[(i+1)%3] * u[(i+2)%3] - v[(i+2)%3] * u[(i+1)%3];
det_ = n.two_norm();
calcedDet_ = affine();
}
return det_;
}
template< int cdim >
alu_inline const typename BilinearMapping< cdim >::matrix_t &
BilinearMapping< cdim >::jacobianTransposed ( const map_t &m ) const
{
map2worldlinear( m[0], m[1] );
return matrix_;
}
template< int cdim >
alu_inline const typename BilinearMapping< cdim >::inv_t &
BilinearMapping< cdim >::jacobianInverseTransposed ( const map_t &m ) const
{
inverse( m );
return invTransposed_;
}
template< int cdim >
template< class vector_t >
alu_inline void BilinearMapping< cdim >
::buildMapping ( const vector_t &p0, const vector_t &p1,
const vector_t &p2, const vector_t &p3 )
{
for( int i = 0; i < cdim; ++i )
{
_b [0][i] = p0 [i];
_b [1][i] = p1 [i] - p0 [i];
_b [2][i] = p2 [i] - p0 [i];
_b [3][i] = p3 [i] - p2 [i] - _b [1][i];
}
ctype sum = std::abs( _b [3][0] );
for( int i = 1; i < cdim; ++i )
sum += std::abs( _b [3][i] );
affine_ = (sum < ALUnumericEpsilon );
calcedMatrix_ = calcedDet_ = calcedInv_ = false;
}
template< int cdim >
alu_inline void BilinearMapping< cdim >
::multTransposedMatrix ( const matrix_t &A, FieldMatrix< ctype, 2, 2 > &C )
{
for( int i = 0; i < 2; ++i )
{
for( int j = 0; j < 2; ++j )
{
C[i][j] = A[i][0] * A[j][0];
for( int k=1; k < cdim; ++k )
C[i][j] += A[i][k] * A[j][k];
}
}
}
template< int cdim >
alu_inline void BilinearMapping< cdim >
::multMatrix ( const matrix_t &A, const FieldMatrix< ctype, 2, 2 > &B, inv_t &C )
{
for( int i = 0; i < cdim; ++i )
for( int j = 0; j < 2; ++j )
C[i][j] = A[0][i] * B[0][j] + A[1][i] * B[1][j];
}
template< int cdim >
alu_inline void BilinearMapping< cdim >
::map2worldlinear ( const alu3d_ctype x, const alu3d_ctype y ) const
{
if( !calcedMatrix_ )
{
for( int i = 0; i < cdim; ++i )
{
matrix_[0][i] = _b [1][i] + y * _b [3][i];
matrix_[1][i] = _b [2][i] + x * _b [3][i];
}
calcedMatrix_ = affine();
}
}
template<>
alu_inline void BilinearMapping< 2 >::inverse ( const map_t &m ) const
{
if( !calcedInv_ )
{
map2worldlinear ( m[0], m[1] );
det_ = std::abs( FMatrixHelp::invertMatrix( matrix_, invTransposed_ ) );
calcedDet_ = calcedInv_ = affine();
}
}
template< int cdim >
alu_inline void BilinearMapping< cdim >::inverse ( const map_t &m ) const
{
// use least squares approach
if( !calcedInv_ )
{
FieldMatrix< ctype, 2, 2 > AT_A, inv_AT_A;
map2worldlinear ( m[0], m[1] );
multTransposedMatrix( matrix_, AT_A );
FMatrixHelp::invertMatrix( AT_A, inv_AT_A );
multMatrix( matrix_, inv_AT_A, invTransposed_ );
calcedInv_ = affine();
}
}
////////////////////////////////////////////////////////////////////////
//
// Tetra specializations
// -- tetra spec
//
////////////////////////////////////////////////////////////////////////
//- Bilinear surface mapping
// Constructor for FieldVectors
template <int cdim, int mydim>
alu_inline LinearMapping<cdim, mydim> ::
LinearMapping ()
: _matrix ( 0.0 )
, _invTransposed( 0.0 )
, _p0( 0.0 )
, _calcedInv( false )
, _calcedDet( false )
{}
// copy constructor
template <int cdim, int mydim>
alu_inline LinearMapping<cdim, mydim> ::
LinearMapping (const LinearMapping & m)
: _matrix ( m._matrix )
, _invTransposed( m._invTransposed )
, _p0( m._p0 )
, _calcedInv( m._calcedInv )
, _calcedDet( m._calcedDet )
{}
// the real constructor, this can be called for FieldVectors
// and double[3], we dont have to convert one type
template <>
template <class vector_t>
alu_inline void LinearMapping<3, 3> ::
buildMapping (const vector_t & p0, const vector_t & p1,
const vector_t & p2, const vector_t & p3 )
{
_matrix [0][0] = p1[0] - p0 [0] ;
_matrix [0][1] = p1[1] - p0 [1] ;
_matrix [0][2] = p1[2] - p0 [2] ;
_matrix [1][0] = p2[0] - p0 [0] ;
_matrix [1][1] = p2[1] - p0 [1] ;
_matrix [1][2] = p2[2] - p0 [2] ;
_matrix [2][0] = p3[0] - p0 [0] ;
_matrix [2][1] = p3[1] - p0 [1] ;
_matrix [2][2] = p3[2] - p0 [2] ;
_p0[0] = p0[0];
_p0[1] = p0[1];
_p0[2] = p0[2];
// initialize flags
_calcedDet = _calcedInv = false ;
return ;
}
// the real constructor, this can be called for FieldVectors
// and double[3], we dont have to convert one type
template <>
template <class vector_t>
alu_inline void LinearMapping<3, 2> ::
buildMapping (const vector_t & p0, const vector_t & p1,
const vector_t & p2)
{
_matrix [0][0] = p1[0] - p0 [0] ;
_matrix [0][1] = p1[1] - p0 [1] ;
_matrix [0][2] = p1[2] - p0 [2] ;
_matrix [1][0] = p2[0] - p0 [0] ;
_matrix [1][1] = p2[1] - p0 [1] ;
_matrix [1][2] = p2[2] - p0 [2] ;
_p0[0] = p0[0];
_p0[1] = p0[1];
_p0[2] = p0[2];
// initialize flags
_calcedDet = _calcedInv = false ;
return ;
}
// the real constructor,
// this can be called for FieldVectors
// and double[3], we dont have to convert one type
template <int cdim, int mydim>
template <class vector_t>
alu_inline void LinearMapping<cdim, mydim> ::
buildMapping (const vector_t & p0, const vector_t & p1)
{
assert( mydim == 1 );
_matrix [0][0] = p1[0] - p0 [0] ;
_matrix [0][1] = p1[1] - p0 [1] ;
_matrix [0][2] = p1[2] - p0 [2] ;
_p0[0] = p0[0];
_p0[1] = p0[1];
_p0[2] = p0[2];
// initialize flags
_calcedDet = _calcedInv = false ;
return ;
}
// the real constructor, this can be called for FieldVectors
// and double[3], we dont have to convert one type
template <>
template <class vector_t>
alu_inline void LinearMapping<2, 2> ::
buildMapping (const vector_t & p0,
const vector_t & p1,
const vector_t & p2)
{
_matrix [0][0] = p1[0] - p0 [0] ;
_matrix [0][1] = p1[1] - p0 [1] ;
_matrix [1][0] = p2[0] - p0 [0] ;
_matrix [1][1] = p2[1] - p0 [1] ;
_p0[0] = p0[0];
_p0[1] = p0[1];
// initialize flags
_calcedDet = _calcedInv = false ;
return ;
}
// the real constructor, this can be called for FieldVectors
// and double[3], we dont have to convert one type
template <>
template <class vector_t>
alu_inline void LinearMapping<2, 1> ::
buildMapping (const vector_t & p0, const vector_t & p1)
{
_matrix [0][0] = p1[0] - p0 [0] ;
_matrix [0][1] = p1[1] - p0 [1] ;
_p0[0] = p0[0];
_p0[1] = p0[1];
_det = std::sqrt( (_matrix [0][0] * _matrix [0][0]) +
(_matrix [0][1] * _matrix [0][1]) );
// initialize flags
_calcedDet = true;
_calcedInv = false ;
return ;
}
template<>
template< class vector_t >
alu_inline void LinearMapping< 2, 0 >::buildMapping ( const vector_t &p0 )
{
_p0[0] = p0[0];
_p0[1] = p0[1];
_det = 1.0;
// initialize flags
_calcedDet = _calcedInv = true;
}
template<>
template< class vector_t >
alu_inline void LinearMapping< 3, 0 >::buildMapping ( const vector_t &p0 )
{
_p0[0] = p0[0];
_p0[1] = p0[1];
_p0[2] = p0[2];
_det = 1.0;
// initialize flags
_calcedDet = _calcedInv = true;
}
// local --> global
template <int cdim, int mydim>
alu_inline void LinearMapping<cdim, mydim> ::
map2world (const map_t& local, world_t& global) const
{
// initialize
global = _p0;
// multiply with (transposed)
_matrix.umtv(local, global);
}
// global --> local
template <int cdim, int mydim>
alu_inline void LinearMapping<cdim, mydim> ::
world2map (const world_t& global, map_t& local) const
{
// initialize
world_t globalCoord( global );
// substract p0
globalCoord -= _p0;
// multiply with jacobian inverse transposed
jacobianInverseTransposed( local ).mtv(globalCoord, local);
}
// tetra mapping
template <int cdim, int mydim>
alu_inline void LinearMapping<cdim, mydim> ::
inverse(const map_t& local) const
{
// invert transposed matrix and return determinant
_det = std::abs( FMatrixHelp::invertMatrix(_matrix , _invTransposed ) );
// set flag
_calcedDet = _calcedInv = true ;
}
template <>
alu_inline void LinearMapping<3, 0> ::
inverse(const map_t& local) const
{
// invert transposed matrix and return determinant
_det = 1.;
// set flag
_calcedDet = _calcedInv = true ;
}
template <>
alu_inline void LinearMapping<2, 0> ::
inverse(const map_t& local) const
{
// invert transposed matrix and return determinant
_det = 1.;
// set flag
_calcedDet = _calcedInv = true ;
}
// tetra mapping
template <int cdim, int mydim>
alu_inline void LinearMapping<cdim, mydim> ::
calculateDeterminant(const map_t& local) const
{
inverse( local );
}
// triangle mapping
template <>
alu_inline void LinearMapping<3, 2> ::
inverse(const map_t& local) const
{
inverseCodimOne( local );
}
// edge mapping
template <>
alu_inline void LinearMapping<2, 1> ::
inverse(const map_t& local) const
{
inverseCodimOne( local );
}
template <>
alu_inline void LinearMapping<3, 0> ::
inverseCodimOne(const map_t& local) const
{}
template <>
alu_inline void LinearMapping<2, 0> ::
inverseCodimOne(const map_t& local) const
{}
template <int cdim, int mydim>
alu_inline void LinearMapping<cdim, mydim> ::
inverseCodimOne(const map_t& local) const
{
// use least squares approach
FieldMatrix<ctype, mydim, mydim> AT_A;
/*
inv_t matrix;
for( int i=0; i<cdim; ++i)
for( int j=0; j<mydim; ++j)
{
matrix[i][j] = _matrix[j][i];
}
*/
// calc ret = A^T*A
//FMatrixHelp::multTransposedMatrix( matrix, AT_A);
multTransposedMatrix(_matrix, AT_A );
// calc Jinv_ = A (A^T*A)^-1
FieldMatrix< ctype, mydim, mydim> inv_AT_A;
FMatrixHelp :: invertMatrix( AT_A, inv_AT_A );
//FMatrixHelp :: multMatrix( matrix, inv_AT_A, _invTransposed );
multMatrix( _matrix, inv_AT_A, _invTransposed );
// set flag
_calcedInv = true ;
}
// triangle mapping
template <>
alu_inline void LinearMapping<3, 2> ::
calculateDeterminant(const map_t& local) const
{
enum { cdim = 3 };
world_t tmpV; //! temporary memory
world_t tmpU; //! temporary memory
for(int i=0; i<cdim; ++i)
{
// p1 - p0 (see buildMapping method)
tmpV[i] = _matrix[0][i];
// p2 - p1 = (p2 - p0) - (p1 - p0)
tmpU[i] = _matrix[1][i] - _matrix[0][i];
}
world_t globalCoord;
// calculate scaled outer normal
for(int i=0; i<cdim; ++i)
{
globalCoord[i] = ( tmpV[(i+1)%cdim] * tmpU[(i+2)%cdim]
- tmpV[(i+2)%cdim] * tmpU[(i+1)%cdim] );
}
// calculate determinant
_det = globalCoord.two_norm();
// set flag
_calcedDet = true ;
}
template <int cdim, int mydim>
alu_inline void LinearMapping<cdim, mydim> ::
multTransposedMatrix(const matrix_t& matrix,
FieldMatrix<ctype, mydim, mydim>& result) const
{
typedef typename matrix_t::size_type size_type;
for(size_type i=0; i<mydim; ++i)
{
for(size_type j=0; j<mydim; ++j)
{
result[i][j] = 0.0;
for(size_type k=0; k<cdim; ++k)
{
result[i][j] += matrix[i][k] * matrix[j][k];
}
}
}
}
template <int cdim, int mydim>
alu_inline void LinearMapping<cdim, mydim> ::
multMatrix ( const matrix_t &A,
const FieldMatrix< ctype, mydim, mydim > &B,
inv_t& ret ) const
{
//! calculates ret = A * B
typedef typename matrix_t :: size_type size_type;
for( size_type i = 0; i < cdim; ++i )
{
for( size_type j = 0; j < mydim; ++j )
{
ret[ i ][ j ] = 0 ;
for( size_type k = 0; k < mydim; ++k )
ret[ i ][ j ] += A[ k ][ i ] * B[ k ][ j ];
}
}
}
// edge mapping
template <>
alu_inline void LinearMapping<3, 1> ::
inverse(const map_t& local) const
{
FieldMatrix<ctype, 1, 1> AT_A_;
// calc ret = A^T*A
multTransposedMatrix(_matrix, AT_A_ );
// calc Jinv_ = A (A^T*A)^-1
FieldMatrix< ctype, 1, 1 > inv_AT_A;
FMatrixHelp :: invertMatrix( AT_A_, inv_AT_A );
multMatrix( _matrix, inv_AT_A, _invTransposed );
// set flag
_calcedInv = true ;
}
// triangle mapping
template <>
alu_inline void LinearMapping<3, 1> ::
calculateDeterminant(const map_t& local) const
{
// calculate length
_det = std::sqrt( (_matrix[0][0] * _matrix[0][0]) +
(_matrix[0][1] * _matrix[0][1]) +
(_matrix[0][2] * _matrix[0][2]) );
// set flag
_calcedDet = true ;
}
// triangle mapping
template <>
alu_inline void LinearMapping<2, 1> ::
calculateDeterminant(const map_t& local) const
{
// calculate length
_det = std::sqrt( (_matrix[0][0] * _matrix[0][0]) +
(_matrix[0][1] * _matrix[0][1]) );
// set flag
_calcedDet = true ;
}
template <int cdim, int mydim>
alu_inline typename LinearMapping< cdim, mydim >::ctype
LinearMapping<cdim, mydim >::det( const map_t& local ) const
{
// return det if already calculated
if( _calcedDet ) return _det;
// calculate inverse
calculateDeterminant( local );
return _det;
}
template <int cdim, int mydim>
alu_inline const typename LinearMapping<cdim, mydim> :: matrix_t&
LinearMapping<cdim, mydim> ::
jacobianTransposed(const map_t & local) const
{
return _matrix;
}
template <int cdim, int mydim>
alu_inline const typename LinearMapping<cdim, mydim> :: inv_t&
LinearMapping<cdim, mydim> ::
jacobianInverseTransposed(const map_t & local) const
{
// if calculated return
if( _calcedInv ) return _invTransposed;
// calculate
inverse ( local ) ;
return _invTransposed;
}
template <>
alu_inline const LinearMapping<3, 0> :: inv_t&
LinearMapping<3, 0> ::
jacobianInverseTransposed(const map_t & local) const
{
return _invTransposed;
}
template <>
alu_inline const LinearMapping<2, 0> :: inv_t&
LinearMapping<2, 0> ::
jacobianInverseTransposed(const map_t & local) const
{
return _invTransposed;
}
#if COMPILE_ALUGRID_LIB
// Instantiation
class TrilinearMapping ;
template void TrilinearMapping::buildMapping< TrilinearMapping::coord_t >
(const TrilinearMapping::coord_t& ,
const TrilinearMapping::coord_t& ,
const TrilinearMapping::coord_t& ,
const TrilinearMapping::coord_t& ,
const TrilinearMapping::coord_t& ,
const TrilinearMapping::coord_t& ,
const TrilinearMapping::coord_t& ,
const TrilinearMapping::coord_t& );
template void TrilinearMapping::buildMapping< TrilinearMapping::double_t >
(const TrilinearMapping::double_t& ,
const TrilinearMapping::double_t& ,
const TrilinearMapping::double_t& ,
const TrilinearMapping::double_t& ,
const TrilinearMapping::double_t& ,
const TrilinearMapping::double_t& ,
const TrilinearMapping::double_t& ,
const TrilinearMapping::double_t& );
class SurfaceNormalCalculator ;
template void SurfaceNormalCalculator::buildMapping< SurfaceNormalCalculator::coord3_t >
(const SurfaceNormalCalculator::coord3_t & ,
const SurfaceNormalCalculator::coord3_t & ,
const SurfaceNormalCalculator::coord3_t & ,
const SurfaceNormalCalculator::coord3_t & );
template void SurfaceNormalCalculator::buildMapping< SurfaceNormalCalculator::double3_t >
(const SurfaceNormalCalculator::double3_t & ,
const SurfaceNormalCalculator::double3_t & ,
const SurfaceNormalCalculator::double3_t & ,
const SurfaceNormalCalculator::double3_t & );
class BilinearSurfaceMapping ;
template void BilinearSurfaceMapping::buildMapping< BilinearSurfaceMapping::coord3_t >
(const BilinearSurfaceMapping::coord3_t & ,
const BilinearSurfaceMapping::coord3_t & ,
const BilinearSurfaceMapping::coord3_t & ,
const BilinearSurfaceMapping::coord3_t & );
template void BilinearSurfaceMapping::buildMapping< BilinearSurfaceMapping::double3_t >
(const BilinearSurfaceMapping::double3_t & ,
const BilinearSurfaceMapping::double3_t & ,
const BilinearSurfaceMapping::double3_t & ,
const BilinearSurfaceMapping::double3_t & );
template class LinearMapping<3, 3> ;
template void LinearMapping<3, 3>::buildMapping< LinearMapping<3, 3>::world_t >
( const LinearMapping<3, 3>::world_t&,
const LinearMapping<3, 3>::world_t&,
const LinearMapping<3, 3>::world_t&,
const LinearMapping<3, 3>::world_t& );
template void LinearMapping<3, 3>::buildMapping< LinearMapping<3, 3>::double_t >
( const LinearMapping<3, 3>::double_t&,
const LinearMapping<3, 3>::double_t&,
const LinearMapping<3, 3>::double_t&,
const LinearMapping<3, 3>::double_t& );
template class LinearMapping<3, 2> ;
template void LinearMapping<3, 2>::buildMapping< LinearMapping<3, 2>::world_t >
( const LinearMapping<3, 2>::world_t&,
const LinearMapping<3, 2>::world_t&,
const LinearMapping<3, 2>::world_t&);
template void LinearMapping<3, 2>::buildMapping< LinearMapping<3, 2>::double_t >
( const LinearMapping<3, 2>::double_t&,
const LinearMapping<3, 2>::double_t&,
const LinearMapping<3, 2>::double_t&);
template class LinearMapping<2, 2> ;
template void LinearMapping<2, 2>::buildMapping< LinearMapping<2, 2>::world_t >
( const LinearMapping<2, 2>::world_t&,
const LinearMapping<2, 2>::world_t&,
const LinearMapping<2, 2>::world_t&);
template void LinearMapping<2, 2>::buildMapping< LinearMapping<2, 2>::double_t >
( const LinearMapping<2, 2>::double_t&,
const LinearMapping<2, 2>::double_t&,
const LinearMapping<2, 2>::double_t&);
template class LinearMapping<3, 1> ;
template void LinearMapping<3, 1>::buildMapping< LinearMapping<3, 1>::world_t >
( const LinearMapping<3, 1>::world_t&,
const LinearMapping<3, 1>::world_t& );
template void LinearMapping<3, 1>::buildMapping< LinearMapping<3, 1>::double_t >
( const LinearMapping<3, 1>::double_t&,
const LinearMapping<3, 1>::double_t& );
template class LinearMapping<2, 1> ;
template void LinearMapping<2, 1>::buildMapping< LinearMapping<2, 1>::world_t >
( const LinearMapping<2, 1>::world_t&,
const LinearMapping<2, 1>::world_t& );
template void LinearMapping<2, 1>::buildMapping< LinearMapping<2, 1>::double_t >
( const LinearMapping<2, 1>::double_t&,
const LinearMapping<2, 1>::double_t& );
/// wtf?
template void LinearMapping<2, 1>::buildMapping< LinearMapping<3, 1>::world_t >
( const LinearMapping<3, 1>::world_t&,
const LinearMapping<3, 1>::world_t& );
template class LinearMapping<3, 0> ;
template void LinearMapping<3, 0>::buildMapping< LinearMapping<3, 0>::double_t >
( const LinearMapping<3, 0>::double_t& );
template void LinearMapping<3, 0>::buildMapping< LinearMapping<3, 0>::world_t >
( const LinearMapping<3, 0>::world_t& );
template class LinearMapping<2, 0> ;
template void LinearMapping<2, 0>::buildMapping< LinearMapping<2, 0>::world_t >
( const LinearMapping<2, 0>::world_t& );
template void LinearMapping<2, 0>::buildMapping< LinearMapping<2, 0>::double_t >
( const LinearMapping<2, 0>::double_t& );
template class BilinearMapping< 2 > ;
template void BilinearMapping< 2 >::buildMapping< BilinearMapping< 2 >::world_t >
( const BilinearMapping< 2 >::world_t&,
const BilinearMapping< 2 >::world_t&,
const BilinearMapping< 2 >::world_t&,
const BilinearMapping< 2 >::world_t& );
template class BilinearMapping< 3 > ;
template void BilinearMapping< 3 >::buildMapping< BilinearMapping< 3 >::world_t >
( const BilinearMapping< 3 >::world_t&,
const BilinearMapping< 3 >::world_t&,
const BilinearMapping< 3 >::world_t&,
const BilinearMapping< 3 >::world_t& );
#endif
} // end namespace Dune
#endif // end DUNE_ALUGRID_MAPPINGS_IMP_CC
|