tensor multiplication in weak form

Asked by robert kersting

Hello there,

I have some problems in multiplying tensors in the weak formulation.
Maybe it is a problem of the assemble function... Would be great, if someone can help me.
Here is my little code:

#start
from dolfin import *

#mesh
mesh = Rectangle(0.0, 0.0, 1.0, 1.0, 10, 10)

# Define function spaces
V = VectorFunctionSpace(mesh, "CG", 1)

# Define trial and test functions
U = TrialFunction(V)
T_U = TestFunction(V)

i,k = indices(2)

Form = T_U[i].dx(k) * (U[i]*U[k])*dx

#lefthandside of Form
a = lhs(Form)

# Assemble matrices
A = assemble(a)

#end

I wonder, why it doesn't work?
U[i]*U[k]
ist just a tensor like
U[i].dx(k)
.
And with
Form = T_U[i].dx(k) * U[i].dx(k)*dx
or
inner(grad(T_U), grad(U))
it works perfectly. But unfortunately not what I want:-(

So is there a way to assemble these ''strange'' tensors?

Thank you very much ans best regards,
Robert

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
robert kersting (robert-kersting) said :
#1

I thought it could work with this (*) notation:

Instead of:
Form = T_U[i].dx(k) * (U[i]*U[k])

this:
Form = inner( grad(T_U) , outer(U,U)) (*)

with:
outer(U,U) = U[i]*U[k]
grad(T_U) = U[i].dx(k)

But it dosen't. Are there any stupid mistakes? Thanks...

Revision history for this message
robert kersting (robert-kersting) said :
#2

It works, if I define the outer product term as a product of two different vectors U and U0:

U0 = Function(V)

Form = T_U[i].dx(k)*(U[i]*U0[k])*dx

so is there a problem because dolfin can't handle outer(U,U) (with the same Vectors?)

best regards, RK

Revision history for this message
Marie Rognes (meg-simula) said :
#3

Your form needs to be linear in the basis functions (Arguments). TestFunction and TrialFunctions are Arguments. Functions are not, so your form can be nonlinear in Functions. You may want to check your formulation and see what should be Functions and what should be Test/TrialFunctions.

Can you help with this problem?

Provide an answer of your own, or ask robert kersting for more information if necessary.

To post a message you must log in.