Skip to content

Commit

Permalink
Cache Basix element creation (#475)
Browse files Browse the repository at this point in the history
* revert caching

* Add C++ DOLFINx tests to CI

* build dir

* add a cached create_basix_element function
  • Loading branch information
mscroggs committed Apr 20, 2022
1 parent e5f26d9 commit 1e9c6d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/dolfin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,14 @@ jobs:
cmake --install build
pip3 -v install --global-option build --global-option --debug dolfinx/python/
- name: Run DOLFINx unit tests
- name: Build DOLFINx C++ unit tests
run: |
cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build/test/ -S build/test/
cmake --build build/test
- name: Run DOLFINx C++ unit tests
run: |
cd build/test
ctest -V --output-on-failure -R unittests
- name: Run DOLFINx Python unit tests
run: python3 -m pytest -n auto dolfinx/python/test/unit
13 changes: 9 additions & 4 deletions ffcx/element_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
import numpy
import ufl
import basix.ufl_wrapper
# from functools import lru_cache
import functools


@functools.lru_cache
def create_basix_element(family_type, cell_type, degree, variant_info, discontinuous):
"""Create a basix element."""
return basix.create_element(family_type, cell_type, degree, *variant_info, discontinuous)


# @lru_cache
def create_element(element: ufl.finiteelement.FiniteElementBase) -> BaseElement:
"""Create an FFCx element from a UFL element.
Expand Down Expand Up @@ -90,8 +95,8 @@ def create_element(element: ufl.finiteelement.FiniteElementBase) -> BaseElement:
else:
variant_info.append(basix.variants.string_to_dpc_variant(element.variant()))

return BasixElement(basix.create_element(
family_type, cell_type, element.degree(), *variant_info, discontinuous))
return BasixElement(create_basix_element(
family_type, cell_type, element.degree(), tuple(variant_info), discontinuous))


def basix_index(*args):
Expand Down

0 comments on commit 1e9c6d0

Please sign in to comment.