Skip to content

Commit 3f686be

Browse files
mscroggschrisrichardsongarth-wells
authored
Transition to basix library for finite element definitions (#296)
* add some debug * Comment out some stuff * Start on libtab_interface * Add simple libtab_interface * flake8 * Add return value to make code compile * Provide more alternatives to fiat_element * Provide more alternatives to fiat_element * tidy and more print debug * Reshape for tensor elements * Removing fiat, adding libtab * libtab * eigen * -dev * Replaceing fiat with libtab * flake * more flake * remove fiat requirement * remove fiat from tests * use libtabbaseelement * Add value_shape TODO * Working on updating dof permutations * Reimplementing more functionality using libtab * return more features * turn off tests for element not implemented yet in libtab * update more tests * get permutation data to pass around correctly * implementing dof permutations * flake * comment out import * entity dofs * vertex quadrature * celltype -> cellname * fixing entity dofs and quadrature * flake * Reimplement more stuff * Get tabulate_reference_basis_derivatives working * remove evaluate_* * flake * remove unused import * contiguous * use fstrings * more fstrings * even more fstrings * missing ) * family names * Remove no longer used code * mt_averaged -> mt.averaged * Reintroduce more functionality * Run demos using pytest * use gcc compilation in demo test * block size corrections * Replace ndofs with dim * Replace ndofs with dim * Added tests that tabulate tensor is correct for Lagrange spaces * install sympy for testing * Put table data from before permutations were applied into conditionals * add interpolation to generated code * correct interpolation and interpolation test * flake * libtab branch * update to match libtab interpolation renaming * add needs_permutation_data to element * correct indices * back to master libtab * interpolation * currect use of subelements * block sizes * Correct interpolation for vectorelement * fix vectorfunctionspace interpolation and evaluation * Add mappings * Add alternative element names * update test to match scalar values * name mapping * skip demos for elements not yes in libtab * fix num_reference_componenets for mixed elements * flake * correct data for mixed and blocked elements * flake * Added permite_dofs_coordinates function * add apply_permutations function * simplify dos permutation application * reflections first * blocking (so mixed elements get correct data * always do reflections first * correct value shapes and sizes of blocked elements * correct blocked tabulation * remove blocksize from value shapes * value shapes * Speed up test * Add curl-curl to get more coverage * back to libtab master * flake8 * correct facet normals for quads * block sizes * libtab -> basix * basix branch * basix branch * ignore test c and h files * update ufc_geometry * remove some unused ufc_geometry * LibtabElement -> BasixElement * add interpolation_is_identity flag * replace reference to fiat with libtab * pass rule into quadrature Correct some geometry * basix branch * correct basix branch name * Remove ufc tabulate_reference_dof_coordinates * switch to main branch * correct quad facet normals * implement cell_vertices * add more to cmap * add mroe info to cmap * swap permutation order for integral tables * reimplement oriented jacobian * use make_perm_data function instead of copy/pasted code * Flake8 fixes * Remove unused code. * Doc fix * tidy up permutations * remove permutations from transform_reference_basis_d * Add docs to ufc.h * remove interpolation functions from finite_element * remove reverse permutation. add permutation of scalar_t data * remove interpolation test (as interpolation is now removed from generated code) * remove tabulate_dof_coordinates * Don't use conditionals * remove interpolation matrix and points from ir * remove physical and reference offsets * Remove transform_values * Remove some unnecessary const in ufc * restore facet_edge_vectors * Tidying up * use scalar_t type inside apply_dof_transformation * remove apply_dof_permutation from coordinate mapping * Revert "remove apply_dof_permutation from coordinate mapping" This reverts commit ea7cbf7. * Tidy coordinate mapping (#297) * add unpermute * un * revert * remove element factory name Co-authored-by: Chris Richardson <[email protected]> Co-authored-by: Garth N. Wells <[email protected]>
1 parent 75ae1bd commit 3f686be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1538
-4795
lines changed

.github/workflows/pythonapp.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ jobs:
2424
if: runner.os == 'Linux'
2525
run: |
2626
sudo apt-get update
27-
sudo apt-get install -y graphviz libgraphviz-dev pkg-config
27+
sudo apt-get install -y graphviz libgraphviz-dev pkg-config libeigen3-dev
2828
- name: Install dependencies (non-Python, macOS)
2929
if: runner.os == 'macOS'
30-
run: brew install graphviz pkg-config
30+
run: brew install graphviz pkg-config eigen
3131
- name: Install dependencies (Python)
3232
run: |
3333
pip install --upgrade pip
3434
pip install pygraphviz
35-
pip install git+https://github.com/FEniCS/fiat.git --user
35+
pip install git+https://github.com/FEniCS/basix.git --user
3636
pip install git+https://github.com/FEniCS/ufl.git --user
3737
- name: Lint with flake8
3838
run: |
@@ -47,7 +47,7 @@ jobs:
4747
pip install .
4848
- name: Run units tests
4949
run: |
50-
pip install coveralls coverage pytest pytest-cov pytest-xdist
50+
pip install coveralls coverage pytest pytest-cov pytest-xdist sympy
5151
pytest -n auto --cov=ffcx/ --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml test/
5252
- name: Upload to Coveralls
5353
if: ${{ github.repository == 'FEniCS/ffcx' && github.head_ref == '' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }}
@@ -65,7 +65,7 @@ jobs:
6565
if: always()
6666
- name: Runs demos
6767
run: |
68-
ffcx demo/*.ufl
68+
python${{ matrix.python-version }} -m pytest demo/test_demos.py
6969
7070
- name: Build documentation
7171
run: |

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,20 @@ install_manifest.txt
4646
# Visual Studio Code project config
4747
.vscode
4848

49+
# c, h and so files due to running demos
50+
demo/*.c
51+
demo/*.h
52+
demo/*.so
53+
test/*.c
54+
test/*.h
55+
test/*.so
56+
4957
# Tests
5058
**/.cache/
5159
__pycache__
60+
test/compile-cache/
61+
test/libffcx_*
62+
test/*.pdf
5263

5364
# setuptools temps
5465
*.egg-info/

demo/test_demos.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
import sys
3+
import pytest
4+
5+
demo_dir = os.path.dirname(os.path.realpath(__file__))
6+
7+
ufl_files = []
8+
for file in os.listdir(demo_dir):
9+
if file.endswith(".ufl") and not file.startswith("."):
10+
ufl_files.append(file[:-4])
11+
12+
13+
@pytest.mark.parametrize("file", ufl_files)
14+
def test_demo(file):
15+
if file in [
16+
"MixedPoissonDual", # Discontinuous Raviart-Thomas
17+
"BiharmonicHHJ", # Hellan-Herrmann-Johnson
18+
"NodalMini", # NodalEnrichedElement
19+
"Mini", # EnrichedElement
20+
"MixedGradient", "TraceElement", # HDiv Trace
21+
"MassHdiv_2D_1", "MassHdiv_2D_3", "MixedPoisson", "MassHdiv_2D_2", # Brezzi-Douglas-Marini
22+
"QuadratureElement" # Quadrature
23+
]:
24+
# Skip demos that use elements not yet implemented in basix
25+
pytest.skip()
26+
27+
assert os.system(f"cd {demo_dir} && ffcx {file}.ufl") == 0
28+
assert os.system(f"cd {demo_dir} && "
29+
"CPATH=../ffcx/codegeneration/ "
30+
f"gcc -I/usr/include/python{sys.version_info.major}.{sys.version_info.minor} -fPIC "
31+
f"-shared {file}.c -o {file}.so") == 0

ffcx/analysis.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ def _analyze_form(form: ufl.form.Form, parameters: typing.Dict) -> ufl.algorithm
148148
"""
149149

150150
if form.empty():
151-
raise RuntimeError("Form ({}) seems to be zero: cannot compile it.".format(str(form)))
151+
raise RuntimeError(f"Form ({form}) seems to be zero: cannot compile it.")
152152
if _has_custom_integrals(form):
153-
raise RuntimeError("Form ({}) contains unsupported custom integrals.".format(str(form)))
153+
raise RuntimeError(f"Form ({form}) contains unsupported custom integrals.")
154154

155155
# Check for complex mode
156156
complex_mode = "complex" in parameters.get("scalar_type", "double")
@@ -213,16 +213,16 @@ def _analyze_form(form: ufl.form.Form, parameters: typing.Dict) -> ufl.algorithm
213213
num_points = ((qd + 1 + 1) // 2)**tdim
214214
if num_points >= 100:
215215
warnings.warn(
216-
"Number of integration points per cell is: {}. Consider using 'quadrature_degree' "
217-
"to reduce number.".format(num_points))
216+
f"Number of integration points per cell is: {num_points}. Consider using 'quadrature_degree' "
217+
"to reduce number.")
218218

219219
# Extract quadrature rule
220220
qr = integral.metadata().get("quadrature_rule", qr_default)
221221

222-
logger.info("Integral {}, integral group {}:".format(i, id))
223-
logger.info("--- quadrature rule: {}".format(qr))
224-
logger.info("--- quadrature degree: {}".format(qd))
225-
logger.info("--- precision: {}".format(p))
222+
logger.info(f"Integral {i}, integral group {id}:")
223+
logger.info(f"--- quadrature rule: {qr}")
224+
logger.info(f"--- quadrature degree: {qd}")
225+
logger.info(f"--- precision: {p}")
226226

227227
# Update the old metadata
228228
metadata = integral.metadata()

0 commit comments

Comments
 (0)