← Back to team overview

dolfin team mailing list archive

[Question #147504]: Subfunction does not work any more

 

New question #147504 on DOLFIN:
https://answers.launchpad.net/dolfin/+question/147504

Hello,

yesterday my system upgraded fenics to the new version 11.02-2~ppa2~maverick1.
Now my simple Mixed Formulation example stated below does not work any more. The compiler gives an error: 
    File "test.py", line 20, in <module>
    p = W[1]
    TypeError: 'MixedFunctionSpace' object does not support indexing
It also is not possible to define p like that:
p = Function(W.sub(1))
This will give the error:
    File "test.py", line 20, in <module>
    p = Function(W.sub(1))
    File "/usr/lib/python2.6/dist-packages/dolfin/function/function.py", line 98, in __init__
    cpp.Function.__init__(self, V)
    File "/usr/lib/python2.6/dist-packages/dolfin/cpp.py", line 13325, in __init__
    _cpp.Function_swiginit(self,_cpp.new_Function(*args))
   RuntimeError: *** Error: Cannot create a Function from a subspace. The subspace needs to be collapsed.

Why was this possible with the older version? How should I implement a subfunction now?

*****************
Example file:
*****************
from dolfin import *

# Optimization options for the form compiler
parameters["form_compiler"]["cpp_optimize"] = True
parameters["form_compiler"]["optimize"] = True

mesh = UnitSquare(64,64)

V1 = FunctionSpace(mesh, "CG", 1)
V2 = FunctionSpace(mesh, "CG", 2)
W  = V1 * V2

(sigma,u) = TrialFunction(W) # y,p
(v,tau)   = TestFunction(W)  # better performance -- symmetric?

a0 = (dot(grad(u),grad(tau)) + dot(grad(sigma),grad(v))- sigma*tau)*dx
f0 = tau*dx

yp = Function(W)
p = W[1]


*******************************

Thanks,
Patricia


You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.