Hi,
I have a scalar function which I want to use to do some operations and assign the results to the components of a vector function. What I can do is to use a scalar function to modify another scalar function. I think it is better understood in this example:
import dolfin as df
import numpy as np
mesh = df.RectangleMesh(-1, -1, 1, 1, 2, 2)
# Create a scalar and vector spaces
space_S1 = df.FunctionSpace(mesh, 'CG', 1)
space_S3 = df.VectorFunctionSpace(mesh, 'CG', 1, dim=3)
# Create two scalar functions and a vector function
# from the previously defined spaces
f1 = df.interpolate(df.Expression("1"), space_S1)
f2 = df.Function(space_S1)
f3 = df.Function(space_S3)
# If we want a scalar function with twice
# the values of f1 (THIS WORKS)
vec = df.assemble(df.dot(2 * f1, df.TestFunction(space_S1)) * df.dP)
f2.vector().axpy(1, vec)
# Now we want to modify the vector function space
# to get the vector (2, 1, 1) in every vertex
# using the f1 function (THIS DOES NOT WORK)
vec = df.assemble(df.dot((2 * f1, f1, f1), df.TestFunction(space_S3)) * df.dP)
I don't know how I should write the 3-component vector in the dot
inside the assemble. In my example, I get the error:
Invalid type conversion: <type 'tuple'> can not be converted to any UFL type.
The representation of the object is:
...
Regards