Dot product for system of equations

Asked by Praveen C

Hello

I have a system of two equations in 1-D. If I do the following, I get errors. How do I take dot product in this case.

Thanks
praveen

# Load mesh from file
mesh = UnitInterval(20)

V = FunctionSpace(mesh, "CG", 1)
W = V * V

# Define test functions
w = TestFunctions(W)

# Define trial functions
Uold = Function(W)
U = Function(W)

F = (1/k)*dot(U - Uold,w)*dx

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Martin Sandve Alnæs
Solved:
Last query:
Last reply:
Revision history for this message
Best Martin Sandve Alnæs (martinal) said :
#1

Try just w = TestFunction(W). Not sure what you try to do though.

Martin
Den 5. juli 2011 16.21 skrev "Praveen C" <
<email address hidden>> følgende:
> New question #163821 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/163821
>
> Hello
>
> I have a system of two equations in 1-D. If I do the following, I get
errors. How do I take dot product in this case.
>
> Thanks
> praveen
>
>
> # Load mesh from file
> mesh = UnitInterval(20)
>
> V = FunctionSpace(mesh, "CG", 1)
> W = V * V
>
> # Define test functions
> w = TestFunctions(W)
>
> # Define trial functions
> Uold = Function(W)
> U = Function(W)
>
>
> F = (1/k)*dot(U - Uold,w)*dx
>
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

Revision history for this message
Praveen C (cpraveen) said :
#2

Thanks Martin Sandve Alnæs, that solved my question.

Revision history for this message
Praveen C (cpraveen) said :
#3

That solved my problem.

But I have seen some examples in undocumented which use "TrialFunctions".

$ grep TrialFunctions */python/*.py
restriction/python/demo_restriction.py:#(uv,uw) = TrialFunctions(mixed)
stokes-iterative/python/demo_stokes-iterative.py:(u, p) = TrialFunctions(W)
stokes-mini/python/demo_stokes-mini.py:(u, p) = TrialFunctions(Mini)
stokes-stabilized/python/demo_stokes-stabilized.py:(u, p) = TrialFunctions(system)
stokes-taylor-hood/python/demo_stokes-taylor-hood.py:(u, p) = TrialFunctions(W)

Want to understand the difference.

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) said :
#4

On 5 July 2011 18:31, Praveen C <email address hidden> wrote:
> Question #163821 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/163821
>
> Praveen C posted a new comment:
> That solved my problem.
>
> But I have seen some examples in undocumented which use
> "TrialFunctions".
>
> $ grep TrialFunctions */python/*.py
> restriction/python/demo_restriction.py:#(uv,uw) = TrialFunctions(mixed)
> stokes-iterative/python/demo_stokes-iterative.py:(u, p) = TrialFunctions(W)
> stokes-mini/python/demo_stokes-mini.py:(u, p) = TrialFunctions(Mini)
> stokes-stabilized/python/demo_stokes-stabilized.py:(u, p) = TrialFunctions(system)
> stokes-taylor-hood/python/demo_stokes-taylor-hood.py:(u, p) = TrialFunctions(W)
>
>
> Want to understand the difference.

Then you should read the UFL manual.

ufl/doc/manual/ufl-user-manual.pdf

Kristian

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

Revision history for this message
Praveen C (cpraveen) said :
#5

The ufl manual does not say the difference between the two. I only see some example usage.

Revision history for this message
Johan Hake (johan-hake) said :
#6

On Tuesday July 5 2011 09:31:17 Praveen C wrote:
> Question #163821 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/163821
>
> Praveen C posted a new comment:
> That solved my problem.
>
> But I have seen some examples in undocumented which use
> "TrialFunctions".
>
> $ grep TrialFunctions */python/*.py
> restriction/python/demo_restriction.py:#(uv,uw) = TrialFunctions(mixed)
> stokes-iterative/python/demo_stokes-iterative.py:(u, p) = TrialFunctions(W)
> stokes-mini/python/demo_stokes-mini.py:(u, p) = TrialFunctions(Mini)
> stokes-stabilized/python/demo_stokes-stabilized.py:(u, p) =
> TrialFunctions(system)
> stokes-taylor-hood/python/demo_stokes-taylor-hood.py:(u, p) =
> TrialFunctions(W)
>
>
> Want to understand the difference.

This is the ouput from help(TestFunction[s]):

TestFunction(element)
    UFL value: Create a test function argument to a form.

TestFunctions(element)
    UFL value: Create a TestFunction in a mixed space, and return a
    tuple with the function components corresponding to the subelements.

These two are equivalent:

   1)
   v = TestFunction(W)
   v0, v1 = split(v)

   2)
   v0, v1 = TesetFunctions(W)

When you then do:

  w = TesetFunctions(W)

w is a tuple of two sub-TestFunctions which cannot be used in a Form.

Johan