How extract the displacement field on the boundary?

I got the displacement field as solution. I then create a deformed mesh with the displacement field. Now I want to use the displacement in the reverse direction as displacement boundary condition to get back to the original shape. I tired Mesh.Domainboundar(). but I couldn’t find it in my library so I am unable to use it.

  1. How to get the displacement field on the boundary alone.
  2. How to apply it in the deformed mesh without projecting the displacement field onto a deformed mesh:
    import numpy as np
    mesh = df.UnitSquareMesh(36,36)
    V = df.VectorFunctionSpace(mesh, "Lagrange",2,dim=2)
    u=df.project(df.Expression(("x[0]", "x[1]"), degree= 1),df. VectorFunctionSpace(mesh, "CG", 1))
    def boundary(x,on_boundary):
        return on_boundary
    u_bndry="function to get the displacement on the boundary"
    DeformedMesh = df.Mesh(mesh)
    X = DeformedMesh.coordinates()
    X+=np.vstack(map(u,X))
    V_1= df.VectorFunctionSpace(DeformedMesh, "Lagrange",2,dim=2)
    D_bc=df.DirichletBC(V_1,-u_bndry,boundary)

The following code does exactly what you would like to do without defining a new mesh:

import numpy as np
import dolfin as df
mesh = df.UnitSquareMesh(36,36)
V = df.VectorFunctionSpace(mesh, "Lagrange",2,dim=2)
u=df.project(df.Expression(("2*x[0]", "x[1]"), degree= 1),df. VectorFunctionSpace(mesh, "CG", 1))
def boundary(x,on_boundary):
    return on_boundary
df.ALE.move(mesh, u)
u_out = df.Function(V)
D_bc=df.DirichletBC(V,-u,boundary)
# Add boundary condition to new function to visualize its effect
D_bc.apply(u_out.vector())
df.File("u_on_deformed.pvd") << u_out

Does ALE change the vectorFunctionSpace V along with mesh?

I’d like to compress the object.

The function space is dependent of the mesh, as you are implicitly changing the mesh, you are also changing the function space with this command.

I am not sure what you mean by your last remark:

is mesh and function space V are maintained by some call by reference kind of method?

The function space contains a reference to the mesh, print for instance V.mesh() and mesh, or the id V.mesh().id() and mesh.id(), or mesh==V.mesh().
ALE.move is an implicit operation that changes the coordinates of your mesh (similar to what you did manually on your deformed mesh).

I’d like to solve the problem by defining (sigma:epsilon) in LHS and RHS =0 with the BCS as mentioned above. just changing the displacement field u_out.vector will not ensure what I want, isn’t it?

I am not sure what you are asking for now.
What I have shown above is the following:

  1. Deform your mesh with a displacement u
  2. Create a Dirichlet-condition on the deformed mesh which enforces -u on the boundary.

The variable u_out is simply there as a helper for you to see that the boundary condition is applied on the deformed mesh, in the direction opposite to the initial deformation. This is why I apply the boundary condition to u_out and save it to file, so you can visualize it in Paraview.

1 Like

Thanks, I see what you mean. It worked well .