From b5d91670c79e64a4f98435c682ec0ea7e372fcbf Mon Sep 17 00:00:00 2001 From: Tom Gustafsson Date: Wed, 19 Jun 2024 08:48:56 +0300 Subject: [PATCH] update doctests and changelog entry --- README.md | 5 +++++ docs/howto.rst | 12 ++++++------ skfem/assembly/basis/abstract_basis.py | 12 ++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 549245db..3dc05d8f 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,11 @@ with respect to documented and/or tested features. - Changed: Default tags ('left', 'right', 'top', ...) are no more added automatically during mesh initialization, as a workaround you can add them explicitly by calling `mesh = mesh.with_defaults()` +- Changed: All indices within the library are now using `np.int32` for + around 10% boost in performance and the corresponding reduction in + memory usage for larger meshes - theoretically, the largest possible + tetrahedral tensor product mesh is roughly 550 ** 3 = 166 M vertices + and 993 M elements, without the facet indexing wrapping over INT_MAX ### [9.1.1] - 2024-04-23 diff --git a/docs/howto.rst b/docs/howto.rst index 3780887e..440561af 100644 --- a/docs/howto.rst +++ b/docs/howto.rst @@ -37,9 +37,9 @@ DOFs on the matching facets: >>> dofs = basis.get_dofs(lambda x: x[0] == 0.) >>> dofs.nodal - {'u': array([ 0, 2, 5, 10, 14])} + {'u': array([ 0, 2, 5, 10, 14], dtype=int32)} >>> dofs.facet - {'u': array([26, 30, 39, 40])} + {'u': array([26, 30, 39, 40], dtype=int32)} This element has one DOF per node and one DOF per facet. The facets have their own numbering scheme starting from zero, however, the corresponding DOFs are @@ -48,7 +48,7 @@ offset by the total number of nodal DOFs: .. doctest:: >>> dofs.facet['u'] - array([26, 30, 39, 40]) + array([26, 30, 39, 40], dtype=int32) .. plot:: @@ -92,9 +92,9 @@ An array of all DOFs with the key ``u`` can be obtained as follows: .. doctest:: >>> dofs.all(['u']) - array([ 0, 2, 5, 10, 14, 26, 30, 39, 40]) + array([ 0, 2, 5, 10, 14, 26, 30, 39, 40], dtype=int32) >>> dofs.flatten() # all DOFs, no matter which key - array([ 0, 2, 5, 10, 14, 26, 30, 39, 40]) + array([ 0, 2, 5, 10, 14, 26, 30, 39, 40], dtype=int32) If a set of facets is tagged, the name of the tag can be passed to :meth:`~skfem.assembly.basis.AbstractBasis.get_dofs`: @@ -103,7 +103,7 @@ to :meth:`~skfem.assembly.basis.AbstractBasis.get_dofs`: >>> dofs = basis.get_dofs('left') >>> dofs.flatten() - array([ 0, 2, 5, 10, 14, 26, 30, 39, 40]) + array([ 0, 2, 5, 10, 14, 26, 30, 39, 40], dtype=int32) Many DOF types have a well-defined location. These DOF locations can be found as follows: diff --git a/skfem/assembly/basis/abstract_basis.py b/skfem/assembly/basis/abstract_basis.py index e15a572a..3be4345f 100644 --- a/skfem/assembly/basis/abstract_basis.py +++ b/skfem/assembly/basis/abstract_basis.py @@ -137,7 +137,7 @@ def get_dofs(self, >>> m = MeshTri().refined() >>> basis = Basis(m, ElementTriP1()) >>> basis.get_dofs().flatten() - array([0, 1, 2, 3, 4, 5, 7, 8]) + array([0, 1, 2, 3, 4, 5, 7, 8], dtype=int32) Get DOFs via a function query: @@ -146,7 +146,7 @@ def get_dofs(self, >>> m = MeshTri().refined() >>> basis = Basis(m, ElementTriP1()) >>> basis.get_dofs(lambda x: np.isclose(x[0], 0)).flatten() - array([0, 2, 5]) + array([0, 2, 5], dtype=int32) Get DOFs via named boundaries: @@ -157,7 +157,7 @@ def get_dofs(self, ... .with_boundaries({'left': lambda x: np.isclose(x[0], 0)})) >>> basis = Basis(m, ElementTriP1()) >>> basis.get_dofs('left').flatten() - array([0, 2, 5]) + array([0, 2, 5], dtype=int32) Get DOFs via named subdomains: @@ -167,7 +167,7 @@ def get_dofs(self, ... .with_subdomains({'left': lambda x: x[0] < .5})) >>> basis = Basis(m, ElementTriP1()) >>> basis.get_dofs(elements='left').flatten() - array([0, 2, 4, 5, 6, 8]) + array([0, 2, 4, 5, 6, 8], dtype=int32) Further reduce the set of DOFs: @@ -178,7 +178,7 @@ def get_dofs(self, >>> basis.get_dofs(lambda x: np.isclose(x[0], 0)).nodal.keys() dict_keys(['u', 'u_x', 'u_y', 'u_xx', 'u_xy', 'u_yy']) >>> basis.get_dofs(lambda x: np.isclose(x[0], 0)).all(['u', 'u_x']) - array([ 0, 1, 12, 13, 30, 31]) + array([ 0, 1, 12, 13, 30, 31], dtype=int32) Skip some DOF names altogether: @@ -199,7 +199,7 @@ def get_dofs(self, ... 'right': lambda x: np.isclose(x[0], 1)})) >>> basis = Basis(m, ElementTriP1()) >>> basis.get_dofs({'left', 'right'}).flatten() - array([0, 1, 2, 3]) + array([0, 1, 2, 3], dtype=int32) Parameters ----------