-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User Expression broken in FEniCS 2018.1 #57
Comments
I had the same problem. Actually, for me there were two problems. One problem was related to the Conda version of dolfin where |
Hi, |
Same issue here.
|
Seems that this project is no longer maintained? I decided to use python instead. Alternatively, one can simply use pycall to run a python version of fenics inside Julia. However, this results in a pyobject return, which is not compatible with FEniCS.jl. |
@EvergreenTree I'll try to have a look into your issue in depth tomorrow when I get into the office. I was under the impression this issue was fixed with the code above. Are you on the latest version (i.e. master) of fenics.jl? |
@ysimillides Thanks for your reply. I tried reinstalling both with Pkg.add("FEniCS") and with cloning this git, but got exactly the same error. I suspect that this is the same issue as @clason has said, i.e. the change of Expression function into UserExpression during one FEniCS update. |
@ysimillides After looking into your code (line 74 of jfem.jl), I found that this works
|
Yet this works: |
@ysimillides Anyway I think it's a bug. Could you please update this fix to the master or let me do this? I wish it would be helpful to FEniCS users. Thank you! |
@EvergreenTree I use this snippet to extract sparse Julia matrices from FEniCS: #55 (comment) For PyCall 1.90, the snippet has to be slightly adapted (and a workaround seems to be no longer needed) using SparseArrays,PyCall
# create a demo matrix
fe = pyimport("fenics")
mesh = fe.UnitSquareMesh(64,64)
V = fe.FunctionSpace(mesh,"CG",1)
u,v = fe.TrialFunction(V),fe.TestFunction(V)
a = fe.dot(fe.grad(u),fe.grad(v))*fe.dx + fe.Dx(u,1)*v*fe.dx # non-symmetric form
A_fe = fe.assemble(a) # wrapper for dolfin matrix
# convert to PETSc matrix, accessible via petsc4py
A_py = fe.as_backend_type(A_fe).mat()
# convert to Julia matrix -- note that we feed the CSR structure to a CSC constructor
m,n = A_py.getSize()
indptr,indices,data = A_py.getValuesCSR()
A_jl = SparseMatrixCSC(m,n,indptr.+1,indices.+1,data)
# transpose to get correct structure (collect lazy wrapper)
A_jl = sparse(A_jl') (Like you, I switched to direct PyCall access to FEniCS as this project seemed... less than fully maintained.) |
FEniCS 2018.1 changed how
UserExpression
s work (due to the switch to pybind11), see, e.g., https://www.allanswered.com/post/jrmxq/expression-with-cpp-code-behaviour-changed-with-2018-1-0-dev0pybind11/, https://www.allanswered.com/post/jrmxq/expression-with-cpp-code-behaviour-changed-with-2018-1-0-dev0pybind11/. It seems that this also impacts howExpression
s are propagated in Julia: The following line from the README.md no longer works with FEniCS.jl (although it does work in Python and using PyCall!)instead giving
It would also help to prominently note in the README which FEniCS version this package is compatible with (and maybe test the version when
using FEniCS
and warn if it's not the right one).The text was updated successfully, but these errors were encountered: