Changing coordinates in one direction only
Dear all, I use a change of coordinate to solve my equations, and I then save the solutions in the initial domain. The transform is \hat{x} = L(x-R)/(L-R). In 1D, my code to save the data in the initial (not transformed) mesh is: ---------------------------- # mesh on which I solve the equations (\hat{x}) mesh_transformed = mesh.coordinates.vector().get_local() # back to the initial mesh (applying the inverse transform) (x) mesh.coordinates.vector().set_local(mesh_transformed*(L-R)/L + R) # save data on the initial mesh save_h << h save_psi << psi # Back to the transformed mesh to solve the WF (\hat{x}) mesh.coordinates.vector().set_local(mesh_transformed) ---------------------------- This works well in 1D. However, I would like to extend my model in 2D, where the transform is still only in x. Therefore, I would like to apply the previous manipulation to the x coordinate only, and not on the 2D mesh. The previous code changes both x and y. How can I change only x ? Thanks, Floriane
Dear Floriane, Don't use .vector() if you want to treat different coordinates differently. Try something like this: mesh.coordinates.dat.data[:, 0] *= (L-R)/L mesh.coordinates.dat.data[:, 0] += R Regards, Miklos ________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Floriane Gidel [RPG] <mmfg@leeds.ac.uk> Sent: 05 August 2016 08:50:47 To: firedrake Subject: [firedrake] Changing coordinates in one direction only Dear all, I use a change of coordinate to solve my equations, and I then save the solutions in the initial domain. The transform is \hat{x} = L(x-R)/(L-R). In 1D, my code to save the data in the initial (not transformed) mesh is: ---------------------------- # mesh on which I solve the equations (\hat{x}) mesh_transformed = mesh.coordinates.vector().get_local() # back to the initial mesh (applying the inverse transform) (x) mesh.coordinates.vector().set_local(mesh_transformed*(L-R)/L + R) # save data on the initial mesh save_h << h save_psi << psi # Back to the transformed mesh to solve the WF (\hat{x}) mesh.coordinates.vector().set_local(mesh_transformed) ---------------------------- This works well in 1D. However, I would like to extend my model in 2D, where the transform is still only in x. Therefore, I would like to apply the previous manipulation to the x coordinate only, and not on the 2D mesh. The previous code changes both x and y. How can I change only x ? Thanks, Floriane
Thanks Miklos, it works ! Best, Floriane ________________________________ De : firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> de la part de Homolya, Miklós <m.homolya14@imperial.ac.uk> Envoyé : vendredi 5 août 2016 09:49:32 À : firedrake Objet : Re: [firedrake] Changing coordinates in one direction only Dear Floriane, Don't use .vector() if you want to treat different coordinates differently. Try something like this: mesh.coordinates.dat.data[:, 0] *= (L-R)/L mesh.coordinates.dat.data[:, 0] += R Regards, Miklos ________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Floriane Gidel [RPG] <mmfg@leeds.ac.uk> Sent: 05 August 2016 08:50:47 To: firedrake Subject: [firedrake] Changing coordinates in one direction only Dear all, I use a change of coordinate to solve my equations, and I then save the solutions in the initial domain. The transform is \hat{x} = L(x-R)/(L-R). In 1D, my code to save the data in the initial (not transformed) mesh is: ---------------------------- # mesh on which I solve the equations (\hat{x}) mesh_transformed = mesh.coordinates.vector().get_local() # back to the initial mesh (applying the inverse transform) (x) mesh.coordinates.vector().set_local(mesh_transformed*(L-R)/L + R) # save data on the initial mesh save_h << h save_psi << psi # Back to the transformed mesh to solve the WF (\hat{x}) mesh.coordinates.vector().set_local(mesh_transformed) ---------------------------- This works well in 1D. However, I would like to extend my model in 2D, where the transform is still only in x. Therefore, I would like to apply the previous manipulation to the x coordinate only, and not on the 2D mesh. The previous code changes both x and y. How can I change only x ? Thanks, Floriane
participants (2)
- 
                
                Floriane Gidel [RPG]
- 
                
                Homolya, Miklós