← Back to team overview

ufl team mailing list archive

Re: [Question #164419]: How to compute a pointwise vector product within an ufl-file

 

Question #164419 on UFL changed:
https://answers.launchpad.net/ufl/+question/164419

    Status: Open => Answered

Martin Sandve Alnæs proposed the following answer:
Hi Norman,

On 11 July 2011 17:51, Norman Lang <question164419@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Question #164419 on UFL changed:
> https://answers.launchpad.net/ufl/+question/164419
>
>    Status: Answered => Open
>
> Norman Lang is still having a problem:
> elem=FiniteElement("Lagrange",tetrahedron,1)
> v = TestFunction(element)
>
> The expression inner(1, v)*ds(1)  should do the same like v*ds(1) i guess. With that expression i want to generate a vector of length n, where n is the number of grid nodes (because of use of Lagrange, 1) and the vector only has some constant entries on node places of the boundary one (ds(1)).
> Later on this should be an input vector of an optimal control problem.
>
> Now i want to create a vector which depends on my spatial coordinate z.
> More precise i want to generate a vector of the form
>
>                              B(i)=exp(-50*z(i))*v(i)*ds(1).

This is ambiguous. Can you write it in (pseudo-)LaTeX?
I interpret your line above as roughly:

V := span{ v_i(x) }
z \in V
z(x) := \sum_i z_i v_i(x)
B_i = exp(-50 z_i)  (  \int_{d\Omega} v_i(x) dx  )

Is that right? Then no, you can't express that in UFL.

> The entries of vector should vary over the hight of my working piece.
> In my C++ code i could realize that via a pointwise multiplication.
>
> But i want to get that expression into my variational form to generate the right hand side of my system of linear equations which i want to solve with FEniCS.

The variational forms you define in UFL will always be integrated, i.e.
expression*ds(1) means "the integral of (expression) over boundary 1".

> Because of your answer
>
> 'Unless you can write what you want into the PDE, you cannot express it
> with UFL.
>
> UFL is a language for variational forms, not for linear algebra
> operations on the assembled global vectors and matrices.'
>
> i think it isn't really possible. So i would be happy if some has got an
> other approach for this problem.

I think your original approach of doing pointwise multiplication
at the linear algebra level is what you have to do.
Unless you can formulate your problem differently.
I don't understand where your equations come from,
so I can't help any more than that.

Martin

> I hope one can understand my problem now and i want to thank for the previous answer.
>
> Regards,
>
> Norman
>
> --
> You received this question notification because you are a member of UFL
> Team, which is an answer contact for UFL.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~ufl
> Post to     : ufl@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ufl
> More help   : https://help.launchpad.net/ListHelp
>

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