← 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:
On 11 July 2011 15:25, Norman Lang <question164419@xxxxxxxxxxxxxxxxxxxxx> wrote:
> New question #164419 on UFL:
> https://answers.launchpad.net/ufl/+question/164419
>
>
>
> i am really new in working with fenics and the packages around. So i have got a question about ufl. I want to generate an input Matrix for an optimal control problem.
> So i am writing down my variational form and want to get the expression
>
>                                    L = c*inner(1,v)*ds(1)

inner(1, v) does not make any sense to me.
You need to specify more clearly what you're
doing with a small but complete code example.
If v is a scalar, it is the same as just v.
If v is not a scalar, it will trigger an error.


> in my matrix (c is only an constant). For that i am assembling L to an Vector B via
>
>                          assemble(B, L, NULL, & sub_domains, NULL);
>
> Now i want to pointwise multiply this vector with another vector, called z.
> I am writing my main programm in C++ and the pointwise multiplying doesn't make any problem.
>
> My question is now. How could i get the pointwise multiplication into the ufl-file, such that, i don't have to do the multiplication after assembling my vector.

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 tried to use the Coefficient class in ufl and later on i tried it with the Function class via
>
> elem=FiniteElement("Lagrange",tetrahedron,1)
>
> z = Coefficient(elem) or z = Function(elem).
>
> With the Coefficient class the multiplication
>
>                        L = z*c*inner(1,v)*ds(1)
>
> does not create an error but the result isn't correct when i'm comparing it with the pointwise operation
>
>                z.*B,        where B is the assembled Vector from above
>
> in MATLAB. So i'm sure i'm not computing a pointwise multiplication of two vectors.
> Could you please help me with this problem. It would really help me.
>
> 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.