In order to control the element size distribution, an octree is built around the surface (or domain) to be discretized. The size of individual octants corresponds approximately to the required element spacing specified by the user (for example on the control grid) while the nodes of the octants are storing the required spacing exactly. To ensure the gradual variation of element size the maximum one-level octree difference of octants sharing an edge is enforced. This will guarantee creation of well shaped triangles. During the actual mesh generation the required element size is extracted from the octree for a given location using the interpolation of octree nodal values of the mesh size.