Giter Site home page Giter Site logo

fenics / basix Goto Github PK

View Code? Open in Web Editor NEW
82.0 18.0 32.0 3.91 MB

FEniCSx finite element basis evaluation library

Home Page: https://fenicsproject.org

License: MIT License

CMake 0.62% C++ 71.21% Python 27.48% TeX 0.67% Makefile 0.01%
finite-elements high-order fenicsx basis-functions

basix's People

Contributors

adeebkor avatar ampdes avatar chrisrichardson avatar conpierce8 avatar drew-parsons avatar francesco-ballarin avatar garth-wells avatar igorbaratta avatar jhale avatar jorgensd avatar luzpaz avatar massimiliano-leoni avatar michalhabera avatar minrk avatar mscroggs avatar nikhiltkur avatar rmsc avatar schnellerhase avatar spraetor avatar tiagovla avatar ttitscher avatar wence- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

basix's Issues

Expose cell::str_to_type and cell::type_to_str to python layer

To make it as easy as possible to use basix along-side dolfin-x, I suggest that cell:str_to_type and cell::type_to_str is expose, such that one can easily convert between dolfinx::mesh::CellType and basix::CellType.
This is for instance relevant when creating custom quadrature rules, as make_quadrature require a basix cell type.
In dolfin-x, one can convert the dolfinx::mesh::CellType to a string using dolfinx.cpp.mesh.to_string(mesh.topology.cell_type)

Create Spack package

We need to create a Spack package rather urgently as the DOLFINX Spack package is broken and will remain so until basix is added to Spack.

Improve quadrature interface

Currently we have make_quadrature which generates Gauss-Jacobi rules on all the cell types.

  • We need a way to choose different schemes.
    • User defined
    • Pre-defined with a name, e.g. "Gauss-Jacobi", "Gauss-Radau", "Strang-Fix" or just "default"

pip install fails with new eigen versions on AMD machines

$ pip3 install git+https://github.com/FEniCS/basix.git --upgrade
...
...
-- Build files have been written to: /tmp/pip-req-build-xvapwdaa/_skbuild/linux-x86_64-3.8/cmake-build
  [1/18] Building CXX object cpp/CMakeFiles/basix.dir/dof-permutations.cpp.o
  FAILED: cpp/CMakeFiles/basix.dir/dof-permutations.cpp.o
  /usr/bin/c++ -DBASIX_VERSION=0.0.1 -DEIGEN_MAX_ALIGN_BYTES=32 -Dbasix_EXPORTS -I/usr/local/include/eigen3 -Wno-comment -Wall -Werror -std=c++17  -O3 -DNDEBUG -fPIC -std=c++17 -MD -MT cpp/CMakeFiles/basix.dir/dof-permutations.cpp.o -MF cpp/CMakeFiles/basix.dir/dof-permutations.cpp.o.d -o cpp/CMakeFiles/basix.dir/dof-permutations.cpp.o -c ../../../cpp/dof-permutations.cpp
  In file included from /usr/local/include/eigen3/Eigen/Core:159,
                   from /usr/local/include/eigen3/Eigen/Dense:1,
                   from ../../../cpp/dof-permutations.h:7,
                   from ../../../cpp/dof-permutations.cpp:5:
  /usr/local/include/eigen3/Eigen/src/Core/util/Memory.h: In function ‘void Eigen::internal::queryCacheSizes_amd(int&, int&, int&)’:
  /usr/local/include/eigen3/Eigen/src/Core/util/Memory.h:1064:14: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
   1064 |   if(abcd[0] >= 0x80000006)
        |      ~~~~~~~~^~~~~~~~~~~~~

The issue can be solved by removing the -Werror flag from release mode.

It happens with eigen 3.9 and the development versions.

Documentation with doxygen and sphinx

  • Go through all documentation checking it works OK with doxygen
  • Add docstrings to python using separate file e.g. wrapper_docs.h and a lookup map.

Check array order consistency - RowMajor vs ColumnMajor

Example:
basix::tabulate receives a pointer to the memory of a set of points [npoints, tdim], which is expected to be in row-major order, maps it into a row-major eigen array, but in the subsequent function calls it's treated as a column-major array.

