This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

About Mixed Functions

+1 vote

Hello,

I would like to solve a time depend problem in a mixed
function space.

What is the correct way to define the functions (u1, tau1, p1)
and to update them in the time loop in what follows:

V_u   = VectorFunctionSpace(mesh, "DG", 2)                  # vector
V_tau = TensorFunctionSpace(mesh, "DG", 2, symmetry=False)  # matrix
V_p   = FunctionSpace(mesh, "DG", 1)                        # scalar
W = MixedFunctionSpace([V_u,V_tau,V_p])

(u, tau, p) = TrialFunctions(W)
(v, sig, q) = TestFunctions(W)


# definition of a function in W
(u1, tau1, p1) <-?->  Functions(W)


# definition of my forms 
#    using operators defined for matrix, vector, ...
a = f(  u, tau,  p, v,  sig,  q)
L = f(  v, sig,  q, u1, tau1, p1, ...)

A = assemble(a)


sol = Function(W)
while t < T
    t += dt

    b = assemble(L)
    solve(A,sol.vector(),b)

    # update the right hand side
    (u1, tau1, p1) <-?- sol 

thanks in advance

asked Jul 4, 2013 by micdup FEniCS User (1,120 points)

2 Answers

+2 votes
 
Best answer

You can either use two Functions: w0 and w1 for the left and right end-point values on each interval. Write the variational formulation in terms of w0 (for the "previous" values), then solve for w1.vector(). In each time step, you can then assign the values from w1 to w0 by

w0.assign(w1)

If the problem is linear, then you can reuse the same vector w0 for both the left and right end-point values and solve directly for w0, without needing to call the assign function.

answered Jul 4, 2013 by logg FEniCS Expert (11,790 points)
selected Jul 8, 2013 by Jan Blechta
0 votes

Try:

sol = Function(W)
u1, tau1, p1 = split(sol)
answered Jul 4, 2013 by johanhake FEniCS Expert (22,480 points)
...