In order to control the element size gradation and to implement the spatial localization, an octree is built around the surface (or domain) to be discretized. The octree is a hierarchic data structure, at the top of which is a root octant represented by a cube surrounding the entire domain. This root octant is then recursively divided into eight octants until all terminal (not further divided) octants are at the desired level in the octree hierarchy. The size of terminal octants corresponds approximately to the required element spacing specified by the user, while the nodes (corners) 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 obviously cause the mesh to be more dense in some regions in comparison to the required element size but simultaneously it will guarantee creation of well shaped elements. 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 size.