Add interface for performing interpolation

It would be helpful to support interpolation.

  • For an element, return the points on the reference cell where it requires function evaluations
  • Given function evaluations on the reference element, return dofs.

value_shape

Some elements may need a value shape as well as a value size

Transpose the data returned by tabulate

Currently, tabulate returns (row-major) data with shape [(nd+tdim)!/nd!tdim!, value_size, dim, npoints]. However data in dolfinx is stored (row-major) as [npoints, dim, value_size].

This means that the same implementation of (eg) map_push_forward cannot be applied to both the result of FiniteElement::tabulate and data passed in from dolfinx.

Restructure the function mappings

  • basix::map_push_forward and basix::map_pull_back should work on multiple points at ones
  • FiniteElement::map_push_forward and FiniteElement::map_pull_back should use in/out arguments, rather than returning arrays
  • A pointer to the correct mapping function should be stored in FiniteElement instead of querying the mapping type for every point and every value

Support "variants" of elements

Do we have "variants" of elements, e.g. Lagrange at GLL points? Discontinuous Lagrange? Point eval vs. integral moment?

Or should each variant just have a new name?

Inform whether a call to compute_reference_geometry is needed for interpolation

Simple regression example:

Number of degrees of freedom: 1030301
element = FiniteElement("Lagrange", tetrahedron, 2)
BoxMesh {50, 50, 50}

Build BoxMesh               |     1  1.140848  1.140848
Build dofmap data           |     2  0.985655  1.971311
Assemble Vector             |     1  0.907553  0.907553


interpolate                 |     1  5.931514  5.931514

Without compute_reference_geometry:

interpolate                 |     1  2.030478 2.030478

Store entity-dof information

There needs to be a way of associating dofs with topological entities.

At first, we can try just storing the dofs in increasing topological order i.e. vertex, edge, face, cell.
In that case, we just need to know how many dofs there are on each dimension.
We can make the assumption that all similar entities of a given dimension must have the same number of dofs (otherwise continuity is difficult). This is a simplification, and may be revised later if necessary.

For face and cell dofs, the layout is not simple (unlike vertex and edge), especially when a cell may have both triangular and quadrilateral faces. In this case, we could specify the number of "edge_dofs", e.g. for a triangle edge_dofs = 3 implies 6 dofs. For a quadrialteral, edge_dofs = 3 implies 9 dofs.

Add all elements used in FEniCSx tests

Used in dolfinx tests:

  • Brezzi-Douglas-Marini
  • RTCE
  • RTCF
  • NCE
  • NCF
  • DQ

Used in ffc demos:

Missing spaces that probably need to be dealt with in FFCx, not in Basix:

  • Hdiv trace
  • EnrichedElement
  • NodalEnrichedElement
  • Quadrature
  • Real

Custom element in dolfin

In #62, we make finite element class store a family name string. This will be used by dolfin to recontruct the element for tabulation.

For custom element (eg the elements in test_create.py), this will not work as the element cannot be constructed.

Implement all elements from the periodic table

These are:

  • Simplices
    • First family
      • Lagrange
      • Nedlec first kind
      • Raviart-Thomas
    • Second family
      • Lagrange
      • Nedelec second kind
      • BDM
  • TP
    • First family
      • Q
      • RTCe / NCe
      • RTCf / NCf
    • Second family
      • Serendipity
      • BDMCe / AAe
      • BDMCf / AAf

Add unique integer identifier for each element type

It would be useful to have an integer identifier for each element type, and embed in this ID the basix version number (or release short git hash). Generated FFCX code could then just store the unique element ID, and the element can be then be easily and reliably fetched from basix.

Add Bubble element

Should be easy as it is just based on Lagrange. Needed for "mini" element demos.

Test the cpp interface

Currently all the tests use the Python interface (via wrapper.cpp).

It would be good to add tests that directly interface through cpp so we can test this without having to use the dolfin tests

Folder structure

