difference between *.split() and split(*)

Asked by Lyuda Vynnytska

Hi, I am curious why results of *.split() and split(*) differ. Thanks!
#---------------------------------------------------------------------------------------------------
from dolfin import *

def strain(v):
    return 0.5*(grad(v) + grad(v).T)

def momentum(W, eta, g, H):
    (u, p) = TrialFunctions(W)
    (v, q) = TestFunctions(W)

    F = (2.0*eta*inner(strain(u), strain(v))*dx
         + div(v)*p*dx
         + div(u)*q*dx
         + H*inner(g, v)*dx)
    return (lhs(F), rhs(F))

def compute_initial_conditions(T_):
    #eta = exp(1.0 - triangle.x[1])
    eta = 1.0
    Ra = Constant(1.0e+6)
    g = Constant((0.0, -1.0))

    (a, L) = momentum(W, eta, g, Ra*T_)
    w = Function(W)

    (A, b) = assemble_system(a, L, bcs)
    solve(a == L, w, bcs)
    return w

mesh = Rectangle(0, 0, 1.0, 1.0, 60, 80)
V2 = VectorFunctionSpace(mesh, "CG", 2)
V1 = FunctionSpace(mesh, "CG", 1)
W = V2 * V1
Q = FunctionSpace(mesh, "DG", 2)

top = DirichletBC(W.sub(0), (500.0, 0.0), "x[1] == 1.0" )
bottom = DirichletBC(W.sub(0).sub(1), 0.0, "x[1] == 0.0")
left = DirichletBC(W.sub(0).sub(0), 0.0, "x[0] == 0.0")
right = DirichletBC(W.sub(0).sub(0), 0.0, "x[0] == 1.0")
bcs = [bottom, top, left, right]

T0=Expression("(1.0 - x[1]*x[1]) + 0.01*cos(pi*x[0])*sin(pi*x[1])")
Tic = interpolate(T0, Q)
w_ = compute_initial_conditions(Tic)
(u, p) = split(w_)
(u_,p_) =w_.split()
plot(u_)
plot(u)
interactive()

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Marie Rognes
Solved:
Last query:
Last reply:
Revision history for this message
Best Marie Rognes (meg-simula) said :
#1

Hi Lyuda,

perhaps the answer to the previous question

   https://answers.launchpad.net/dolfin/+question/207313

may help?

--
Marie

On 10/18/2012 05:45 PM, Lyuda Vynnytska wrote:
> New question #211580 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/211580
>
> Hi, I am curious why results of *.split() and split(*) differ. Thanks!
> #---------------------------------------------------------------------------------------------------
> from dolfin import *
>
> def strain(v):
> return 0.5*(grad(v) + grad(v).T)
>
> def momentum(W, eta, g, H):
> (u, p) = TrialFunctions(W)
> (v, q) = TestFunctions(W)
>
> F = (2.0*eta*inner(strain(u), strain(v))*dx
> + div(v)*p*dx
> + div(u)*q*dx
> + H*inner(g, v)*dx)
> return (lhs(F), rhs(F))
>
> def compute_initial_conditions(T_):
> #eta = exp(1.0 - triangle.x[1])
> eta = 1.0
> Ra = Constant(1.0e+6)
> g = Constant((0.0, -1.0))
>
> (a, L) = momentum(W, eta, g, Ra*T_)
> w = Function(W)
>
> (A, b) = assemble_system(a, L, bcs)
> solve(a == L, w, bcs)
> return w
>
> mesh = Rectangle(0, 0, 1.0, 1.0, 60, 80)
> V2 = VectorFunctionSpace(mesh, "CG", 2)
> V1 = FunctionSpace(mesh, "CG", 1)
> W = V2 * V1
> Q = FunctionSpace(mesh, "DG", 2)
>
> top = DirichletBC(W.sub(0), (500.0, 0.0), "x[1] == 1.0" )
> bottom = DirichletBC(W.sub(0).sub(1), 0.0, "x[1] == 0.0")
> left = DirichletBC(W.sub(0).sub(0), 0.0, "x[0] == 0.0")
> right = DirichletBC(W.sub(0).sub(0), 0.0, "x[0] == 1.0")
> bcs = [bottom, top, left, right]
>
> T0=Expression("(1.0 - x[1]*x[1]) + 0.01*cos(pi*x[0])*sin(pi*x[1])")
> Tic = interpolate(T0, Q)
> w_ = compute_initial_conditions(Tic)
> (u, p) = split(w_)
> (u_,p_) =w_.split()
> plot(u_)
> plot(u)
> interactive()
>

Revision history for this message
Lyuda Vynnytska (lyudav) said :
#2

Yes, thanks!