This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Solving Poisson eq with Q2

+2 votes

Hi all,
I am fairly new to FEniCS and I am trying to change the Poisson example to use quadrilateral elements of degree two. I can't understand where the problem is in the code below

from dolfin import *

# Create mesh
mesh = UnitSquareMesh(32, 32)

# Define function space
Q2 = FiniteElement(family = "Quadrature",
                    cell = mesh.ufl_cell(),
                    degree = 2,
                    quad_scheme="default")

V = FunctionSpace(mesh, Q2)

# V = FunctionSpace(mesh, "Lagrange", 2)

# Define Dirichlet boundary everywhere
def boundary(x, on_boundary):
     return on_boundary

# Define boundary condition
u_D = Constant(0.0)
bc = DirichletBC(V, u_D, boundary)

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
a = inner(grad(u), grad(v))*dx
f = Expression("2*x[1]", degree = 2)
L = f*v*dx

# Compute solution
u = Function(V)
solve(a == L, u, bc)

Running this, I get the following error

Calling FFC just-in-time (JIT) compiler, this may take some time.
('\npoints:\n', array([[ 0.81684757, 0.09157621],
[ 0.09157621, 0.81684757],
[ 0.09157621, 0.09157621],
[ 0.10810302, 0.44594849],
[ 0.44594849, 0.10810302],
[ 0.44594849, 0.44594849]])) ('\nquad points:\n', array([[ 0.16666667, 0.16666667],
[ 0.16666667, 0.66666667],
[ 0.66666667, 0.16666667]])) Points must be equal to coordinates of quadrature points Traceback (most recent call last):
File "LaplaceEq.py", line 38, in
solve(a == L, u, bc) File "/usr/local/lib/python2.7/dist-packages/dolfin/fem/solving.py", line
300, in solve
_solve_varproblem(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/dolfin/fem/solving.py", line
325, in _solve_varproblem
form_compiler_parameters=form_compiler_parameters) File "/usr/local/lib/python2.7/dist-packages/dolfin/fem/solving.py", line
81, in __init__
L = Form(L, form_compiler_parameters=form_compiler_parameters) File "/usr/local/lib/python2.7/dist-packages/dolfin/fem/form.py", line
89, in __init__
mpi_comm=mesh.mpi_comm()) File "/usr/local/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py",
line 68, in mpi_jit
return local_jit(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py",
line 133, in jit
"ffc.jit failed with message:\n%s" % (tb_text,)) File "/usr/local/lib/python2.7/dist-packages/dolfin/cpp/common.py", line
2912, in dolfin_error
return _common.dolfin_error(location, task, reason) RuntimeError:

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at


*** fenics-support@googlegroups.com


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to perform just-in-time compilation of form.
*** Reason: ffc.jit failed with message: Traceback (most recent call last): File
"/usr/local/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py",
line 128, in jit
result = ffc.jit(ufl_object, parameters=p) File "/usr/local/lib/python2.7/dist-packages/ffc/jitcompiler.py", line 198,
in jit
module = jit_build(ufl_object, module_name, parameters) File "/usr/local/lib/python2.7/dist-packages/ffc/jitcompiler.py", line 120,
in jit_build
generate=jit_generate) File "/usr/local/lib/python2.7/dist-packages/dijitso/jit.py", line 160, in
jit
header, source, dependencies = generate(jitable, name, signature, params["generator"]) File
"/usr/local/lib/python2.7/dist-packages/ffc/jitcompiler.py", line 66,
in jit_generate
prefix=module_name, parameters=parameters, jit=True) File "/usr/local/lib/python2.7/dist-packages/ffc/compiler.py", line 141, in
compile_form
prefix, parameters, jit) File "/usr/local/lib/python2.7/dist-packages/ffc/compiler.py", line 188, in
compile_ufl_objects
ir = compute_ir(analysis, prefix, parameters, jit) File "/usr/local/lib/python2.7/dist-packages/ffc/representation.py", line
187, in compute_ir
for (form_id, fd) in enumerate(form_datas)] File "/usr/local/lib/python2.7/dist-packages/ffc/representation.py", line
450, in _compute_integral_ir
parameters) File "/usr/local/lib/python2.7/dist-packages/ffc/quadrature/quadraturerepresentation.py",
line 71, in compute_integral_ir
tabulate_basis(sorted_integrals, form_data, itg_data) File "/usr/local/lib/python2.7/dist-packages/ffc/quadrature/tabulate_basis.py",
line 227, in tabulate_basis
points) File "/usr/local/lib/python2.7/dist-packages/ffc/quadrature/tabulate_basis.py",
line 120, in _tabulate_psi_table
psi_table[entity] = element.tabulate(deriv_order, entity_points) File
"/usr/local/lib/python2.7/dist-packages/ffc/quadratureelement.py",
line 119, in tabulate
error("Points must be equal to coordinates of quadrature points") File "", line 1, in File
"/usr/local/lib/python2.7/dist-packages/ufl/log.py", line 171, in
error
raise self._exception_type(self._format_raw(*message)) Exception: Points must be equal to coordinates of quadrature points .
*** Where: This error was encountered inside jit.py.
*** Process: 0


*** DOLFIN version: 2016.2.0
*** Git changeset: 0f003bc07ee5fd583fb956245016d5972b80fea1
*** -------------------------------------------------------------------------

Any help is appreciated.
Thank you.

Ashkan.

asked May 10, 2017 by alidorostkar FEniCS Novice (170 points)

1 Answer

+1 vote
 
Best answer

Hi there,

the problem is that you want to use quadrilateral finite elements, but your mesh is made up of triangle cells. See here for more. In particular, FEniCS does not yet seem to support quadrilateral finite elements.

answered May 10, 2017 by wilhelmbraun FEniCS User (2,070 points)
selected May 10, 2017 by alidorostkar
...