As more elements are added, we're going to end up with a lot of files in the cpp/ directory. Would it be neater to put them in subdirectories, eg:

  • cpp contains basix and wrapper
  • cpp/core containing cell, dof-permutations, finite-element, indexing, moment, polyset, quadrature
  • cpp/elements containing lagrange, crouzeix-raviart, raviart-thomas, nedelec, etc

Nedelec 2nd kind H(curl) fails on 32-bit systems

Judging by the build errors at https://buildd.debian.org/status/package.php?p=basix, looks like Nedelec 2nd kind H(curl) is not compatible with 32 bit systems. e.g.
i386 https://buildd.debian.org/status/fetch.php?pkg=basix&arch=i386&ver=0.0.1%7Egit20210122.4f10ef2-1&stamp=1612391676&raw=0
armel https://buildd.debian.org/status/fetch.php?pkg=basix&arch=armel&ver=0.0.1%7Egit20210122.4f10ef2-1&stamp=1612398463&raw=0
armhf https://buildd.debian.org/status/fetch.php?pkg=basix&arch=armhf&ver=0.0.1%7Egit20210122.4f10ef2-1&stamp=1612392128&raw=0

Is this problem expected? Is it something that can be fixed, or should Nedelec 2nd kind H(curl) just be considered not supported on 32 bit systems?

The error message is

__ test_permutation_of_tabulated_data_tetrahedron[5-Nedelec 2nd kind H(curl)] __

element_name = 'Nedelec 2nd kind H(curl)', order = 5

    @pytest.mark.parametrize("element_name", tetrahedron_elements)
    @pytest.mark.parametrize("order", range(1, 6))
    def test_permutation_of_tabulated_data_tetrahedron(element_name, order):
        if element_name == "Crouzeix-Raviart" and order != 1:
            pytest.xfail()
    
        e = basix.create_element(element_name, "tetrahedron", order)
    
        N = 4
        points = np.array([[i / N, j / N, k / N]
                           for i in range(N + 1) for j in range(N + 1 - i) for k in range(N + 1 - i - j)])
        values = e.tabulate(0, points)[0]
    
        start = sum(e.entity_dofs[0])
        ndofs = e.entity_dofs[1][0]
        if ndofs != 0:
            # Check that the 0th permutation undoes the effect of reflecting edge 0
            reflected_points = np.array([[p[0], p[2], p[1]] for p in points])
            reflected_values = e.tabulate(0, reflected_points)[0]
    
            if e.mapping_name == "affine":
                pass
            elif e.mapping_name == "covariant piola":
                for i, r in enumerate(reflected_values):
                    for j in range(e.dim):
                        reflected_values[i][j + e.dim::e.dim] = r[j + e.dim::e.dim][::-1]
            elif e.mapping_name == "contravariant piola":
                for i, r in enumerate(reflected_values):
                    for j in range(e.dim):
                        reflected_values[i][j] = -r[j]
                        reflected_values[i][j + e.dim::e.dim] = -r[j + e.dim::e.dim][::-1]
            elif e.mapping_name == "double covariant piola":
                pytest.skip()  # TODO: implement double covariant piola
            else:
                raise ValueError(f"Unknown mapping: {e.mapping_name}")
    
            for i, j in zip(values, reflected_values):
                for d in range(e.value_size):
                    i_slice = i[d * e.dim:(d + 1) * e.dim]
                    j_slice = j[d * e.dim:(d + 1) * e.dim]
>                   assert np.allclose((e.base_permutations[0].dot(i_slice))[start: start + ndofs],
                                       j_slice[start: start + ndofs])
E                   assert False
E                    +  where False = <function allclose at 0xf6d2a658>(array([ 0., -0., -0., -0., -0.,  0.]), array([-1.34, -1.12, -0.28,  0.68,  0.8 , -1.5 ]))
E                    +    where <function allclose at 0xf6d2a658> = np.allclose

test/test_permutations.py:227: AssertionError

In the meantime since only this one test fails, I'll just skip this test in the 32-bit Debian builds. So the error won't show in future builds (but will still be there).

Create a public API

  • The library should provide single header API that should not expose any other libtab headers
  • Provide a plain C interface
  • Wrap with pybind11 just the public API

Would it be convenient to provide an API that using Eigen? Would this be portable?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.