Hi everyone!
A few months ago I had this code to deform a mesh from changes in the boundary
from typing import List
def deform_mesh(V, bcs: List[dolfinx.fem.DirichletBCMetaClass]):
mesh = V.mesh
uh = dolfinx.fem.Function(V)
dolfinx.fem.petsc.set_bc(uh.vector, bcs)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)
a = ufl.inner(ufl.grad(u), ufl.grad(v))*ufl.dx
L = ufl.inner(dolfinx.fem.Constant(mesh, (0., 0.)), v)*ufl.dx
problem = dolfinx.fem.petsc.LinearProblem(a, L, bcs, uh)
problem.solve()
deformation_array = uh.x.array.reshape((-1, mesh.geometry.dim))
mesh.geometry.x[:, :mesh.geometry.dim] += deformation_array
c_el = mesh.ufl_domain().ufl_coordinate_element()
V = dolfinx.fem.FunctionSpace(mesh, c_el)
mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
all_facets = dolfinx.mesh.exterior_facet_indices(mesh.topology)
top_facets = dolfinx.mesh.locate_entities_boundary(
mesh, mesh.topology.dim-1, walls)
bc_fixed_facets = []
for facet in all_facets:
if facet not in top_facets:
bc_fixed_facets.append(facet)
fixed_dofs = dolfinx.fem.locate_dofs_topological(
V, mesh.topology.dim-1, bc_fixed_facets)
c = dolfinx.fem.Constant(mesh, (0., 0.))
bc_fixed = dolfinx.fem.dirichletbc(c, fixed_dofs, V)
, but now I get the following error.
module 'dolfinx.fem' has no attribute 'DirichletBCMetaClass'
Does anyone know how I can update it?
Thank you very much