Basically, I want to know how to extract a vector from ListTensor object or Indexed object.
He's a minimal code.
What I was trying to do is similar to the calculation of b in this demo.
from dolfin import *
mesh = UnitSquareMesh(32, 32)
V = VectorFunctionSpace(mesh, "CG", 1, dim=2)
W = FunctionSpace(mesh, "CG", 1)
X = FunctionSpace(mesh, "CG", 1)
VWX = MixedFunctionSpace([V, W, X]) # mixed functions space
# Define trail and test functions
du_ = TrialFunction(VWX)
v_u, v_p, v_c = TestFunctions(VWX)
# define functions
u_ = Function(VWX) # current solution
u0_ = Function(VWX) # solution from previous step
# Split mixed functions
du, dp, dc = split(du_)
u, p, c = split(u_)
u0, p0, c0 = split(u0_)
a = inner(u, v_u)*dx
A = assemble(a)
# Class representing the initial conditions
class InitialConditions(Expression):
def __init__(self):
pass
def eval(self, values, x):
values[0] = 0
values[1] = 0
values[2] = 0
values[3] = 0.01
def value_shape(self):
return (4,)
# Create initial conditions and interpolate
u_init_ = InitialConditions()
u_.interpolate(u_init_)
u0_.interpolate(u_init_)
t = 0
dt = 0.01
while (t < 1):
b = A*u.vector() # doesn't work!