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

dolfin split vs dolfin_adjoint split

0 votes

Hello, the following lines of code are working for me only with dolfin, but not with dolfin_adjoint:

from dolfin import *

M=UnitSquareMesh(20,20)
V = VectorFunctionSpace(M,"DG", 0)
Q = FunctionSpace(M,"CG",1)
Z = MixedFunctionSpace([V, Q])

PHI = Function(Z)

u,p=PHI.split(deepcopy=True)
u0,u1=u.split(deepcopy=True)

If I also import dolfin adjoint this way:

from dolfin import *
from dolfin_adjoint import *

Without editing anything else, I get the following error:

u0,u1=u.split(deepcopy=True)
TypeError: 'bool' object is not callable

I looked a bit into the examples, but I still don't know what I'm supposed to do instead to achieve the same result.

Thanks a lot,

Davide

asked Aug 23, 2013 by DLongoni FEniCS Novice (300 points)

What version of dolfin_adjoint do you have? Your code above works fine with the latest version from launchpad together with the master branch of dolfin from bitbucket.

Sorry for the late reply,

those are the libraries I have installed with the corresponding versions:

dolfin-bin 1.2.0-1~ppa1~precise1
libdolfin1.2 1.2.0-1~ppa1~precise1
libdolfin1.2-dev 1.2.0-1~ppa1~precise1
python-dolfin 1.2.0-1~ppa1~precise1
python-dolfin-adjoint 1.2.0-0~835~precise1

I also tried:

u0,u1=split(u),

but the problem with that is that the output type is "Indexed" insead of "Coefficient", so that I can'd (or don't know how to) extract nodal values information doing something like

u0.vector().array()

thanks for the help

I'm currently using this workaround, which is not fantastic but at least works for me.

from dolfin import *
from dolfin_adjoint import *

M=UnitSquareMesh(20,20)
V = VectorFunctionSpace(M,"DG", 0,dim=2)
Q = FunctionSpace(M,"CG",1)
Z = MixedFunctionSpace([V, Q])

PHI = Function(Z,name="solution")

u,p=split(PHI)

up=project(u,V)

u0,u1=split(up)
...