I see that the ALE methods have not yet been added to dolfinx. How would one go about updating the nodes manually to try to do an updated lagrangian formulation of large deformation elasticity? I went through the mesh geometry class but couldn’t find a method to just update the positions.
Thanks!
dokken
April 5, 2020, 11:14am
2
Consider the following:
from dolfinx.fem import assemble_scalar
from dolfinx import MPI, UnitSquareMesh, FunctionSpace, Function, Constant
from ufl import VectorElement, dx
import numpy as np
mesh = UnitSquareMesh(MPI.comm_world, 2, 2)
el = VectorElement("CG", mesh.ufl_cell(), 1)
V = FunctionSpace(mesh, el)
v = Function(V)
def displacement(x):
vals = np.zeros((2, x.shape[1]))
vals[0] = x[0]
vals[1] = 2*x[1]
return vals
v.interpolate(displacement)
point_values = v.compute_point_values()
ext_values = np.zeros((point_values.shape[0], 3))
ext_values[:, :-1] = point_values
print(assemble_scalar(Constant(mesh, 1)*dx))
mesh.geometry.x += ext_values
print(assemble_scalar(Constant(mesh, 1)*dx))
1 Like
anna
June 21, 2021, 6:06pm
4
Hello. I had the same problem, but for me the solution above gave an Attribute Error. It worked by adding [:,:] behind the mesh.geometry:
from dolfinx.fem import assemble_scalar
from dolfinx import UnitSquareMesh, FunctionSpace, Function, Constant, RectangleMesh
from ufl import VectorElement, dx
from mpi4py import MPI
import numpy as np
mesh = UnitSquareMesh(MPI.COMM_WORLD, 1, 1)
el = VectorElement("CG", mesh.ufl_cell(), 1)
V = FunctionSpace(mesh, el)
v = Function(V)
def displacement(x):
vals = np.zeros((2, x.shape[1]))
vals[0] = x[0]
vals[1] = 2*x[1]
return vals
v.interpolate(displacement)
point_values = v.compute_point_values()
ext_values = np.zeros((point_values.shape[0], 3))
ext_values[:, :-1] = point_values
print(assemble_scalar(Constant(mesh, 1)*dx))
mesh.geometry.x[:,:] += ext_values
print(assemble_scalar(Constant(mesh, 1)*dx))