← Back to team overview

dolfin team mailing list archive

Re: [Question #159021]: Assigning initial values to a mixed function space for a nonlinear problem.

 

Question #159021 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/159021

Martin Sandve Alnæs posted a new comment:
On 25 May 2011 23:16, Douglas Brinkerhoff
<question159021@xxxxxxxxxxxxxxxxxxxxx> wrote:
> New question #159021 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/159021
>
> I would like to assign an initial guess to two solution variables in the following way, given two functions u0 and v0:
>
>
> V = FunctionSpace(mesh,"Lagrange",1)
> W = MixedFunctionSpace([V,V])
>
> phi,psi = TestFunctions(W)
> dU = TrialFunctions(W)
> U = Function(W)
>
> du,dv = split(dU)
> u,v = split(U)
>
> #Here is where I would like to assign initial values u0 and v0 for my non-linear problem
> u.assign(u0)
> v.assign(v0)
>
> u0 and v0 are already defined as functions on the appropriate function space.
>
> When I use this particular syntax, I receive an error message stating that indexed objects don't have an assign method.  Fair enough, but how do I bypass this so that I can assign an initial guess.  This problem cannot converge from a zero starting solution.
>

You could also project u0,v0 into u,v:

a = (du*phi + dv*psi)*dx
L = (u0*phi + v0*psi)*dx
problem = VariationalProblem(a, L)
problem.solve(U)

Not tested!

But it would be nice with a more direct way to assign to a subfunction.

Martin

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