gf_mesh, gfMesh

Purpose

Creation of mesh objects .

Synopsis

M = gf_mesh('empty', int dim) 
M = gf_mesh('cartesian', vec X[, vec Y[, vec Z,..]])
M = gf_mesh('triangles grid', vec X, vec Y)
M = gf_mesh('regular simplices', vec X[, vec Y[, vec Z,.., ]][, 'degree', int K]['noised'])
M = gf_mesh('curved', const_mesh M0, vec F)
M = gf_mesh('prismatic', const_mesh M0, int K)
M = gf_mesh('pt2D', mat p, imat t[, int n])
M = gf_mesh('ptND', mat p, imat t)
M = gf_mesh('load', string filename)
M = gf_mesh('from string', string s)
M = gf_mesh('import', string format, string filename)
M = gf_mesh('clone', const_mesh M0)

Description

The function gf_mesh (or gfMesh) creates a new mesh object. The gf_mesh version returns a matlab structure, which can be manipulated with gf__mesh_get(M,...) and gf_mesh_set(M,...), while the gfMesh version returns an "object" (in the matlab sense) M which can also be manipulated with get(M, ...) and set(M, ...). The first argument specifies the kind of operation which will create the mesh. The returned value, M, is an identifier (of type uint32) to the new object.

gf_mesh('empty', dim) : return a new empty mesh, whose nodes have dim coordinates. This mesh can be later populated with e.g. gf_mesh_set('add convex',...).

gf_mesh('cartesian', X[, Y,...]) can be used to build quickly a cartesian mesh (with a linear geometric transformation, see gf_geotrans. The vectors X,Y,...contain the vertices coordinates along each axis. The regular numbering of points and convexes is guaranteed by this functions

gf_mesh('triangles grid', X, Y) : create a regular 2D mesh, similar to a cartesian grid where each rectangle is split in two triangles.

gf_mesh('regular simplices', X, ...) : is a generalization to arbitrary dimensions of the triangles grid. For example, gfMesh('regular simplices',0:10, 0:10, 'degree', 2, 'noised') will build a mesh of quadratic triangles (of irregular shape).

gf_mesh('curved', M0, F) : build a curved (n+1)-dimensions mesh from a n-dimensions mesh M0: the new mesh has one additional dimension. The additional coordinate is given by the vector F. This can be used to obtain meshes for shells.

gf_mesh('prismatic', M0, K) : extrude a prismatic mesh M from a mesh M0. In the additional dimension there are K layers of elements stacked in the range [0..1].

gf_mesh('pt2D', p, t[, n]) : build quickly a planar mesh from a points array p and a triangulation t. This can be used to convert a pdetool mesh exported in variables p and t into a getfem++ mesh M. n is optional and is a zone number. If n is specified only triangle belonging to the zone number n are created in the mesh. The points array p is assumed to be a 2×Npoints matrix, and the triangles array should be a 3×nbtri matrix, or a 4×nbtri if a zone number is used.

gf_mesh('ptND', p, t[, n]) this is a more general form of 'pt2d'. It builds a simplex mesh from a given triangulation. The dimension of the mesh will be the number of rows of p, and the dimension of the simplexes will be the number of rows of t.

gf_mesh('load', filename) load a mesh from a getfem++ mesh file (which may have been created by gf_mesh_get(M,'save',filename). gf_mesh('from string', s) is very similar, but the mesh is loaded from a string instead of a file. The content of this string may be set by s=gf_mesh_get(M,'char').

gf_mesh('import', format, filename) import a mesh from a file. For the moment, only three formats are supported:

  • mesh objects created with gmsh (GPL meshing/post processing tool): gf_mesh('import', 'gmsh', filename). Note that gmsh meshes always use 3D points, even for planar meshes. However, you can remove the z-component of the planar mesh with gf_mesh_set(m, 'transform', [1 0 0; 0 1 0]).
  • mesh objects created with GiD (only limited version is free, but it is able to generate quadratic elements): gf_mesh('import', 'gid', filename).
  • 2D triangular meshes from emc2, saved with the am_fmt format: gf_mesh('import', 'am_fmt', filename).
Support for other file-formats should be quickly available.

gf_mesh('clone', M0) return a copy of the mesh M0. Note that m = gf_mesh('clone', m0) is different from doing m = m0 since in the latter case, m and m0 still refer the same getfem mesh object!

See Also

Examples

Building a small 5×3 cartesian mesh:
m = gf_mesh('cartesian',[0:.2:1], [0:3])
Making a curved mesh with z=x2+y2:
pts = gf_mesh_get(m, 'pts coords');
V = pts(1,:).^2 + pts(2,:)^2;
m2 = gf_mesh('curved', m, V);