FFC Error undocumented/poisson-disc example

Hello,

I am new to FEniCS. I am trying to figure out how to compute convergence of the L2 error norm using C++. For this reason I am interested in the undocumented/poisson-disc example.

I am getting an error while compiling with ffs the example undocumented/poisson-disc/cpp. The original file compiles well. Compilation fails if I modify the example a bit: I replace the triangle with quadrilateral. It works fine if cell = quadrilateral and degree = 1. It fails if cell = quadrilateral and degree = 2. The error message and the code are attached.

Does anyone knows what is wrong? Is there a good example of how to compute convergence of L2 and H1 error norms (i.e. method of manufactured solutions) in C++?

Thanks!
Kenneth

Error

Traceback (most recent call last):
File “/usr/bin/ffc”, line 33, in
sys.exit(load_entry_point(‘fenics-ffc==2019.2.0.dev0’, ‘console_scripts’, ‘ffc’)())
File “/usr/lib/python3/dist-packages/ffc/main.py”, line 215, in main
resultcode = _compile_files(args, parameters, enable_profile)
File “/usr/lib/python3/dist-packages/ffc/main.py”, line 254, in _compile_files
code_h, code_c = compile_ufl_data(ufd, prefix, parameters)
File “/usr/lib/python3/dist-packages/ffc/main.py”, line 95, in compile_ufl_data
code_h, code_c = compile_form(ufd.forms, ufd.object_names,
File “/usr/lib/python3/dist-packages/ffc/compiler.py”, line 142, in compile_form
return compile_ufl_objects(forms, “form”, object_names,
File “/usr/lib/python3/dist-packages/ffc/compiler.py”, line 200, in compile_ufl_objects
code = generate_code(oir, parameters)
File “/usr/lib/python3/dist-packages/ffc/codegeneration.py”, line 74, in generate_code
code_integrals = [_generate_integral_code(ir, parameters)
File “/usr/lib/python3/dist-packages/ffc/codegeneration.py”, line 74, in
code_integrals = [_generate_integral_code(ir, parameters)
File “/usr/lib/python3/dist-packages/ffc/codegeneration.py”, line 249, in _generate_integral_code
code = r.generate_integral_code(ir, ir[“prefix”], parameters)
File “/usr/lib/python3/dist-packages/ffc/uflacs/uflacsgenerator.py”, line 45, in generate_integral_code
parts = ig.generate()
File “/usr/lib/python3/dist-packages/ffc/uflacs/integralgenerator.py”, line 225, in generate
self.generate_quadrature_loop(num_points)
File “/usr/lib/python3/dist-packages/ffc/uflacs/integralgenerator.py”, line 386, in generate_quadrature_loop
body = self.generate_unstructured_varying_partition(num_points)
File “/usr/lib/python3/dist-packages/ffc/uflacs/integralgenerator.py”, line 551, in generate_unstructured_varying_partition
parts = self.generate_partition(arraysymbol,
File “/usr/lib/python3/dist-packages/ffc/uflacs/integralgenerator.py”, line 584, in generate_partition
vdef = self.backend.definitions(mt.terminal,
File “/usr/lib/python3/dist-packages/ufl/corealg/multifunction.py”, line 89, in call
return self._handlers[o.ufl_typecode](o, *args)
File “/usr/lib/python3/dist-packages/ffc/uflacs/backends/ffc/definitions.py”, line 239, in jacobian
return self._define_coordinate_dofs_lincomb(e, mt, tabledata, num_points, access)
File “/usr/lib/python3/dist-packages/ffc/uflacs/backends/ffc/definitions.py”, line 132, in _define_coordinate_dofs_lincomb
assert end - begin <= num_scalar_dofs
AssertionError

Code

Copyright (C) 2015-2015 Martin Sandve Alnæs

This file is part of DOLFIN.

DOLFIN is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

DOLFIN is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with DOLFIN. If not, see http://www.gnu.org/licenses/.

The bilinear form a(u, v) and linear form L(v) for
Poisson’s equation with quadratic isoparametric elements.

Compile this form with FFC: ffc -r uflacs -l dolfin PoissonDisc.ufl

Solving
-laplace u = 1
u(r=1) = 0

#########################################################
These are original lines of code
degree = 2
cell = triangle
#########################################################

#########################################################
The ffc compiles it well with the following modification
degree = 1
cell = quadrilateral
#########################################################

#########################################################
The ffc fails on the following modification
degree = 2
cell = quadrilateral
#########################################################

coordinate_element = VectorElement(“Lagrange”, cell, degree)
mesh = Mesh(coordinate_element)

element = FiniteElement(“Lagrange”, cell, degree)
V = FunctionSpace(mesh, element)

u = TrialFunction(V)
v = TestFunction(V)

x = SpatialCoordinate(mesh)

f = Coefficient(V)

Variational formulation
a = dot(grad(u), grad(v))dx
L = f
v*dx

Exact solution
uexact = (1.0 - x**2) / 4.0

Error norm functional
uh = Coefficient(V)
M = (uh - uexact)**2*dx

Dolfin has very limited support for quadrilateral elements. If you want to use quadrilaterals, I would strongly suggest to use dolfinx, as the they are fully supported there, and several bugs and improvements has been made to the source code.

To start, you can consider Error control: Computing convergence rates — FEniCSx tutorial
which shows how to compute convergence rates in the DOLFINx python layer (and a similar implementation can be created in C++).

1 Like