Element Base Class
The base class from which all other elements are derived.
Source code in FEMpy/Elements/Element.py
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 |
|
__init__(numNodes, numDim, quadratureOrder, numStates=None)
Instantiate an element object
Parameters
numNodes : int Number of nodes in the element numDim : int Number of spatial dimensions the element lives in quadratureOrder : int Integration quadrature order numStates : int, optional Number of states in the underlying PDE, a.k.a the number of DOF per node, by default uses numDim
Source code in FEMpy/Elements/Element.py
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 |
|
computeCoordinates(paramCoords, nodeCoords)
Given nodal coordinates, compute the real coordinates at given parametric coordinates within the element
Parameters
paramCoords : numPoint x numDim array Array of parametric point coordinates to compute real coordinates of nodeCoords : numElements x numNodes x numDim array Node coordinates for each element
Source code in FEMpy/Elements/Element.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
|
computeFunction(nodeCoords, nodeStates, elementDVs, function, elementReductionType, intOrder=None)
Given a function that can depend on true coordinates, the state, state gradients and some design variables, compute the value of that function over the element
Parameters
nodeCoords : numElements x numNodes x numDim array
Node coordinates for each element
nodeStates : numElements x numNodes x numStates array
State values at the nodes of each element
elementDVs : dict of numElement length arrays
Design variable values for each element
function : callable
Function to evaluate at each point within each element, must have signature f(x, u, u', dvs), where:
x is an n x numDim array of coordinates
u is an n x numStates array of state values
u' is an n x (numStates*numDim) array of state gradients
dvs is an n x numDVs array of design variable values
elementReductionType : type
Type of reduction to do to get a single value for each element, can be:
- 'sum' : sum all values
- 'mean' : average all values
- integrate
: integrate the function over the element
- 'max' : take the maximum value
- 'min' : take the minimum value
- 'ksmax' : Compute a smooth approximation of the maximum value using KS aggregation
- 'ksmin' : Compute a smooth approximation of the minimum value using KS aggregation
Returns
values : numElements array Value of the function for each element
Source code in FEMpy/Elements/Element.py
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 |
|
computeJacobians(paramCoords, nodeCoords)
Compute the Jacobian at a set of parametric coordinates within a set of elements
This function is vectorised both across multiple elements, and multiple points within each element, but the parametric coordinates are assumed to be the same across all elements
Parameters
paramCoords : numPoint x numDim array Array of parametric point coordinates to compute Jacobians at nodeCoords : numElements x numNodes x numDim array Node coordinates for each element
Returns
Jac : numElements x numPoints x numDim x numDim array The Jacobians at each point in each element
Source code in FEMpy/Elements/Element.py
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 |
|
computeResidualJacobians(nodeStates, nodeCoords, designVars, constitutiveModel, intOrder=None)
Given node coordinates and states, design variable values, and a constitutive model, compute the residual Jacobian for a bunch of elements
Parameters
nodeCoords : numElements x numNodes x numDim array Node coordinates for each element nodeStates : numElements x numNodes x numStates array State values at the nodes of each element designVars : dict of numElements arrays Design variable values for each element constitutiveModel : FEMpy constitutive model object The constitutive model of the element
Returns
numElement x (numNodes * numStates) x (numNodes * numStates) array The local residual Jacobian matrix for each element
Source code in FEMpy/Elements/Element.py
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 |
|
computeResiduals(nodeStates, nodeCoords, designVars, constitutiveModel, intOrder=None)
Compute the local residual for a series of elements
Parameters
nodeCoords : numElements x numNodes x numDim array Node coordinates for each element nodeStates : numElements x numNodes x numStates array State values at the nodes of each element designVars : dict of numElements arrays Design variable values for each element constitutiveModel : FEMpy constitutive model object The constitutive model of the element
Returns
numElement x numNodes x numStates array The local residuals for each element
Source code in FEMpy/Elements/Element.py
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 |
|
computeShapeFunctionGradients(paramCoords)
abstractmethod
Compute the derivatives of the shape functions with respect to the parametric coordinates at a given set of parametric coordinates
Parameters
paramCoords : numPoint x numDim array Array of parametric point coordinates to evaluate shape function gradients at
Returns
NPrimeParam: numPoint x numDim x numNodes array Shape function gradient values, NPrimeParam[i][j][k] is the derivative of the kth shape function at the ith point w.r.t the jth parametric coordinate
Source code in FEMpy/Elements/Element.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
computeShapeFunctions(paramCoords)
abstractmethod
Compute the shape function values at a given set of parametric coordinates
Parameters
paramCoords : numPoint x numDim array Array of parametric point coordinates to evaluate shape functions at
Returns
N: numPoint x numNodes array Array of shape function values at the given parametric coordinates, N[i][j] is the value of the jth shape function at the ith parametric point
Source code in FEMpy/Elements/Element.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
computeStateGradients(paramCoords, nodeStates, nodeCoords)
Given nodal DOF, compute the gradient of the state at given parametric coordinates within the element
The gradient of the state at each point in each element is a numStates x numDim array.
This function is vectorised both across multiple elements, and multiple points within each element, but the parametric coordinates are assumed to be the same across all elements
Parameters
paramCoords : numPoint x numDim array Array of parametric point coordinates to compute state at nodeStates : numElements x numNodes x numStates array State values at the nodes of each element nodeCoords : numElements x numNodes x numDim array Node coordinates for each element
Returns
stateGradients : numElements x numPoint x numStates x numDim array The gradient of the states at each point in each element, stateGradient[i, j, k, l] is the value of \(du_k/dx_l\) at the \(j^{th}\) point in the \(i^{th}\) element
Source code in FEMpy/Elements/Element.py
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 |
|
computeStates(paramCoords, nodeStates)
Given nodal DOF, compute the state at given parametric coordinates within the element
This function is vectorised both across multiple elements, and multiple points within each element, but the parametric coordinates are assumed to be the same across all elements
Parameters
paramCoords : numPoint x numDim array Array of parametric point coordinates to compute state at nodeStates : numElements x numNodes x numStates array State values at the nodes of each element
Returns
states : numElements x numPoint x numStates array State values at the given parametric coordinates for each element
Source code in FEMpy/Elements/Element.py
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 |
|
getClosestPoints(nodeCoords, point, **kwargs)
Given real coordinates of a point, find the parametric coordinates of the closest point on a series of elements to that point
Computing the closest point is an optimization problem of the form:
min ||X(x) - P||^2
s.t Ax <= b lb <= x <= ub
Where X are the real coordinates of a point in the element, x the parametric coordinates of that point, and P is the target point. lb <= x <= ub and Ax <= b are a set of bounds and linear constraints on the parametric coordinates that encode the bounds of the element.
Parameters
nodeCoords : numElements x numNodes x numDim array The coordinates of the elements point : array of length numDim Target point coordinates
Returns
closestParamCoords : numElements x numDim array The parametric coordinates of the closest point in each element closestDistances : numElements array The distances from the closest point in each element to the target point
Source code in FEMpy/Elements/Element.py
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 |
|
getIntegrationPointCoords(order=None)
abstractmethod
Compute the integration point parameteric coordinates for a given quadrature order on this element
Parameters
order : int, optional Integration order
Returns
numIntpoint x numDim array Integration point coordinates
Source code in FEMpy/Elements/Element.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
getIntegrationPointWeights(order=None)
abstractmethod
Compute the integration point weights for a given quadrature order on this element
Parameters
order : int, optional Integration order
Returns
array of length numIntpoint Integration point weights
Source code in FEMpy/Elements/Element.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
getRandParamCoord(n, rng=None)
Get a random set of parametric coordinates within the element
By default this method assumes the the valid parametric coordinates are between -1 and 1 in each direction. If this is not the case for a particular element then that element should reimplemnt this method.
Parameters
n : int Number of points to generate rng : numpy random Generator, optional Random number generator to use, useful for creating consistent test behaviour, by default None, in which case a new one is created for this call
Source code in FEMpy/Elements/Element.py
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
|
getRandomElementCoordinates(rng=None)
Compute random node coordinates for an element
The random node coordinates are computed by taking the reference element coordinates and then applying: - Random perturbations to each node - Random translation in each dimension - Random scalings in each dimension - Random rotations around each available axis
Parameters
rng : numpy random Generator, optional Random number generator to use, useful for creating consistent test behaviour, by default None, in which case a new one is created for this call
Source code in FEMpy/Elements/Element.py
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 |
|
getReferenceElementCoordinates()
abstractmethod
Get the node coordinates for the reference element, a.k.a the element on which the shape functions are defined
Returns
numNodes x numDim array Element node coordinates
Source code in FEMpy/Elements/Element.py
149 150 151 152 153 154 155 156 157 158 |
|
testGetClosestPoints(n=10, tol=1e-10, rng=None)
Test the getClosestPoints method
This test works by generating a set of random parametric coordinates, converting them to real coordinates, and then checking that the parametric coordinates returned by getClosestPoints match the original random values.
Parameters
n : int, optional Number of random coordinates to generate, by default 10 rng : numpy random Generator, optional Random number generator to use, useful for creating consistent test behaviour, by default None, in which case a new one is created for this call
Source code in FEMpy/Elements/Element.py
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 |
|
testIdentityJacobian(n=10, rng=None)
Validate that, when the element geometry matches the reference element exactly, the mapping Jacobian is the identity matrix everywhere.
Parameters
n : int, optional Number of points to test at, by default 10 rng : numpy random Generator, optional Random number generator to use, useful for creating consistent test behaviour, by default None, in which case a new one is created for this call
Source code in FEMpy/Elements/Element.py
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 |
|
testInterpolation(n=10, rng=None)
Validate that, when the element geometry matches the reference element exactly, the parametric and real coordinates are the same
Parameters
n : int, optional Number of points to test at, by default 10 rng : numpy random Generator, optional Random number generator to use, useful for creating consistent test behaviour, by default None, in which case a new one is created for this call
Source code in FEMpy/Elements/Element.py
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 |
|
testShapeFunctionDerivatives(n=10, rng=None)
Test the implementation of the shape function derivatives using the complex-step method
Parameters
n : int, optional Number of random coordinates to generate, by default 10 rng : numpy random Generator, optional Random number generator to use, useful for creating consistent test behaviour, by default None, in which case a new one is created for this call
Source code in FEMpy/Elements/Element.py
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
|
testShapeFunctionSum(n=10, rng=None)
Test the basic property that shape function values should sum to 1 everywhere within an element
Parameters
n : int, optional Number of points to test at, by default 10 rng : numpy random Generator, optional Random number generator to use, useful for creating consistent test behaviour, by default None, in which case a new one is created for this call
Source code in FEMpy/Elements/Element.py
802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
|
testStateGradient(n=10, rng=None)
Test that the state gradient is correctly reconstructed within the element
This test works by generating random node coordinates, then computing the states at each node using the following equation:
u_i = a_i * x + b_i * y + c_i * z + d_i
This field has a gradient, du/dx, of [a_i, b_i, c_i] everywhere in the element, which should be exactly reproduced by the state gradient computed by the element.
Parameters
n : int, optional description, by default 10 rng : numpy random Generator, optional Random number generator to use, useful for creating consistent test behaviour, by default None, in which case a new one is created for this call
Source code in FEMpy/Elements/Element.py
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 |
|