firedrakeproject / firedrake

Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)
https://firedrakeproject.org
Other
509 stars 159 forks source link

Move 3d mesh using base mesh values #1022

Open dham opened 7 years ago

dham commented 7 years ago

Floriane reports:

I change the coordinates for saving purpose only (once the WF are solved). So my objective is to solve the WF in a fixed 2D RectangleMesh, and then save the functions in a 3D mesh in which I apply the coordinate transforms to get moving boundaries. I managed to do this when Ny>1, and I changed my code so that it works for Ny=1, but I would like a general command that works whatever the value of Ny.

So my question would be : how can I make the link between the x-coordinates in a RectangleMesh, and the x-coordinates in the 3D mesh obtained by extrusion of the RectangleMesh ?

For instance, for a function h_2D defined in the RectangleMesh, if I want to change the z-coordinate of the extruded mesh as z_new = z*h_2D/H0 so that the top boundary of the 3D domain for a given (xi,yi) coordinates moves as h_2D(xi,yi), how can I find the indices "..." to substitute into the following expression :

mesh_3D.coordinates.dat.data[ ..., 2]*= h_2D.dat.data[ ... ]/H0 ?

dham commented 7 years ago

You should use a hand-written kernel to do this. In essence this is similar to an extrusion kernel. See: http://www.firedrakeproject.org/extruded-meshes.html#generating-extruded-meshes-in-firedrake except that you call the par_loop yourself at a later time rather than having it called at mesh generation.

tkarna commented 7 years ago

Also see extrude_mesh_sigma function in Thetis that essentially does what you ask; modifies the z coords based on a 2d bathymetry field. https://github.com/thetisproject/thetis/blob/master/thetis/utility.py#L169