Hi everyone,
I am currently working on solving a dynamic deformation problem on a 2D mesh: RectangleMesh(Point(xmin, ymin), Point(xmax, ymax), 20, 20, “right/left”). During the deformation, top boundary deforms, and my problem depends on top boundary normals.
So, I would like to compute and display the normal vectors to deforming top boundary of the rectangle mesh iteratively, at each timestep.
I have tried the below function, but when I display iteratively normals, they do not seem to be updated and stay on the initial mesh configuration.
My question:
- Is my function get_new_topboundary_normals() correct (computation and display)?
- How should I make sure top boundary normals are correctly updated into the problem? Recomputing them within the loop or within the residual form?
- Could you maybe provide me some examples?
Many thanks,
Anne
I got inspired by code in Iterate over all facets on mesh surface to obtain average values for each facet
V = VectorFunctionSpace(mesh, “CG”, 1)
ds = Measure(“ds”, domain=mesh, subdomain_data=boundaries)
def get_new_topboundary_normals(mesh, dofs_mesh, dofs_topboundary, V, ds):
u_trial = TrialFunction(V)
v_test = TestFunction(V)
normals_topboundary = Function(V) # normals at top boundary vertices
n = FacetNormal(mesh)
a = inner(u_trial, v_test) * ds(1) # ds(1): “top” boundary
l = inner(n, v_test) * ds(1)
A = assemble(a, keep_diagonal=True)
L = assemble(l)
A.ident_zeros()
solve(A, normals_topboundary.vector(), L)
vdf.plot( normals_topboundary,
mode=‘mesh arrows’,
style=‘matplotlib’,
axes=4,
azimuth=0,
interactive=True,
viewup=[‘0.’,‘0.’,‘1.’],
scale=0.05).clear()
return normals_topboundary