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

How to combine two scalar-valued functions into one vector-valued function.

0 votes

I'm dealing with a non-linear finite element problem in 2D.

Let u0 be a stored, previous time-step of u = TrialFunction(V)

Let v be the test-functions.

I need to be able to produce:

cross(curl(u),u0)

Such that the following line produces a matrix that makes sense:

a = -inner(grad(u),grad(v))*dx + inner(cross(curl(u),u0),v)*dx + div(v)*p*dx + q*div(u)*dx

It would appear that I need to create a function that computes my non-linear part explicitly, however, I can't seem to package the values back into the correct form. I realize the following function is totally incorrect, but it represents the "spirit" of what I'm trying to accomplish:

def nonlinear_part(h,k):
    out = Function(V)
    curl_y_h0 = Dx(h,1)[0]
    curl_x_h1 = Dx(h,0)[1]
    out = ((-k[1]*(curl_x_h1 - curl_y_h0)),k[0]*(curl_x_h1 - curl_y_h0))
    return out
asked Dec 11, 2015 by qwetico FEniCS Novice (360 points)

1 Answer

0 votes
 
Best answer

If you just need something to use in a form the as_vector function works nicely

u = as_vector([u0, u1, u2])

Where u0, u1, and u2 are scalar valued

answered Dec 14, 2015 by Tormod Landet FEniCS User (5,130 points)
selected Aug 2, 2016 by qwetico
...