FreeFem / FreeFem-sources

FreeFEM source code
https://freefem.org/
Other
746 stars 187 forks source link

origin of 2D-meshes appear at [0,0] instead of at the chosen coordinate #304

Closed VolkerRaab closed 5 months ago

VolkerRaab commented 5 months ago

When I execute the following script:

mesh Th = square(100,100, [10*(x-1/2), 20*(y-1/2)]);
fespace F(Th, P1);
F sinsin = sin(x)*sin(y);
plot(sinsin);

I get a tiling with a knot in the bottom left corner instead of in the center of the plot. The mesh seems to respect the different extensions along x and y but not the shifted origin. Is this by design?

prj- commented 5 months ago

Your mesh definition is wrong, you are performing integer divisions (whereas you want floating-point divisions).

mesh Th = square(100,100, [10.0*(x-1.0/2.0), 20.0*(y-1.0/2.0)]);
VolkerRaab commented 5 months ago

Dear Pierre, thanks a lot for the quick reply 👍 and sorry for that somewhat stupid error 🥴.