Exception: Cell type prism not supported for integral type exterior_facet

Hello,

I am dealing with a heat conduction problem whose r.h.s is a surface heat source. Therefore I need to calculate the integral confined to a exterior surface. I encountered the following error

Traceback (most recent call last):
  File "/opt/project/field_mat.py", line 145, in <module>
    b_t = form(source_expr * v_t * ufl.ds)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/fem/forms.py", line 337, in form
    return _create_form(form)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/fem/forms.py", line 331, in _create_form
    return _form(form)
           ^^^^^^^^^^^
  File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/fem/forms.py", line 254, in _form
    ufcx_form, module, code = jit.ffcx_jit(
                              ^^^^^^^^^^^^^
  File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/jit.py", line 62, in mpi_jit
    return local_jit(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/jit.py", line 212, in ffcx_jit
    r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, **p_jit)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/ffcx/codegeneration/jit.py", line 225, in compile_forms
    raise e
  File "/dolfinx-env/lib/python3.12/site-packages/ffcx/codegeneration/jit.py", line 205, in compile_forms
    impl = _compile_objects(
           ^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/ffcx/codegeneration/jit.py", line 330, in _compile_objects
    _, code_body = ffcx.compiler.compile_ufl_objects(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/ffcx/compiler.py", line 113, in compile_ufl_objects
    ir = compute_ir(analysis, _object_names, _prefix, options, visualise)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/ffcx/ir/representation.py", line 135, in compute_ir
    _compute_integral_ir(
  File "/dolfinx-env/lib/python3.12/site-packages/ffcx/ir/representation.py", line 330, in _compute_integral_ir
    points, weights, tensor_factors = create_quadrature_points_and_weights(
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/ffcx/ir/representationutils.py", line 80, in create_quadrature_points_and_weights
    raise Exception(f"Cell type {cell} not supported for integral type {integral_type}.")
Exception: Cell type prism not supported for integral type exterior_facet.

It looks as if the current version of dolfinx (== 0.9.0) does not yet support the integration of external facet on prism cells. Are there any possible solutions?

This is being worked on atm: Make ds integrals on prism/pyramids generate kernels for each facet type by mscroggs · Pull Request #739 · FEniCS/ffcx · GitHub

1 Like

Glad to know. Thanks a lot.

@dokken I see this pull request was completed by mscroggs. What is the best way to incorporate the changes to the ffcx main branch? I am running on Ubuntu 22.04.3 LTS and have been using the Ubuntu PPA (on Dolfinx 0.9.0). I’d like to make use of prism elements, specifically for external facet integrals, but I’m not sure how to incorporate the merged pull request. I tried copying the changes to my python3/dist-packages/ffcx directory (by pulling the current main ffcx branch and overwriting package files) and running the following.

from mpi4py import MPI
from dolfinx import mesh, fem
import ufl

domain = mesh.create_box(MPI.COMM_WORLD, ((0,0,0), (1,1,1)), (1,1,1), cell_type = mesh.CellType.prism)
ds = ufl.Measure('ds', domain = domain)
print(fem.assemble_scalar(fem.form(1 * ds)))

But I get the following AssertionError

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/fem/forms.py", line 337, in form
    return _create_form(form)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/fem/forms.py", line 331, in _create_form
    return _form(form)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/fem/forms.py", line 254, in _form
    ufcx_form, module, code = jit.ffcx_jit(
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/jit.py", line 62, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfinx/jit.py", line 212, in ffcx_jit
    r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, **p_jit)
  File "/usr/lib/python3/dist-packages/ffcx/codegeneration/jit.py", line 226, in compile_forms
    raise e
  File "/usr/lib/python3/dist-packages/ffcx/codegeneration/jit.py", line 206, in compile_forms
    impl = _compile_objects(
  File "/usr/lib/python3/dist-packages/ffcx/codegeneration/jit.py", line 331, in _compile_objects
    _, code_body = ffcx.compiler.compile_ufl_objects(
  File "/usr/lib/python3/dist-packages/ffcx/compiler.py", line 118, in compile_ufl_objects
    code = generate_code(ir, options)
  File "/usr/lib/python3/dist-packages/ffcx/codegeneration/codegeneration.py", line 50, in generate_code
    code_integrals = [
  File "/usr/lib/python3/dist-packages/ffcx/codegeneration/codegeneration.py", line 51, in <listcomp>
    integral_generator(integral_ir, domain, options)
  File "/usr/lib/python3/dist-packages/ffcx/codegeneration/C/integrals.py", line 77, in generator
    assert ir.expression.coordinate_element_hash is not None
AssertionError

You can’t use the ubuntu PPA for this. I would suggest the docker images at: dolfinx/dolfinx versions · fenics · GitHub

Understood. I just pulled the nightly and tried running the example snippet above. Is that example a viable way to check the exterior facet integration or do I need to pass additional information to ufl.Measure or fem.form? Depending if I want integration over the triangle or rectangle exterior facets? I ultimately want to integrate over the (0-1-3-4) rectangular facet but I could use a deformed hexahedral to achieve something similar.

I get the following RuntimeError:

  File "<stdin>", line 1, in <module>
  File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/fem/forms.py", line 436, in form
    return _create_form(form)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/fem/forms.py", line 428, in _create_form
    return _form(form)
           ^^^^^^^^^^^
  File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/fem/forms.py", line 386, in _form
    f = ftype(
        ^^^^^^
RuntimeError: Multiple facet types in mesh. Call exterior_facet_indices with facet type index.

I guess I need additional guidance to understand the error as I try to call mesh.exterior_facet_indices(domain.topology), which as far as I can see only accepts Topology, and I get the exact same error.