# Movemesh23 and move solution for visualisation

**URL:** https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211
**Category:** General Discussion
**Created:** [February 3, 2026, 2:33pm UTC](https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211 "2026-02-03T14:33:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)
#### Post date: [February 3, 2026, 2:33pm UTC](https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211/1 "2026-02-03T14:33:04Z")

</div>

For a parameterised sphere,

if we solve a problem in the parameter space, for example `(0, 2pi) x (0, pi)`

we can use _movemesh23()_ to generate the mesh of a sphere quickly,

my question is: how can we move the solution to the sphere for visualisation – ideally a node to node transfer such as `us[] = u[]` ?

To clarify my question: we have a flat 2D mesh `Th`

```auto
fespace Vh(Th, P1, periodic=[[2, y], [4, y]]);

Vh u.
...

meshS ThS = movemesh23(Th, transfo=[a*sin(y)cos(x),asin(y)sin(x),acos(y)],removeduplicate=1);

fespace VhS(ThS, P1);
VhS us;

```

How can we move `u` to `us`?

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [February 4, 2026, 8:39pm UTC](https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211/2 "2026-02-04T20:39:59Z")

</div>

There is a method that works here

> [@Transfer scalar field to deformed mesh with movemesh2d](https://community.freefem.org/t/transfer-scalar-field-to-deformed-mesh-with-movemesh2d/4010/4):
>
> Dear Angel Daniel, Indeed the following lines make it work for P2 or any finite element space: int[int] renum(Ch.ndof); for (int k=0;k\<Th2.nt;++k){ for (int j=0;j\<Ch.ndofK;++j){ renum(Ch3(k,j))=Ch(k,j); } } temp3d[]=Temp[](renum); full code: load "msh3" real r=1.; real R=2.; real x0 = pi/2.; real x1 = 3.\*pi/2.; real y0 = pi; real y1 = 2.\*pi; int n = 5; int m = 5; mesh Th2 = square(n, m, [x0+(x1-x0)\*x, y0+(y1-y0)\*y]); fespace Ch(Th2,P2); Ch Temp; //calculations of Temp follow Temp=x; plot…

but it is related to the property that the mesh nodes are purely transported by th transformation.  
In your case you have “removeduplicate=1” that breaks this property (the two meshes do not have the same number of nodes).  
Maybe you can do it if you set “removeduplicate=0”

---

<div class="post-metadata">

### Author: ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)
#### Post date: [February 4, 2026, 9:12pm UTC](https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211/3 "2026-02-04T21:12:30Z")

</div>

Thanks for your help. I wrote a piece of code to find the corresponding nodes, although it looks ugly:

```auto
Vh theta=x, phi=y; 

VhS us, xs=x, ys=y, zs=z;

real xx, yy, zz, dd;
for(int i=0; i<xs[].n; i++){
for(int j=0; j<theta[].n; j++){
xx = sin(phi[][j])cos(theta[][j]);
yy = sin(phi[][j])sin(theta[][j]);
zz = cos(phi[][j]);
dd = sqrt( (xs[][i]-xx)(xs[][i]-xx) + (ys[][i]-yy)(ys[][i]-yy) + (zs[][i]-zz)(zs[][i]-zz) );
if (dd < 1.e-5) us[][i]=u[][j];
}
}

```

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [February 4, 2026, 9:50pm UTC](https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211/4 "2026-02-04T21:50:30Z")

</div>

You don’t need to find the nodes, they follow the map as long as you keep all the nodes (and do not remove some of them).  
Thus you can do in several steps:

1. define your square mesh and your initial periodic function u.  
Transport the mesh to a meshS by movemesh23.

2. define a a slighly smaller square mesh, and interpolate your u on this mesh to ucut.  
Transpor the mesh to a meshS S1 which is not closed (so that you keep all the nodes).  
Transport ucut to us1

3. finally interpolate us1 to us.

```auto
real a=1.;

mesh Th=square(10,10,[2.*pi*x,pi*y]);
cout << "Th.nt " << Th.nt << " Th.nv " << Th.nv << endl;;
fespace Vh(Th, P1, periodic=[[2, y], [4, y]]);
Vh u;
u=cos(x)*sin(y);

meshS ThS=movemesh23(Th, transfo=[a*sin(y)*cos(x),a*sin(y)*sin(x),a*cos(y)],removeduplicate=1);
cout << "ThS.nt " << ThS.nt << " ThS.nv " << ThS.nv << endl;
fespace VhS(ThS, P1);
VhS us;

mesh Thcut=square(10,10,[2.*pi*0.999*x,0.001+pi*0.998*y]);
cout << "Thcut.nt " << Thcut.nt << " Thcut.nv " << Thcut.nv << endl;;
fespace Vhcut(Thcut, P1);
Vhcut ucut;
ucut=u;

meshS ThS1=movemesh23(Thcut, transfo=[a*sin(y)*cos(x),a*sin(y)*sin(x),a*cos(y)],removeduplicate=0);
cout << "ThS1.nt " << ThS1.nt << " ThS1.nv " << ThS1.nv << endl;;
fespace VhS1(ThS1,P1);
VhS1 us1;
us1[]=ucut[];

us=us1;

plot(ThS);

```

However there are some warning messages “no manifold obj” for ThS, and “unfreed pointers, memory leak” that are a bit scary

---

<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: [February 26, 2026, 9:46am UTC](https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211/5 "2026-02-26T09:46:41Z")

</div>

yes, it works in this case

---

<div class="post-metadata">

### Author: ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)
#### Post date: [March 3, 2026, 10:57am UTC](https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211/6 "2026-03-03T10:57:50Z")

</div>

In the case of moving a vector `(u, v)` from `Th` to a vector `(ux, uy, uz)` on `ThS`, I assume there is no easier way – it seems we have to compute the derivative of the mapping and push forward `(u, v)` to the surface `ThS`, or there is a better idea @fb77 @frederichecht ?

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [March 3, 2026, 2:53pm UTC](https://community.freefem.org/t/movemesh23-and-move-solution-for-visualisation/4211/7 "2026-03-03T14:53:45Z")

</div>

I agree with your view: additionally to the composition you have to multiply by the tangent mapping.
