# [Gmsh] Generating a mesh for z=f(x,y) 3D surface

Christophe Geuzaine cgeuzaine at uliege.be
Mon Apr 22 21:02:35 CEST 2019

```
> On 12 Apr 2019, at 21:20, Amit Singh <amit112amit at yahoo.co.in> wrote:
>
> Dear all.
>
> I want to generate a mesh for the surface given by z=f(x,y) for x and y in [-1, 1]x[-1, 1]. In particular, I have z = sin(pi*x)*cos(pi*y).
>
> Currently, I use Numpy to create a mesh grid of points in the x-y plane and create their 2D Delaunay Triangulation (using scipy). Then, I loop over all the points and set their z-coordinate as per z=f(x,y). But in regions of high curvature, the triangles become elongated so I am forced to increase the number of points in the x-y grid. I also used a mesh optimization package from PyPi called optimesh to improve the aspect ratio of the triangles but it results in a reduction of surface area of the mesh by around 5%.
>
> Can anyone kindly share or point me to any gmsh tutorial / example that shows how to generate a mesh for a 3D surface such that the mesh density increases in regions of high curvature?
>

Since you know the curvature, you can directly use a Field to specify the mesh size: see e.g. tutorial/t10.geo.

Christophe

> Thanks and regards,
> Amit
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

—
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science
http://www.montefiore.ulg.ac.be/~geuzaine

```