Hi, I am new to FreeFem++. I googled for the answer of this problem but without success. I need some help, please.
I have an scalar field Temperature defined on a 2D mesh Th2.
I deform this mesh with movemesh23 and get a new mesh Th3.
When I plot Temperature on Th3 it does not always work.
When Th2 is cartesian coordinates, it does work.
But when Th2 is curvilinear coordinates (say angles) it does not work.
How can I transfer an scalar field defined in Th2 so that I can plot it on Th3?
Thank you!
Example:
real r=1;
real R=2;
real x0 = pi/2;
real x1 = 3pi/2;
real y0 = pi;
real y1 = 2pi;
int n = 5;
real 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
plot(Th2, Temp, nbiso=30, fill=true, value=true, cmm=“A”);//plot 2D ok
func f1 = rsin(x);
func f2 = (R-rcos(x))cos(y);
func f3 = (R-rcos(x))*sin(y);
meshS Th3 = movemesh23(Th2, transfo=[f1,f2,f3]);
fespace Ch3(Th3,P2);
Ch3 temp3d=Temp;
plot(Th3, temp3d, nbiso=30, fill=true, value=true, cmm=“A”);//plot not ok
Hello,
If you write temp3d=Temp, the function Temp defined on a 2d mesh (which is interpreted with z=0 as a subset of R^3) is extended by 0 outside of the 2d mesh, then interpolated on Th3. The result is that temp3d=0.
A more correct way is to write temp3d[]=Temp[]. It means that the vector of coordinates in the finite element basis it taken the same.
This works for the space P1 testtransfer.edp (579 Bytes)
as long as the numbering of vertices of Th3 is obtained as the numbering of vertices of Th2 transported by transfo=[f1,f2,f3]
For P2 it does not work because the numbering of dofs seems to be different for the two meshes. Then I have no simple way to do it.
Dear François,
Thank you for your help! Using temp3d=Temp in P1 does work indeed! It is a pity that the same will not hold for P2. In any case, I can always work in P2, and then project into P1 prior to the assignment to the 3d mesh.
Thanks a lot for your invaluable help.
Angel.