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

Scale solution fields and move mesh

0 votes

I have a running solver which computes a solution u. I want to scale the solution and use the scaled solution dx = s * u to move my mesh. I have successfully moved my mesh by feeding the move function with the solution directly, but when I scale my solution I get a TypeError.

I am trying this:

# Solve all time steps
steps = 20
for step in range(steps):
    # Solve
    solve(a == L, u)

    # Compute displacement distance
    dx = 1.0/steps * u;

    # Displace mesh
    ALE.move(mesh0, dx)

and get:

TypeError: in method 'ALE_move', argument 2 of type 'dolfin::GenericFunction const &'
asked Jun 15, 2017 by sehlstrom FEniCS Novice (180 points)

1 Answer

+1 vote
 
Best answer

I've had similar problems with the ALE.move() function. My knowledge of FEniCS is limited, but I think that multiplying u by some constant changes the type of the function. If you take type(u) and type(dx) then you'll see that they're different kinds of Python objects.

This approach usually works for me:

V = VectorFunctionSpace(mesh0, "CG", 1)
du = project(1.0/steps*u,V)
ALE.move(mesh0,du)

Alternatively, you can try this if you want to avoid the project() function:

V = VectorFunctionSpace(mesh0, "CG", 1)
du = Function(V)
du.vector()[:] = 1.0/steps*u.vector()
ALE.move(mesh0,du)
answered Jun 15, 2017 by jimmy FEniCS Novice (730 points)
selected Jun 16, 2017 by sehlstrom

First approach worked. Thanks!

...