Skip to content

Commit

Permalink
update doctests and changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
kinnala committed Jun 19, 2024
1 parent f395d1f commit b5d9167
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions docs/howto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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::

Expand Down Expand Up @@ -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`:
Expand All @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions skfem/assembly/basis/abstract_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
----------
Expand Down

0 comments on commit b5d9167

Please sign in to comment.