The below code works for me. You are initialzing a Function from a FunctionSpace with value size 2, which is done as you present.
If you want to set the initial conditions for the whole solution vector you need an Expression with value_shape 3, including the scalar sub function space W too. Johan On Friday April 8 2011 05:44:56 Melanie Jahny wrote: > Question #152076 on DOLFIN changed: > https://answers.launchpad.net/dolfin/+question/152076 > > Status: Answered => Open > > Melanie Jahny is still having a problem: > Sorry, I just wanted to keep the question text brief. > The code is > > mesh = Rectangle(0,0,150,0.29, 750, 20) > mesh.order() > > # Define function spaces (P2-P1) > V = VectorFunctionSpace(mesh, "CG", 2) > W = FunctionSpace(mesh, "CG", 1) > > # combined Function Space > VW = V*W > > (u,p) = TrialFunctions(VW) > > class InitialConditions(Expression): > def __init__(self): > random.seed(2 + MPI.process_number()) > def eval(self, values, x): > values[0] = 0.02 > values[1] = 0.02 > def value_shape(self): > return (2,) > > > I tried now to use a Function for Interpolation: > > u_init = InitialConditions() > u_test = Function(V) > u_test.interpolate(u_init) > > I get an error message in eval. It works if I change the eval function > in the InitalConditions class: > > def eval(self, values, x): > values[0] = 0.02 > > But if I do this, are the two components of the vector valued function > initialized? > > And I've got another question: > Can I define the solution of a differential equation as a Function instead > of a TrialFunction? > Can I use u_test now as the solution function? > What is the difference? > > Thanks for your help!!! _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : [email protected] Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp

