← Back to team overview

dolfin team mailing list archive

Re: [Question #152076]: Initial Concition for vector valued function

 

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

    Status: Open => Answered

Anders Logg proposed the following answer:
On Fri, Apr 08, 2011 at 08:45:07AM -0000, Melanie Jahny wrote:
> New question #152076 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/152076
>
> I've got a Trial Function in VectorFunctionSpace and I'd like to
> define an initial value for this function.
> My function is defined as follows:
>
> class InitialConditions(Expression):
>     def __init__(self):
>         values[0] = 0.02
>         values[1] = 0.02

This part looks strange. Why do you set the values in the constructor.

>     def eval(self, values, x):
>         values[0] = 0.02
>         values[1] = 0.02
>     def value_shape(self):
>         return (2,)

This part looks good.

> V = VectorFunctionSpace(mesh, "CG", 2)
> u = TrialFunction(V)
> u_init = InitialConditions()
> u.interpolate(u_init)
>
> I adopted this from the Cahn-Hilliard example, but I don't understand how I can
> adapt it for vector valued functions.
> Please can you help me?! Thanks!

I don't understand the question. The above example code you have given
is for a vector-valued function.

--
Anders

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