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

Quadrature element

+3 votes

In the newest version of FeNiCs, I don't seems to be able to call

DG = VectorFunctionSpace(mesh, "Quadrature", degree=2)

Missing quad_scheme in quadrature element.
Traceback (most recent call last):
File "ArtsActive_v5.py", line 272, in
DG = VectorFunctionSpace(mesh, "Quadrature", degree=2)
File "/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.py", line 553, in VectorFunctionSpace
constrained_domain=constrained_domain)
File "/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.py", line 206, in init
self._init_from_ufl(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.py", line 226, in _init_from_ufl
dolfin_element, dolfin_dofmap = _compile_dolfin_element(element, mesh, constrained_domain=constrained_domain)
File "/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.py", line 89, in _compile_dolfin_element
ufc_element, ufc_dofmap = jit(element, mpi_comm=mesh.mpi_comm())
File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 65, in mpi_jit
return local_jit(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 143, in jit
return form_compiler.jit(form, parameters=p)
File "/usr/local/lib/python2.7/dist-packages/FFC-1.7.0dev-py2.7.egg/ffc/jitcompiler.py", line 119, in jit
parameters=parameters, jit=True)
File "/usr/local/lib/python2.7/dist-packages/FFC-1.7.0dev-py2.7.egg/ffc/compiler.py", line 204, in compile_element
analysis = analyze_elements(elements, parameters)
File "/usr/local/lib/python2.7/dist-packages/FFC-1.7.0dev-py2.7.egg/ffc/analysis.py", line 99, in analyze_elements
error("Missing quad_scheme in quadrature element.")
File "", line 1, in
File "build/bdist.linux-x86_64/egg/ufl/log.py", line 158, in error
Exception: Missing quad_scheme in quadrature element.

Any help would be greatly appreciated!
Thanks!

asked Mar 22, 2016 by lee FEniCS User (1,170 points)

Hi, see the penultimate comment in this thread for the answer.

Thanks Mirok! I saw that comment before. But I still don't quite know how to interpolate a field onto the quadrature function space.

For example, I have a field defined as

 DGfine = VectorFunctionSpace(finemesh, "DG", 0)
 field = Function(DGfine, 'field.xml')

and I want to interpolate to a quadrature functional space and I used to be able to do that using

Quad = VectorFunctionSpace(mesh, "Quadrature", 2)
fieldQuad = interpolate(field, Quad)

but this seems not possible in v1.7

I confirm there seems to be some issue here. This works:

import dolfin
mesh = dolfin.UnitSquareMesh(1,1)
fe = dolfin.FiniteElement(family="Quadrature", cell=mesh.ufl_cell(), degree=1, quad_scheme="default")
fs = dolfin.FunctionSpace(mesh, fe) # can't use keyword arguments here

However, this does not (Exception: Missing quad_scheme in quadrature element):

import dolfin
mesh = dolfin.UnitSquareMesh(1,1)
fs = dolfin.FunctionSpace(mesh, "Quadrature", 1) # can't use keyword arguments here

Similarly, this does not work (Exception: Missing quad_scheme in quadrature element):

import dolfin
mesh = dolfin.UnitSquareMesh(1,1)
vfs = dolfin.VectorFunctionSpace(mesh, "Quadrature", 1) # can't use keyword arguments here

Any hint? Thanks!

1 Answer

0 votes

Hi! This code runs fine on the 2016.1 version:

from dolfin import *
mesh = UnitSquareMesh(4,4)

quad_element = VectorElement(family = "Quadrature",
                             cell = mesh.ufl_cell(),
                             degree = 2,
                             quad_scheme="default")

Quad = FunctionSpace(mesh, quad_element)

finemesh = adapt(mesh)
DGfine = VectorFunctionSpace(finemesh, "DG", 0)
field = Function(DGfine)

q = interpolate(field, Quad)
answered Feb 16, 2017 by finsberg FEniCS User (2,360 points)
...