/usr/lib/python2.7/dist-packages/openturns/geom.py is in python-openturns 1.9-5.
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 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 | # This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.12
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
"""Geometrical classes."""
from sys import version_info as _swig_python_version_info
if _swig_python_version_info >= (2, 7, 0):
def swig_import_helper():
import importlib
pkg = __name__.rpartition('.')[0]
mname = '.'.join((pkg, '_geom')).lstrip('.')
try:
return importlib.import_module(mname)
except ImportError:
return importlib.import_module('_geom')
_geom = swig_import_helper()
del swig_import_helper
elif _swig_python_version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_geom', [dirname(__file__)])
except ImportError:
import _geom
return _geom
try:
_mod = imp.load_module('_geom', fp, pathname, description)
finally:
if fp is not None:
fp.close()
return _mod
_geom = swig_import_helper()
del swig_import_helper
else:
import _geom
del _swig_python_version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
try:
import builtins as __builtin__
except ImportError:
import __builtin__
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr(self, class_type, name):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except __builtin__.Exception:
class _object:
pass
_newclass = 0
class SwigPyIterator(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name)
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr
__swig_destroy__ = _geom.delete_SwigPyIterator
__del__ = lambda self: None
def value(self):
return _geom.SwigPyIterator_value(self)
def incr(self, n=1):
return _geom.SwigPyIterator_incr(self, n)
def decr(self, n=1):
return _geom.SwigPyIterator_decr(self, n)
def distance(self, x):
return _geom.SwigPyIterator_distance(self, x)
def equal(self, x):
return _geom.SwigPyIterator_equal(self, x)
def copy(self):
return _geom.SwigPyIterator_copy(self)
def next(self):
return _geom.SwigPyIterator_next(self)
def __next__(self):
return _geom.SwigPyIterator___next__(self)
def previous(self):
return _geom.SwigPyIterator_previous(self)
def advance(self, n):
return _geom.SwigPyIterator_advance(self, n)
def __eq__(self, x):
return _geom.SwigPyIterator___eq__(self, x)
def __ne__(self, x):
return _geom.SwigPyIterator___ne__(self, x)
def __iadd__(self, n):
return _geom.SwigPyIterator___iadd__(self, n)
def __isub__(self, n):
return _geom.SwigPyIterator___isub__(self, n)
def __add__(self, n):
return _geom.SwigPyIterator___add__(self, n)
def __sub__(self, *args):
return _geom.SwigPyIterator___sub__(self, *args)
def __iter__(self):
return self
SwigPyIterator_swigregister = _geom.SwigPyIterator_swigregister
SwigPyIterator_swigregister(SwigPyIterator)
GCC_VERSION = _geom.GCC_VERSION
class TestFailed:
"""TestFailed is used to raise an uniform exception in tests."""
__type = "TestFailed"
def __init__(self, reason=""):
self.reason = reason
def type(self):
return TestFailed.__type
def what(self):
return self.reason
def __str__(self):
return TestFailed.__type + ": " + self.reason
def __lshift__(self, ch):
self.reason += ch
return self
import openturns.common
import openturns.typ
import openturns.graph
class DomainImplementationTypedInterfaceObject(openturns.common.InterfaceObject):
__swig_setmethods__ = {}
for _s in [openturns.common.InterfaceObject]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DomainImplementationTypedInterfaceObject, name, value)
__swig_getmethods__ = {}
for _s in [openturns.common.InterfaceObject]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, DomainImplementationTypedInterfaceObject, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _geom.new_DomainImplementationTypedInterfaceObject(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
def getImplementation(self, *args):
"""
Accessor to the underlying implementation.
Returns
-------
impl : Implementation
The implementation class.
"""
return _geom.DomainImplementationTypedInterfaceObject_getImplementation(self, *args)
def setName(self, name):
"""
Accessor to the object's name.
Parameters
----------
name : str
The name of the object.
"""
return _geom.DomainImplementationTypedInterfaceObject_setName(self, name)
def getName(self):
"""
Accessor to the object's name.
Returns
-------
name : str
The name of the object.
"""
return _geom.DomainImplementationTypedInterfaceObject_getName(self)
def __eq__(self, other):
return _geom.DomainImplementationTypedInterfaceObject___eq__(self, other)
__swig_destroy__ = _geom.delete_DomainImplementationTypedInterfaceObject
__del__ = lambda self: None
DomainImplementationTypedInterfaceObject_swigregister = _geom.DomainImplementationTypedInterfaceObject_swigregister
DomainImplementationTypedInterfaceObject_swigregister(DomainImplementationTypedInterfaceObject)
class Domain(DomainImplementationTypedInterfaceObject):
"""
Domain.
Available constructors:
Domain(*lowerBound, upperBound*)
Parameters
----------
lowerBound, upperBound : sequence of float of dimension *dim*
Define a finite :class:`interval <openturns.Interval>`
:math:`[lowerBound_0, upperBound_0]\\times \\dots \\times [lowerBound_{dim-1}, upperBound_{dim-1}]`.
It is allowed to have :math:`lowerBound_i \\geq upperBound_i` for some
:math:`i`: it simply defines an empty interval.
By default, an empty interval is created.
Notes
-----
A Domain object can be created through its derived classes:
- :class:`~openturns.Mesh`
- :class:`~openturns.RegularGrid`
- :class:`~openturns.Interval`
- :class:`~openturns.LevelSet`
Examples
--------
>>> import openturns as ot
>>> # Create the interval [a, b]
>>> a = 1
>>> b = 3
>>> print(ot.Domain([a], [b]))
[1, 3]
>>> print(ot.Domain(ot.Interval(a, b)))
[1, 3]
"""
__swig_setmethods__ = {}
for _s in [DomainImplementationTypedInterfaceObject]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, Domain, name, value)
__swig_getmethods__ = {}
for _s in [DomainImplementationTypedInterfaceObject]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, Domain, name)
__repr__ = _swig_repr
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _geom.Domain_getClassName(self)
def isEmpty(self):
"""
Test whether the domain is empty or not.
Returns
-------
isInside : bool
*True* if the interior of the geometric domain is empty.
"""
return _geom.Domain_isEmpty(self)
def isNumericallyEmpty(self):
"""
Check if the domain is numerically empty.
Returns
-------
isInside : bool
Flag telling whether the domain is numerically empty, i.e. if its numerical
volume is inferior or equal to :math:`\\epsilon` (defined in the
:class:`~openturns.ResourceMap`:
:math:`\\epsilon` = DomainImplementation-SmallVolume).
Examples
--------
>>> import openturns as ot
>>> domain = ot.Domain([1.0, 2.0], [1.0, 2.0])
>>> print(domain.isNumericallyEmpty())
True
"""
return _geom.Domain_isNumericallyEmpty(self)
def contains(self, point):
"""
Check if the given point is inside of the domain.
Parameters
----------
point : sequence of float
Point with the same dimension as the current domain's dimension.
Returns
-------
isInside : bool
Flag telling whether the given point is inside of the domain.
"""
return _geom.Domain_contains(self, point)
def numericallyContains(self, point):
"""
Check if the given point is inside of the discretization of the domain.
Parameters
----------
point : sequence of float
Point with the same dimension as the current domain's dimension.
Returns
-------
isInside : bool
Flag telling whether the point is inside the discretized domain associated
to the domain. For now, by default, the discretized domain is equal to the
geometrical domain.
"""
return _geom.Domain_numericallyContains(self, point)
def getNumericalVolume(self):
"""
Get the volume of the domain.
Returns
-------
volume : float
Volume of the underlying mesh which is the discretization of the domain.
For now, by default, it is equal to the geometrical volume.
"""
return _geom.Domain_getNumericalVolume(self)
def getVolume(self):
"""
Get the geometric volume of the domain.
Returns
-------
volume : float
Geometrical volume of the domain.
"""
return _geom.Domain_getVolume(self)
def getDimension(self):
"""
Get the dimension of the domain.
Returns
-------
dim : int
Dimension of the domain.
"""
return _geom.Domain_getDimension(self)
def getLowerBound(self):
"""
Get the lower bound of the domain.
Returns
-------
lower : :class:`~openturns.Point`
The lower bound of an axes-aligned bounding box of the domain.
"""
return _geom.Domain_getLowerBound(self)
def getUpperBound(self):
"""
Get the upper bound of the domain.
Returns
-------
upper : :class:`~openturns.Point`
The upper bound of an axes-aligned bounding box of the domain.
"""
return _geom.Domain_getUpperBound(self)
def __init__(self, *args):
this = _geom.new_Domain(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _geom.delete_Domain
__del__ = lambda self: None
Domain_swigregister = _geom.Domain_swigregister
Domain_swigregister(Domain)
class IndicesCollection(_object):
"""
Collection.
Examples
--------
>>> import openturns as ot
- Collection of **real values**:
>>> ot.ScalarCollection(2)
[0,0]
>>> ot.ScalarCollection(2, 3.25)
[3.25,3.25]
>>> vector = ot.ScalarCollection([2.0, 1.5, 2.6])
>>> vector
[2,1.5,2.6]
>>> vector[1] = 4.2
>>> vector
[2,4.2,2.6]
>>> vector.add(3.8)
>>> vector
[2,4.2,2.6,3.8]
- Collection of **complex values**:
>>> ot.ComplexCollection(2)
[(0,0),(0,0)]
>>> ot.ComplexCollection(2, 3+4j)
[(3,4),(3,4)]
>>> vector = ot.ComplexCollection([2+3j, 1-4j, 3.0])
>>> vector
[(2,3),(1,-4),(3,0)]
>>> vector[1] = 4+3j
>>> vector
[(2,3),(4,3),(3,0)]
>>> vector.add(5+1j)
>>> vector
[(2,3),(4,3),(3,0),(5,1)]
- Collection of **booleans**:
>>> ot.BoolCollection(3)
[0,0,0]
>>> ot.BoolCollection(3, 1)
[1,1,1]
>>> vector = ot.BoolCollection([0, 1, 0])
>>> vector
[0,1,0]
>>> vector[1] = 0
>>> vector
[0,0,0]
>>> vector.add(1)
>>> vector
[0,0,0,1]
- Collection of **distributions**:
>>> print(ot.DistributionCollection(2))
[Uniform(a = -1, b = 1),Uniform(a = -1, b = 1)]
>>> print(ot.DistributionCollection(2, ot.Gamma(2.75, 1.0)))
[Gamma(k = 2.75, lambda = 1, gamma = 0),Gamma(k = 2.75, lambda = 1, gamma = 0)]
>>> vector = ot.DistributionCollection([ot.Normal(), ot.Uniform()])
>>> print(vector)
[Normal(mu = 0, sigma = 1),Uniform(a = -1, b = 1)]
>>> vector[1] = ot.Uniform(-0.5, 1)
>>> print(vector)
[Normal(mu = 0, sigma = 1),Uniform(a = -0.5, b = 1)]
>>> vector.add(ot.Gamma(2.75, 1.0))
>>> print(vector)
[Normal(mu = 0, sigma = 1),Uniform(a = -0.5, b = 1),Gamma(k = 2.75, lambda = 1, gamma = 0)]
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, IndicesCollection, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, IndicesCollection, name)
__swig_destroy__ = _geom.delete_IndicesCollection
__del__ = lambda self: None
def clear(self):
"""
Reset the collection to zero dimension.
Examples
--------
>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.clear()
>>> x
class=Point name=Unnamed dimension=0 values=[]
"""
return _geom.IndicesCollection_clear(self)
def __len__(self):
return _geom.IndicesCollection___len__(self)
def __eq__(self, rhs):
return _geom.IndicesCollection___eq__(self, rhs)
def __contains__(self, val):
return _geom.IndicesCollection___contains__(self, val)
def __getitem__(self, i):
return _geom.IndicesCollection___getitem__(self, i)
def __setitem__(self, i, val):
return _geom.IndicesCollection___setitem__(self, i, val)
def __delitem__(self, i):
return _geom.IndicesCollection___delitem__(self, i)
def at(self, *args):
"""
Access to an element of the collection.
Parameters
----------
index : positive int
Position of the element to access.
Returns
-------
element : type depends on the type of the collection
Element of the collection at the position *index*.
"""
return _geom.IndicesCollection_at(self, *args)
def add(self, *args):
"""
Append a component (in-place).
Parameters
----------
value : type depends on the type of the collection.
The component to append.
Examples
--------
>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.add(1.)
>>> print(x)
[0,0,1]
"""
return _geom.IndicesCollection_add(self, *args)
def getSize(self):
"""
Get the collection's dimension (or size).
Returns
-------
n : int
The number of components in the collection.
"""
return _geom.IndicesCollection_getSize(self)
def resize(self, newSize):
"""
Change the size of the collection.
Parameters
----------
newSize : positive int
New size of the collection.
Notes
-----
If the new size is smaller than the older one, the last elements are thrown
away, else the new elements are set to the default value of the element type.
Examples
--------
>>> import openturns as ot
>>> x = ot.Point(2, 4)
>>> print(x)
[4,4]
>>> x.resize(1)
>>> print(x)
[4]
>>> x.resize(4)
>>> print(x)
[4,0,0,0]
"""
return _geom.IndicesCollection_resize(self, newSize)
def isEmpty(self):
"""
Tell if the collection is empty.
Returns
-------
isEmpty : bool
*True* if there is no element in the collection.
Examples
--------
>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.isEmpty()
False
>>> x.clear()
>>> x.isEmpty()
True
"""
return _geom.IndicesCollection_isEmpty(self)
def __repr__(self):
return _geom.IndicesCollection___repr__(self)
def __str__(self, *args):
return _geom.IndicesCollection___str__(self, *args)
def __init__(self, *args):
this = _geom.new_IndicesCollection(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
IndicesCollection_swigregister = _geom.IndicesCollection_swigregister
IndicesCollection_swigregister(IndicesCollection)
class IndicesPersistentCollection(openturns.common.PersistentObject, IndicesCollection):
__swig_setmethods__ = {}
for _s in [openturns.common.PersistentObject, IndicesCollection]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, IndicesPersistentCollection, name, value)
__swig_getmethods__ = {}
for _s in [openturns.common.PersistentObject, IndicesCollection]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, IndicesPersistentCollection, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _geom.IndicesPersistentCollection_getClassName(self)
def __init__(self, *args):
this = _geom.new_IndicesPersistentCollection(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
def __repr__(self):
return _geom.IndicesPersistentCollection___repr__(self)
def __str__(self, *args):
return _geom.IndicesPersistentCollection___str__(self, *args)
__swig_destroy__ = _geom.delete_IndicesPersistentCollection
__del__ = lambda self: None
IndicesPersistentCollection_swigregister = _geom.IndicesPersistentCollection_swigregister
IndicesPersistentCollection_swigregister(IndicesPersistentCollection)
class BipartiteGraph(IndicesPersistentCollection):
"""
Bipartite red/black graph.
Available constructors:
BipartiteGraph(*size=0*)
BipartiteGraph(*sequence*)
Parameters
----------
size : int, :math:`size \\geq 0`
Size of the collection.
sequence : sequence of :class:`~openturns.Indices`
Cliques of the red nodes.
Notes
-----
A bipartite graph is an undirected graph in which the nodes can be colored in two colors such that no edge has its two ends with the same colors. Here we force the :math:`n` red nodes to be numbered in consecutive order from 0 to :math:`n-1` and for each red node we give the list of black nodes that are the other end of the edges starting from this red node.
Examples
--------
>>> import openturns as ot
Use the first constructor:
>>> ot.BipartiteGraph(3)
[[],[],[]]
Use the second constructor:
>>> graph = ot.BipartiteGraph([[1, 3], [2, 0], [5, 4]])
>>> graph
[[1,3],[2,0],[5,4]]
Use some functionalities:
>>> graph[1] = [3, 4]
>>> graph
[[1,3],[3,4],[5,4]]
>>> graph.add([1, 6])
>>> graph
[[1,3],[3,4],[5,4],[1,6]]
"""
__swig_setmethods__ = {}
for _s in [IndicesPersistentCollection]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, BipartiteGraph, name, value)
__swig_getmethods__ = {}
for _s in [IndicesPersistentCollection]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, BipartiteGraph, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _geom.BipartiteGraph_getClassName(self)
def getRedNodes(self):
"""
Accessor to the graph red nodes.
Returns
-------
red : sequence of int, :class:`~openturns.Indices`
"""
return _geom.BipartiteGraph_getRedNodes(self)
def getBlackNodes(self):
"""
Accessor to the graph black nodes.
Returns
-------
black : sequence of int, :class:`~openturns.Indices`
"""
return _geom.BipartiteGraph_getBlackNodes(self)
def draw(self):
"""
Draw the graph.
Returns
-------
graph : a :class:`~openturns.Graph`
View of the bipartite graph as a set of red nodes linked to black nodes.
"""
return _geom.BipartiteGraph_draw(self)
__swig_destroy__ = _geom.delete_BipartiteGraph
__del__ = lambda self: None
def __repr__(self):
return _geom.BipartiteGraph___repr__(self)
def __str__(self, *args):
return _geom.BipartiteGraph___str__(self, *args)
def __init__(self, *args):
this = _geom.new_BipartiteGraph(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
BipartiteGraph_swigregister = _geom.BipartiteGraph_swigregister
BipartiteGraph_swigregister(BipartiteGraph)
class Mesh(openturns.typ.DomainImplementation):
"""
Mesh.
Available constructors:
Mesh(*dim=1*)
Mesh(*vertices*)
Mesh(*vertices, simplices*)
Parameters
----------
dim : int, :math:`dim \\geq 0`
The dimension of the vertices. By default, it creates only one
vertex of dimension :math:`dim` with components equal to 0.
vertices : 2-d sequence of float
Vertices' coordinates in :math:`\\Rset^{dim}`.
simplices : 2-d sequence of int
List of simplices defining the topology of the mesh. The simplex
:math:`[i_1, \\dots, i_{dim+1}]` connects the vertices of indices
:math:`(i_1, \\dots, i_{dim+1})` in :math:`\\Rset^{dim}`. In dimension 1, a
simplex is an interval :math:`[i_1, i_2]`; in dimension 2, it is a
triangle :math:`[i_1, i_2, i_3]`.
See also
--------
RegularGrid
Examples
--------
>>> import openturns as ot
>>> # Define the vertices of the mesh
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [1.5, 1.0]]
>>> # Define the simplices of the mesh
>>> simplices = [[0, 1, 2], [1, 2, 3]]
>>> # Create the mesh of dimension 2
>>> mesh2d = ot.Mesh(vertices, simplices)
"""
__swig_setmethods__ = {}
for _s in [openturns.typ.DomainImplementation]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, Mesh, name, value)
__swig_getmethods__ = {}
for _s in [openturns.typ.DomainImplementation]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, Mesh, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _geom.Mesh_getClassName(self)
def contains(self, point):
"""
Check if the given point is inside of the domain.
Parameters
----------
point : sequence of float
Point with the same dimension as the current domain's dimension.
Returns
-------
isInside : bool
Flag telling whether the given point is inside of the domain.
"""
return _geom.Mesh_contains(self, point)
def getDescription(self):
"""
Get the description of the vertices.
Returns
-------
description : str
Description of the vertices.
Examples
--------
>>> import openturns as ot
>>> mesh = ot.Mesh()
>>> vertices = ot.Sample([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]])
>>> vertices.setDescription(['X', 'Y'])
>>> mesh.setVertices(vertices)
>>> print(mesh.getDescription())
[X,Y]
"""
return _geom.Mesh_getDescription(self)
def getVerticesNumber(self):
"""
Get the number of vertices of the mesh.
Returns
-------
number : int
Number of vertices of the mesh.
"""
return _geom.Mesh_getVerticesNumber(self)
def getSimplicesNumber(self):
"""
Get the number of simplices of the mesh.
Returns
-------
number : int
Number of simplices of the mesh.
"""
return _geom.Mesh_getSimplicesNumber(self)
def getNearestVertexAndSimplexIndicesWithCoordinates(self, point):
"""
Get the index of the nearest vertex of a given point and the containing simplex if any, and returns its barycentric coordinates.
Parameters
----------
point : sequence of float
Point of dimension :math:`dim`, the dimension of the vertices of the mesh.
Returns
-------
indices : :class:`~openturns.Indices`
Collecton of 1 or 2 integers, the first one being the index of the vertex the closest to the given point and the second one the index of the containing simplex if the given point is inside of the mesh.
coordinates : :class:`~openturns.Point`
The barycentric coordinates of the given point wrt the vertices of the containing simplex. It is of dimension 0 if the point is not contained into the mesh.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplex = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplex)
>>> # Create a point A inside the simplex
>>> pointA = [0.6, 0.3]
>>> print(mesh2d.getNearestVertexAndSimplexIndicesWithCoordinates(pointA))
[[1,0], class=Point name=Unnamed dimension=3 values=[0.4,0.3,0.3]]
>>> # Create a point B outside the simplex
>>> pointB = [1.1, 0.6]
>>> print(mesh2d.getNearestVertexAndSimplexIndicesWithCoordinates(pointB))
[[2], class=Point name=Unnamed dimension=0 values=[]]
"""
return _geom.Mesh_getNearestVertexAndSimplexIndicesWithCoordinates(self, point)
def getNearestVertexIndex(self, *args):
"""
Get the index of the nearest vertex of a given point.
Parameters
----------
point : sequence of float
Point of dimension :math:`dim`, the dimension of the vertices of the mesh.
Returns
-------
index : int
Index of the simplex the nearest of *point* according to the Euclidean
norm.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplices = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> point = [0.9, 0.4]
>>> print(mesh2d.getNearestVertexIndex(point))
1
"""
return _geom.Mesh_getNearestVertexIndex(self, *args)
def getNearestVertex(self, *args):
"""
Get the nearest vertex of a given point.
Parameters
----------
point : sequence of float
Point of dimension :math:`dim`, the dimension of the vertices of the mesh.
Returns
-------
vertex : :class:`~openturns.Point`
Coordinates of the nearest vertex of *point*.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplices = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> point = [0.9, 0.4]
>>> print(mesh2d.getNearestVertex(point))
[1,0]
"""
return _geom.Mesh_getNearestVertex(self, *args)
def getVerticesToSimplicesMap(self):
"""
Accessor to the map between vertices and simplices.
Returns
-------
verticesSimplicesMap : :class:`~openturns.IndicesCollection`
For each vertex, list the vertices indices it belongs to.
"""
return _geom.Mesh_getVerticesToSimplicesMap(self)
def computeWeights(self):
"""
Compute an approximation of an integral defined over the mesh.
Returns
-------
weights : :class:`~openturns.Point`
Weights such that an integral of a function over the mesh
is a weighted sum of its values at the vertices.
"""
return _geom.Mesh_computeWeights(self)
def __eq__(self, rhs):
return _geom.Mesh___eq__(self, rhs)
def isValid(self):
"""
Check the mesh validity.
Returns
-------
validity : bool
Tells if the mesh is valid i.e. if there is non-overlaping simplices,
no unused vertex, no simplices with duplicate vertices and no coincident
vertices.
"""
return _geom.Mesh_isValid(self)
def checkPointInSimplex(self, point, index):
"""
Check if a point is inside a simplex.
Parameters
----------
point : sequence of float
Point of dimension :math:`dim`, the dimension of the vertices of the mesh.
index : int
Integer characterizes one simplex of the mesh.
Returns
-------
isInside : bool
Flag telling whether *point* is inside the simplex of index *index*.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplex = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplex)
>>> # Create a point A inside the simplex
>>> pointA = [0.6, 0.3]
>>> print(mesh2d.checkPointInSimplex(pointA, 0))
True
>>> # Create a point B outside the simplex
>>> pointB = [1.1, 0.6]
>>> print(mesh2d.checkPointInSimplex(pointB, 0))
False
"""
return _geom.Mesh_checkPointInSimplex(self, point, index)
def checkPointInSimplexWithCoordinates(self, point, index):
"""
Check if a point is inside a simplex and returns its barycentric coordinates.
Parameters
----------
point : sequence of float
Point of dimension :math:`dim`, the dimension of the vertices of the mesh.
index : int
Integer characterizes one simplex of the mesh.
Returns
-------
isInside : bool
Flag telling whether *point* is inside the simplex of index *index*.
coordinates : :class:`~openturns.Point`
The barycentric coordinates of the given point wrt the vertices of the simplex
.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplex = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplex)
>>> # Create a point A inside the simplex
>>> pointA = [0.6, 0.3]
>>> print(mesh2d.checkPointInSimplexWithCoordinates(pointA, 0))
[True, class=Point name=Unnamed dimension=3 values=[0.4,0.3,0.3]]
>>> # Create a point B outside the simplex
>>> pointB = [1.1, 0.6]
>>> print(mesh2d.checkPointInSimplexWithCoordinates(pointB, 0))
[False, class=Point name=Unnamed dimension=3 values=[-0.1,0.5,0.6]]
"""
return _geom.Mesh_checkPointInSimplexWithCoordinates(self, point, index)
def getVertices(self):
"""
Get the vertices of the mesh.
Returns
-------
vertices : :class:`~openturns.Sample`
Coordinates in :math:`\\Rset^{dim}` of the vertices,
where :math:`dim` is the dimension of the vertices of the mesh.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplices = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> print(mesh2d.getVertices())
0 : [ 0 0 ]
1 : [ 1 0 ]
2 : [ 1 1 ]
"""
return _geom.Mesh_getVertices(self)
def setVertices(self, vertices):
"""
Set the vertices of the mesh.
Parameters
----------
vertices : 2-d sequence of float
Cordinates in :math:`\\Rset^{dim}` of the vertices,
where :math:`dim` is the dimension of the vertices of the mesh.
Examples
--------
>>> import openturns as ot
>>> mesh = ot.Mesh()
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> mesh.setVertices(vertices)
"""
return _geom.Mesh_setVertices(self, vertices)
def getVertex(self, index):
"""
Get the vertex of a given index.
Parameters
----------
index : int
Index characterizing one vertex of the mesh.
Returns
-------
vertex : :class:`~openturns.Point`
Coordinates in :math:`\\Rset^{dim}` of the vertex of index *index*,
where :math:`dim` is the dimension of the vertices of the mesh.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplices = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> print(mesh2d.getVertex(1))
[1,0]
>>> print(mesh2d.getVertex(0))
[0,0]
"""
return _geom.Mesh_getVertex(self, index)
def setVertex(self, index, vertex):
"""
Set a vertex of a given index.
Parameters
----------
index : int
Index of the vertex to set.
vertex : sequence of float
Cordinates in :math:`\\Rset^{dim}` of the vertex of index *index*,
where :math:`dim` is the dimension of the vertices of the mesh.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplices = [[0, 1, 2]]
>>> mesh = ot.Mesh(vertices, simplices)
>>> vertex = [0.0, 0.5]
>>> mesh.setVertex(0, vertex)
>>> print(mesh.getVertices())
0 : [ 0 0.5 ]
1 : [ 1 0 ]
2 : [ 1 1 ]
"""
return _geom.Mesh_setVertex(self, index, vertex)
def getSimplices(self):
"""
Get the simplices of the mesh.
Returns
-------
indicesCollection : collection of :class:`~openturns.Indices`
List of indices defining all the simplices. The simplex
:math:`[i_1, \\dots, i_{n+1}]` relies the vertices of index
:math:`(i_1, \\dots, i_{n+1})` in :math:`\\Rset^{dim}`. In dimension 1, a
simplex is an interval :math:`[i_1, i_2]`; in dimension 2, it is a
triangle :math:`[i_1, i_2, i_3]`.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [1.5, 1.0]]
>>> simplices = [[0, 1, 2], [1, 2, 3]]
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> print(mesh2d.getSimplices())
[[0,1,2],[1,2,3]]
"""
return _geom.Mesh_getSimplices(self)
def setSimplices(self, simplices):
"""
Set the simplices of the mesh.
Parameters
----------
indices : 2-d sequence of int
List of indices defining all the simplices. The simplex
:math:`[i_1, \\dots, i_{n+1}]` relies the vertices of index
:math:`(i_1, \\dots, i_{n+1})` in :math:`\\Rset^{dim}`. In dimension 1, a
simplex is an interval :math:`[i_1, i_2]`; in dimension 2, it is a
triangle :math:`[i_1, i_2, i_3]`.
Examples
--------
>>> import openturns as ot
>>> mesh = ot.Mesh()
>>> simplices = [[0, 1, 2], [1, 2, 3]]
>>> mesh.setSimplices(simplices)
"""
return _geom.Mesh_setSimplices(self, simplices)
def getSimplex(self, index):
"""
Get the simplex of a given index.
Parameters
----------
index : int
Index characterizing one simplex of the mesh.
Returns
-------
indices : :class:`~openturns.Indices`
Indices defining the simplex of index *index*. The simplex
:math:`[i_1, \\dots, i_{n+1}]` relies the vertices of index
:math:`(i_1, \\dots, i_{n+1})` in :math:`\\Rset^{dim}`. In dimension 1, a
simplex is an interval :math:`[i_1, i_2]`; in dimension 2, it is a
triangle :math:`[i_1, i_2, i_3]`.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [1.5, 1.0]]
>>> simplices = [[0, 1, 2], [1, 2, 3]]
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> print(mesh2d.getSimplex(0))
[0,1,2]
>>> print(mesh2d.getSimplex(1))
[1,2,3]
"""
return _geom.Mesh_getSimplex(self, index)
def computeSimplexVolume(self, index):
"""
Compute the volume of a given simplex.
Parameters
----------
index : int
Integer characterizes one simplex of the mesh.
Returns
-------
volume : float
Volume of the simplex of index *index*.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplex = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplex)
>>> print(mesh2d.computeSimplexVolume(0))
0.5
"""
return _geom.Mesh_computeSimplexVolume(self, index)
def computeP1Gram(self):
"""
Compute the P1 Lagrange finite element gram matrix of the mesh.
Returns
-------
gram : :class:`~openturns.CovarianceMatrix`
P1 Lagrange finite element gram matrix of the mesh.
Notes
-----
The P1 Lagrange finite element space associated to a mesh with vertices :math:`(\\vect{x}_i)_{i=1,\\hdots,n}` is the space of piecewise-linear functions generated by the functions :math:`(\\phi_i)_{i=1,\\hdots,n}`, where :math:`\\phi_i(\\vect{x_i})=1`, :math:`\\phi_i(\\vect{x_j})=0` for :math:`j\\neq i` and the restriction of :math:`\\phi_i` to any simplex is an affine function. The vertices that are not included into at least one simplex are not taken into account.
The gram matrix of the mesh is defined as the symmetric positive definite matrix :math:`\\mat{K}` whose generic element :math:`K_{i,j}` is given by:
.. math::
\\forall i,j=1,\\hdots,n,\\quad K_{i,j}=\\int_{\\cD}\\phi_i(\\vect{x})\\phi_j(\\vect{x})\\di{\\vect{x}}
This method is used in several algorithms related to stochastic process representation such as the Karhunen-Loeve decomposition.
Examples
--------
>>> import openturns as ot
>>> # Define the vertices of the mesh
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [1.5, 1.0]]
>>> # Define the simplices of the mesh
>>> simplices = [[0, 1, 2], [1, 2, 3]]
>>> # Create the mesh of dimension 2
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> print(mesh2d.computeP1Gram())
[[ 0.0416667 0.0208333 0.0208333 0 ]
[ 0.0208333 0.0625 0.03125 0.0104167 ]
[ 0.0208333 0.03125 0.0625 0.0104167 ]
[ 0 0.0104167 0.0104167 0.0208333 ]]
"""
return _geom.Mesh_computeP1Gram(self)
def isRegular(self):
"""
Check if the mesh is regular (only for 1-d meshes).
Returns
-------
isRegular : bool
Tells if the mesh is regular or not.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.5], [1.5], [2.4], [3.5]]
>>> simplices = [[0, 1], [1, 2], [2, 3]]
>>> mesh1d = ot.Mesh(vertices, simplices)
>>> print(mesh1d.isRegular())
False
>>> vertices = [[0.5], [1.5], [2.5], [3.5]]
>>> mesh1d = ot.Mesh(vertices, simplices)
>>> print(mesh1d.isRegular())
True
"""
return _geom.Mesh_isRegular(self)
def getLowerBound(self):
"""
Get the lower bound of the domain.
Returns
-------
lower : :class:`~openturns.Point`
The lower bound of an axes-aligned bounding box of the domain.
"""
return _geom.Mesh_getLowerBound(self)
def getUpperBound(self):
"""
Get the upper bound of the domain.
Returns
-------
upper : :class:`~openturns.Point`
The upper bound of an axes-aligned bounding box of the domain.
"""
return _geom.Mesh_getUpperBound(self)
def draw(self):
"""
Draw the mesh.
Returns
-------
graph : :class:`~openturns.Graph`
If the dimension of the mesh is 1, it draws the corresponding interval,
using the :meth:`draw1D` method; if the dimension is 2, it draws the
triangular simplices, using the :meth:`draw2D` method; if the dimension is
3, it projects the simplices on the plane of the two first components,
using the :meth:`draw3D` method with its default parameters, superposing
the simplices.
"""
return _geom.Mesh_draw(self)
def draw1D(self):
"""
Draw the mesh of dimension 1.
Returns
-------
graph : :class:`~openturns.Graph`
Draws the line linking the vertices of the mesh when the mesh is of
dimension 1.
Examples
--------
>>> import openturns as ot
>>> from openturns.viewer import View
>>> vertices = [[0.5], [1.5], [2.1], [2.7]]
>>> simplices = [[0, 1], [1, 2], [2, 3]]
>>> mesh1d = ot.Mesh(vertices, simplices)
>>> # Create a graph
>>> aGraph = mesh1d.draw1D()
>>> # Draw the mesh
>>> View(aGraph).show()
"""
return _geom.Mesh_draw1D(self)
def draw2D(self):
"""
Draw the mesh of dimension 2.
Returns
-------
graph : :class:`~openturns.Graph`
Draws the edges of each simplex, when the mesh is of dimension 2.
Examples
--------
>>> import openturns as ot
>>> from openturns.viewer import View
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [1.5, 1.0]]
>>> simplices = [[0, 1, 2], [1, 2, 3]]
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> # Create a graph
>>> aGraph = mesh2d.draw2D()
>>> # Draw the mesh
>>> View(aGraph).show()
"""
return _geom.Mesh_draw2D(self)
def draw3D(self, *args):
"""
Draw the bidimensional projection of the mesh.
Available usages:
draw3D(*drawEdge=True, thetaX=0.0, thetaY=0.0, thetaZ=0.0, shading=False, rho=1.0*)
draw3D(*drawEdge, rotation, shading, rho*)
Parameters
----------
drawEdge : bool
Tells if the edge of each simplex has to be drawn.
thetaX : float
Gives the value of the rotation along the X axis in radian.
thetaY : float
Gives the value of the rotation along the Y axis in radian.
thetaZ : float
Gives the value of the rotation along the Z axis in radian.
rotation : :class:`~openturns.SquareMatrix`
Operates a rotation on the mesh before its projection of the plane of the
two first components.
shading : bool
Enables to give a visual perception of depth and orientation.
rho : float, :math:`0 \\leq \\rho \\leq 1`
Contraction factor of the simplices. If :math:`\\rho < 1`, all the
simplices are contracted and appear deconnected: some holes are created,
which enables to see inside the mesh. If :math:`\\rho = 1`, the simplices
keep their initial size and appear connected. If :math:`\\rho = 0`, each
simplex is reduced to its gravity center.
Returns
-------
graph : :class:`~openturns.Graph`
Draws the bidimensional projection of the mesh on the :math:`(x,y)` plane.
Examples
--------
>>> import openturns as ot
>>> from openturns.viewer import View
>>> from math import cos, sin, pi
>>> vertices = [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, 1.0, 0.0],
... [0.0, 1.0, 1.0], [1.0, 0.0, 0.0], [1.0, 0.0, 1.0],
... [1.0, 1.0, 0.0], [1.0, 1.0, 1.0]]
>>> simplices = [[0, 1, 2, 4], [3, 5, 6, 7],[1, 2, 3, 6],
... [1, 2, 4, 6], [1, 3, 5, 6], [1, 4, 5, 6]]
>>> mesh3d = ot.Mesh(vertices, simplices)
>>> # Create a graph
>>> aGraph = mesh3d.draw3D()
>>> # Draw the mesh
>>> View(aGraph).show()
>>> rotation = ot.SquareMatrix(3)
>>> rotation[0, 0] = cos(pi / 3.0)
>>> rotation[0, 1] = sin(pi / 3.0)
>>> rotation[1, 0] = -sin(pi / 3.0)
>>> rotation[1, 1] = cos(pi / 3.0)
>>> rotation[2, 2] = 1.0
>>> # Create a graph
>>> aGraph = mesh3d.draw3D(True, rotation, True, 1.0)
>>> # Draw the mesh
>>> View(aGraph).show()
"""
return _geom.Mesh_draw3D(self, *args)
def __repr__(self):
return _geom.Mesh___repr__(self)
def __str__(self, *args):
return _geom.Mesh___str__(self, *args)
def ImportFromMSHFile(fileName):
"""
Import mesh from FreeFem 2-d mesh files.
Parameters
----------
MSHFile : str
A MSH ASCII file.
Returns
-------
mesh : :class:`~openturns.Mesh`
Mesh defined in the file *MSHFile*.
"""
return _geom.Mesh_ImportFromMSHFile(fileName)
ImportFromMSHFile = staticmethod(ImportFromMSHFile)
def streamToVTKFormat(self):
"""
Give a VTK representation of the mesh.
Returns
-------
stream : str
VTK representation of the mesh.
"""
return _geom.Mesh_streamToVTKFormat(self)
def exportToVTKFile(self, fileName):
"""
Export the mesh to a VTK file.
Parameters
----------
myVTKFile.vtk : str
Name of the created file which contains the mesh and the associated random
values that can be visualized with the open source software
`Paraview <http://www.paraview.org/>`_.
"""
return _geom.Mesh_exportToVTKFile(self, fileName)
def __init__(self, *args):
this = _geom.new_Mesh(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _geom.delete_Mesh
__del__ = lambda self: None
Mesh_swigregister = _geom.Mesh_swigregister
Mesh_swigregister(Mesh)
def Mesh_ImportFromMSHFile(fileName):
"""
Import mesh from FreeFem 2-d mesh files.
Parameters
----------
MSHFile : str
A MSH ASCII file.
Returns
-------
mesh : :class:`~openturns.Mesh`
Mesh defined in the file *MSHFile*.
"""
return _geom.Mesh_ImportFromMSHFile(fileName)
class RegularGrid(Mesh):
"""
Regular Grid.
Available constructors:
RegularGrid(*start, step, n*)
RegularGrid(*mesh*)
Parameters
----------
start : float
The start time stamp of the grid.
step : float, positive
The step between to consecutive time stamps.
n : int
The number of time stamps in the grid, including the start and the end time stamps.
mesh : :class:`~openturns.Mesh`
The mesh must be in :math:`\\Rset`, regular and sorted in the increasing order.
Notes
-----
The time stamps of the regular grid are: :math:`(t_0, \\dots, t_{n-1})` where :math:`t_{k} = t_0 + k \\Delta` for :math:`0 \\leq k \\leq n-1` and :math:`\\Delta >0` the step.
See also
--------
Mesh
Examples
--------
>>> import openturns as ot
>>> myRegularGrid = ot.RegularGrid(0.0, 0.1, 100)
"""
__swig_setmethods__ = {}
for _s in [Mesh]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, RegularGrid, name, value)
__swig_getmethods__ = {}
for _s in [Mesh]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, RegularGrid, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _geom.RegularGrid_getClassName(self)
def __eq__(self, rhs):
return _geom.RegularGrid___eq__(self, rhs)
def __ne__(self, rhs):
return _geom.RegularGrid___ne__(self, rhs)
def getStart(self):
"""
Accessor to the start time stamp.
Returns
-------
start : float
The start point :math:`t_0` of the grid.
"""
return _geom.RegularGrid_getStart(self)
def getEnd(self):
"""
Accessor to the first time stamp after the last time stamp of the grid.
Returns
-------
endPoint : float
The first point that follows the last point of the grid: :math:`t_{n-1} + \\Delta`. The end point is not in the grid.
"""
return _geom.RegularGrid_getEnd(self)
def getStep(self):
"""
Accessor to the step.
Returns
-------
step : float
The step :math:`\\Delta` between two consecutive time stamps.
"""
return _geom.RegularGrid_getStep(self)
def getN(self):
"""
Accessor to the number of time stamps in the grid.
Returns
-------
n : int
The number :math:`n` of time stamps in the grid.
"""
return _geom.RegularGrid_getN(self)
def getValue(self, i):
"""
Accessor to the time stamps at a gien index.
Parameters
----------
k : int, :math:`0 \\leq k \\leq n-1`.
Index of a time stamp.
Returns
-------
value : float
The time stamp :math:`t_{k}`.
"""
return _geom.RegularGrid_getValue(self, i)
def getValues(self):
"""
Accessor to all the time stamps.
Returns
-------
values : :class:`~openturns.Point`
The collection of the time stamps.
"""
return _geom.RegularGrid_getValues(self)
def follows(self, starter):
"""
Check if the given grid follows the current one.
Parameters
----------
newGrid : :class:`~openturns.RegularGrid`
A new regular grid.
Returns
-------
answer : boolean
The answer is *True* if the *newGrid* directly follows the current one.
"""
return _geom.RegularGrid_follows(self, starter)
def isRegular(self):
"""
Check if the mesh is regular (only for 1-d meshes).
Returns
-------
isRegular : bool
Tells if the mesh is regular or not.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.5], [1.5], [2.4], [3.5]]
>>> simplices = [[0, 1], [1, 2], [2, 3]]
>>> mesh1d = ot.Mesh(vertices, simplices)
>>> print(mesh1d.isRegular())
False
>>> vertices = [[0.5], [1.5], [2.5], [3.5]]
>>> mesh1d = ot.Mesh(vertices, simplices)
>>> print(mesh1d.isRegular())
True
"""
return _geom.RegularGrid_isRegular(self)
def getNearestVertexIndex(self, point):
"""
Get the index of the nearest vertex of a given point.
Parameters
----------
point : sequence of float
Point of dimension :math:`dim`, the dimension of the vertices of the mesh.
Returns
-------
index : int
Index of the simplex the nearest of *point* according to the Euclidean
norm.
Examples
--------
>>> import openturns as ot
>>> vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
>>> simplices = [[0, 1, 2]]
>>> mesh2d = ot.Mesh(vertices, simplices)
>>> point = [0.9, 0.4]
>>> print(mesh2d.getNearestVertexIndex(point))
1
"""
return _geom.RegularGrid_getNearestVertexIndex(self, point)
def __repr__(self):
return _geom.RegularGrid___repr__(self)
def __str__(self, *args):
return _geom.RegularGrid___str__(self, *args)
def __init__(self, *args):
this = _geom.new_RegularGrid(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _geom.delete_RegularGrid
__del__ = lambda self: None
RegularGrid_swigregister = _geom.RegularGrid_swigregister
RegularGrid_swigregister(RegularGrid)
class IntervalMesher(openturns.common.PersistentObject):
"""
Creation of mesh of box type.
Available constructor:
IntervalMesher(*discretization*)
Parameters
----------
discretization : sequence of int, of dimension :math:`\\leq 3`.
Number of intervals in each direction of the box.
Examples
--------
Create a mesh:
>>> import openturns as ot
>>> mesher = ot.IntervalMesher([5, 10])
>>> lowerbound = [0.0, 0.0]
>>> upperBound = [2.0, 4.0]
>>> interval = ot.Interval(lowerbound, upperBound)
>>> mesh = mesher.build(interval)
"""
__swig_setmethods__ = {}
for _s in [openturns.common.PersistentObject]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, IntervalMesher, name, value)
__swig_getmethods__ = {}
for _s in [openturns.common.PersistentObject]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, IntervalMesher, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _geom.IntervalMesher_getClassName(self)
def setDiscretization(self, discretization):
"""
Accessor to the discretization.
Parameters
----------
discretization : sequence of int
Number of intervals in each direction of the box.
"""
return _geom.IntervalMesher_setDiscretization(self, discretization)
def getDiscretization(self):
"""
Accessor to the discretization.
Returns
-------
discretization : :class:`~openturns.Indices`
Number of intervals in each direction of the box.
"""
return _geom.IntervalMesher_getDiscretization(self)
def __repr__(self):
return _geom.IntervalMesher___repr__(self)
def __str__(self, *args):
return _geom.IntervalMesher___str__(self, *args)
def build(self, *args):
"""
Build the mesh of box type.
Parameters
----------
interval : :class:`~openturns.Interval`
The interval to mesh, of dimension equal to the dimension
of `discretization`.
diamond : bool
A flag telling if one want the usual mesh (rectangular cells cut along a
diagonal in dimension 2) or a diamond like mesh (rectangular cells cut
into 4 triangles with the center of the cell as shared vertex).
Default is *IntervalMesher-UseDiamond*, see :class:`~openturns.ResourceMap`.
Returns
-------
mesh : :class:`~openturns.Mesh`
The mesh built.
"""
return _geom.IntervalMesher_build(self, *args)
def __init__(self, *args):
this = _geom.new_IntervalMesher(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _geom.delete_IntervalMesher
__del__ = lambda self: None
IntervalMesher_swigregister = _geom.IntervalMesher_swigregister
IntervalMesher_swigregister(IntervalMesher)
# This file is compatible with both classic and new-style classes.
|