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

Project on Quadrature function space in Fenics 2017.1.0

+2 votes

Hi,

I used to be able to project a ufl expression into Quadrature functionspace in Fenics 2016.2.0 but that doesn't seems to be able to work in the 2017.1.0.

For example, the following code:

import dolfin as df

deg = 2
df.parameters["form_compiler"]["quadrature_degree"]=deg
df.parameters["form_compiler"]["representation"] = "uflacs"

mesh = df.UnitCubeMesh(1, 1, 1)
V = df.VectorFunctionSpace(mesh, "Lagrange", 2)
u = df.Function(V)
F = df.Identity(3) + df.grad(u)
C = F.T*F

Quadelem = df.FiniteElement("Quadrature", mesh.ufl_cell(), degree=deg,    quad_scheme="default")
Quad = df.FunctionSpace(mesh, Quadelem)

e1 = df.Function(V)

ls = df.inner(e1, C*e1)
lsprj = df.project(ls, Quad)

will produce the following error:

Moving new file over differing existing file:
src: /home/likchuan/Research/fenicsheartmodel2/strippeddown/jitfailure-ffc_form_c94e290f78247dd89872cf8388ce7a628cfa6fa6  /error.log.cf6b7283b08746b1be2d9e46180c9668
dst: /home/likchuan/Research/fenicsheartmodel2/strippeddown/jitfailure-     ffc_form_c94e290f78247dd89872cf8388ce7a628cfa6fa6/error.log
backup: /home/likchuan/Research/fenicsheartmodel2/strippeddown/jitfailure-ffc_form_c94e290f78247dd89872cf8388ce7a628cfa6fa6/error.log.old
Backup file exists, overwriting.
Compilation failed! Sources, command, and errors have been written to: /home/likchuan/Research/fenicsheartmodel2/strippeddown/jitfailure-   ffc_form_c94e290f78247dd89872cf8388ce7a628cfa6fa6
Traceback (most recent call last):
 File "test.py", line 38, in <module>
  lsprj = df.project(ls, Quad)
 File "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/dolfin/fem/projection.py", line 142, in project
   form_compiler_parameters=form_compiler_parameters)
 File "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/dolfin/fem/assembling.py", line 350, in assemble_system
A_dolfin_form = _create_dolfin_form(A_form, form_compiler_parameters)
 File "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/dolfin/fem/assembling.py", line 67, in _create_dolfin_form
function_spaces=function_spaces)
 File "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/dolfin/fem/form.py", line 89, in __init__
mpi_comm=mesh.mpi_comm())
 File "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 70, in mpi_jit
return local_jit(*args, **kwargs)
File "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 147, in jit
"ffc.jit failed with message:\n%s" % (tb_text,))
File "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/dolfin/cpp/common.py", line 2214, 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 "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 142, in jit
    result = ffc.jit(ufl_object, parameters=p)
  File "/home/likchuan/.hashdist/bld/profile/rwlceu6wj3pg/lib/python2.7/site-packages/ffc/jitcompiler.py", line 210, in jit
    raise FFCJitError("A directory with files to reproduce the jit build failure has been created.") 
 FFCJitError: A directory with files to reproduce the jit build failure has been created.
 .
 *** Where:   This error was encountered inside jit.py.
 *** Process: 0
 *** 
 *** DOLFIN version: 2017.1.0
 *** Git changeset:  
 *** -------------------------------------------------------------------------

Any help is greatly appreciated!
Thanks!

asked May 29, 2017 by lee FEniCS User (1,170 points)

I've experienced pretty much the same problem with the latest version. Here's another working example, in case it helps:

#!/usr/bin/python
from dolfin import *
from mshr import *

QUAD_DEG = 2
parameters["form_compiler"]["representation"] = "uflacs"
parameters["form_compiler"]["quadrature_degree"] = QUAD_DEG

r = Rectangle(Point(0.0,0.0), Point(1.0,1.0))
mesh = generate_mesh(r,64)

# used to work in 2016.2, but not in 2017.1
VHE = FiniteElement("Quadrature",mesh.ufl_cell(),\
                    degree=QUAD_DEG,quad_scheme="default")

# works in 2017.1
#VHE = FiniteElement("Lagrange",mesh.ufl_cell(),1)

VH = FunctionSpace(mesh,VHE)

# Hack based on mikael-mortensen's response in the following old thread:
#
# https://fenicsproject.org/qa/1425/derivatives-at-the-quadrature-points
#
# In the real application, Constant(1.0) is replaced with a complicated
# expression (not to be confused with the class Expression) involving
# derivatives of Functions, conditionals, etc. that I am trying to store
# as a history variable at quadrature points.
#
vH = TestFunction(VH)
uH = TrialFunction(VH)
Htemp = Function(VH)
H_proj_res = inner(uH-Constant(1.0),vH)*dx
aH_proj,LH_proj = lhs(H_proj_res), rhs(H_proj_res)
Hproblem = LinearVariationalProblem(aH_proj,LH_proj,Htemp)
Hsolver = LinearVariationalSolver(Hproblem)

Hsolver.solve()

Try to set

df.parameters["form_compiler"]["representation"] = "quadrature"

Thanks, that works !!

Thanks! However, does anyone know whether the issues with derivative() and conditional() discussed in these threads have been addressed in the latest release?

https://bitbucket.org/fenics-project/ufl/issues/70/derivative-of-conditional

https://bitbucket.org/fenics-project/ffc/issues/107/ffc-fails-with-conditionals-which-are

That is the reason I was using uflacs. (The "conditional workaround" didn't quite seem to solve the problems in my application.)

I find that using uflacs is much faster and take less memory during compilation. One way I use to get around is to directly specify uflacs during the solving i.e.,

solve(F == 0, w, bcs, J = Jac, form_compiler_parameters={"representation":"uflacs"})
...