Skip to content

Commit

Permalink
Transition to basix library for finite element definitions (#296)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Jan 19, 2021
1 parent 75ae1bd commit 3f686be
Show file tree
Hide file tree
Showing 47 changed files with 1,538 additions and 4,795 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y graphviz libgraphviz-dev pkg-config
sudo apt-get install -y graphviz libgraphviz-dev pkg-config libeigen3-dev
- name: Install dependencies (non-Python, macOS)
if: runner.os == 'macOS'
run: brew install graphviz pkg-config
run: brew install graphviz pkg-config eigen
- name: Install dependencies (Python)
run: |
pip install --upgrade pip
pip install pygraphviz
pip install git+https://github.com/FEniCS/fiat.git --user
pip install git+https://github.com/FEniCS/basix.git --user
pip install git+https://github.com/FEniCS/ufl.git --user
- name: Lint with flake8
run: |
Expand All @@ -47,7 +47,7 @@ jobs:
pip install .
- name: Run units tests
run: |
pip install coveralls coverage pytest pytest-cov pytest-xdist
pip install coveralls coverage pytest pytest-cov pytest-xdist sympy
pytest -n auto --cov=ffcx/ --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml test/
- name: Upload to Coveralls
if: ${{ github.repository == 'FEniCS/ffcx' && github.head_ref == '' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }}
Expand All @@ -65,7 +65,7 @@ jobs:
if: always()
- name: Runs demos
run: |
ffcx demo/*.ufl
python${{ matrix.python-version }} -m pytest demo/test_demos.py
- name: Build documentation
run: |
Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,20 @@ install_manifest.txt
# Visual Studio Code project config
.vscode

# c, h and so files due to running demos
demo/*.c
demo/*.h
demo/*.so
test/*.c
test/*.h
test/*.so

# Tests
**/.cache/
__pycache__
test/compile-cache/
test/libffcx_*
test/*.pdf

# setuptools temps
*.egg-info/
Expand Down
31 changes: 31 additions & 0 deletions demo/test_demos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
import sys
import pytest

demo_dir = os.path.dirname(os.path.realpath(__file__))

ufl_files = []
for file in os.listdir(demo_dir):
if file.endswith(".ufl") and not file.startswith("."):
ufl_files.append(file[:-4])


@pytest.mark.parametrize("file", ufl_files)
def test_demo(file):
if file in [
"MixedPoissonDual", # Discontinuous Raviart-Thomas
"BiharmonicHHJ", # Hellan-Herrmann-Johnson
"NodalMini", # NodalEnrichedElement
"Mini", # EnrichedElement
"MixedGradient", "TraceElement", # HDiv Trace
"MassHdiv_2D_1", "MassHdiv_2D_3", "MixedPoisson", "MassHdiv_2D_2", # Brezzi-Douglas-Marini
"QuadratureElement" # Quadrature
]:
# Skip demos that use elements not yet implemented in basix
pytest.skip()

assert os.system(f"cd {demo_dir} && ffcx {file}.ufl") == 0
assert os.system(f"cd {demo_dir} && "
"CPATH=../ffcx/codegeneration/ "
f"gcc -I/usr/include/python{sys.version_info.major}.{sys.version_info.minor} -fPIC "
f"-shared {file}.c -o {file}.so") == 0
16 changes: 8 additions & 8 deletions ffcx/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ def _analyze_form(form: ufl.form.Form, parameters: typing.Dict) -> ufl.algorithm
"""

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

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

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

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

# Update the old metadata
metadata = integral.metadata()
Expand Down
Loading

0 comments on commit 3f686be

Please sign in to comment.