Hello, Dear Professor. This is a function that I wrote about generating moving meshes base on Can’t create 1D mesh in parallel, where Ulh is the numerical result of calculations on the original mesh, mesh modification with consistent topology, and this processing is performed serially when running, as well as when running on the original mesh, performance is good. But when I use mpirun -np n python3 my_file.py, If n is greater than 1, it will result in a new grid derangement. What I understand is that the transfer takes place only in the main process, and the data from the other processes is not added to the main process, what should I do? Looking forward to your guidance, thank you.
Thank you for your reply. This part is also what I want to learn, but I need to describe my own problem more clearly. My problem is a linear elastic problem; when there is external pressure, the whole region will be deformed, rather than simply internal node position changes. I think this is part of the content moving grid, not just the internal interface moving. Looking forward to your guidance!
The example above moves the internal nodes based on the data in a dolfinx.fem.Function, which I assume is what you will have as input to your own problem. It doesn’t have any assumptions that would keep the exterior boundary fixed, that is just due to the specifics of the prescribed functions expr and expr2
If u is a solution from a elasticity probloem, you can simply pass that to perturb_mesh(u)
We do not have a specific ALE module in FEniCSx. As you can observe, moving the mesh given a function can be done as above.
If you want to make a smoothen function, for instance by a Laplace smoothing, this is covered in:
NOTE: In the post above it doesn’t use the perturb_mesh, but assumes a 1-1 relationship between the mesh nodes and dofs. I would recommend adapting the code such that it looks like
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()
perturb_mesh(uh)