# Deformed mesh plot displaced

**URL:** https://community.freefem.org/t/deformed-mesh-plot-displaced/4354
**Category:** General Discussion
**Created:** [September 2, 2026, 10:56am UTC](https://community.freefem.org/t/deformed-mesh-plot-displaced/4354 "2026-09-02T10:56:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wrg11](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@wrg11](https://community.freefem.org/u/wrg11)
#### Post date: [September 2, 2026, 10:56am UTC](https://community.freefem.org/t/deformed-mesh-plot-displaced/4354/1 "2026-09-02T10:56:27Z")

</div>

I’ve computed a solution for a solid wave in a rectangular bar. This particular case has an analytical solution, and line plots confirm that it’s been found. However, plots of the deformed mesh have unexpected creases, as shown (for real and imaginary parts of the solution) here:

 ![defmshr](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/c/ca3727d7c9dedbefff3f11b8a69e83b48703b7a0.png)

 ![defmshi](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/c/c2d733dea876c0a66ec74b528f2fdcb7fc3adfaf.png)

The code that produces these (and the line plots) is listed below. Quiver and contour plots are also generated, in case they’re helpful.

// Waves on a bar of rectangular cross-section.  
// Developed from gempro-code-bareigFF.cpp

load “msh3”

// 1. Geometric and Material Parameters  
real Lx = 2.0 \* sqrt(2); real nu = 0.3; // Used for Lame modes  
real Ly = 2.0;  
real mu = 1.0; // Shear modulus  
real lam = 2_nu/(1 - 2_nu); // Lame’s first parameter (lambda)  
real rho = 1.0; // Density  
real k = 3.1416; // Given real wavenumber (M&F zeta; T&I gamma)

int nx = 40;  
int ny = 30;

// 2. Mesh Generation  
mesh Th = square(nx, ny, [x_Lx, y_Ly]);  
plot(Th, wait=true);

// 3. Finite Element Space  
// P2 elements for all three displacement components, complex-valued  
fespace Vh(Th, [P2, P2, P2]);  
Vh [u1, u2, u3];  
Vh [v1, v2, v3];

// 5. Variational Formulations  
// Stiffness Matrix (Strain Energy)  
varf vK([u1, u2, u3], [v1, v2, v3]) =  
int2d(Th)(  
lam \* (dx(u1)+dy(u2)-1i_k_u3) \* (dx(v1)+dy(v2)+1i_k_v3)

- 2.0 \* mu \* (  
dx(u1) \* dx(v1)
- dy(u2) \* dy(v2)
- k^2 \* u3 \* v3)
- mu \* (  
(dy(u1)+ dx(u2)) \* (dy(v1)+ dx(v2))
- (-1i_k_u2 + dy(u3)) \* (1i_k_v2 + dy(v3))
- (dx(u3) - 1i_k_u1) \* (dx(v3) + 1i_k_v1)  
)  
);

// Mass Matrix (Kinetic Energy)  
varf vM([u1, u2, u3], [v1, v2, v3]) =  
int2d(Th)(  
rho \* (u1_v1 + u2_v2 + u3\*v3)  
);

// Assemble Matrices  
matrix K = vK(Vh, Vh);  
matrix M = vM(Vh, Vh);

// 6. Eigenvalue Solution via ARPACK  
int nev = 10; // Number of requested eigenvalues  
complex[int] ev(nev); // Array to store eigenvalues  
Vh[int] eVec1, eVec2, eVec3; // Eigenvectors

// Solve generalized eigenvalue problem A \* x = lambda \* B \* x  
// where lambda = omega^2  
real sig = 20.0;  
matrix Kshft = K - sig\*M;  
set(Kshft, solver=sparsesolver);

int kfound = EigenValue(Kshft, M, sigma=sig, value=ev, vector=eVec1, nev=nev);

// 8. Plot eigenvectors  
fespace Vhplt(Th,P2);  
int kplt = 2; // mode to plot, counting from _one_  
Vhplt uxr = real(eVec1[kplt-1]);  
Vhplt uxi = imag(eVec1[kplt-1]);  
Vhplt uyr = real(eVec2[kplt-1]);  
Vhplt uyi = imag(eVec2[kplt-1]);  
Vhplt uzr = real(eVec3[kplt-1]);  
Vhplt uzi = imag(eVec3[kplt-1]);  
meshS ThNew = movemesh23(Th, transfo=[x + uxr, y + uyr, uzr]);  
plot(ThNew, wait=true, value=true, ps=“defmshr.eps”, cmm=“Deformed mesh, real displacements”);  
meshS ThNewi = movemesh23(Th, transfo=[x + uxi, y + uyi, uzi]);  
plot(ThNewi, wait=true, value=true, ps=“defmshi.eps”, cmm=“Deformed mesh, imag displacements”);

// — Define Slice Parameters —  
real xSlc = 0.5\*Lx;  
real yMin = 0.0, yMax = Ly;  
int Ny = 50; // Grid resolution for the slice  
real[int] ySlc(Ny+1), uyrsl(Ny+1), uyisl(Ny+1), uzrsl(Ny+1), uzisl(Ny+1);

real deey = (yMax - yMin) / Ny;

for (int j = 0; j \<= Ny; j++) {

```auto
ySlc[j] = yMin + j * deey;

// FreeFEM automatically interpolates the FE functions
uyrsl[j] = uyr(xSlc, ySlc[j]);
uyisl[j] = uyi(xSlc, ySlc[j]);
uzrsl[j] = uzr(xSlc, ySlc[j]);
uzisl[j] = uzi(xSlc, ySlc[j]);

```

}

plot([uxr,uyr],value=true,cmm=“Re(ux,uy)”,wait=true);  
plot([ySlc,uyrsl],value=true,cmm=“Re(uy) vs y”,wait=true);

plot(uzr,cmm=“Re(uz)”,value=true, wait=true);  
plot([ySlc,uzrsl],value=true,cmm=“Re(uz) vs y”,wait=true);

plot([uxi,uyi],value=true,cmm=“Im(ux,uy)”,wait=true);  
plot([ySlc,uyisl],value=true,cmm=“Im(uy) vs y”,wait=true);

plot(uzi,value=true,cmm=“Im(uz)”,wait=true);  
plot([ySlc,uzisl],value=true,cmm=“Im(uz) vs y”,wait=true);

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [September 2, 2026, 2:31pm UTC](https://community.freefem.org/t/deformed-mesh-plot-displaced/4354/2 "2026-09-02T14:31:11Z")

</div>

[xxx.edp](https://community.freefem.org/uploads/short-url/vQjK4QT4yzUL2cTbCmTP74zyFWJ.edp) (3.2 KB)

The problem is just du to too large deformation in

> movemesh23(Th, transfo=[x + uxr, y + uyr, uzr]);  
> The problem is just du to too large and if the multiply by 0.1 it will be OK (remenber the eigen value a normalized!).

My small correction are in file xxx.edp

---

<div class="post-metadata">

### Author: ![wrg11](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@wrg11](https://community.freefem.org/u/wrg11)
#### Post date: [September 3, 2026, 1:55pm UTC](https://community.freefem.org/t/deformed-mesh-plot-displaced/4354/3 "2026-09-03T13:55:49Z")

</div>

Thank you. I should have checked that possibility before posting!
