[Gmsh] [Freefempp] Import a 2D mesh

Geordie McBain gdmcbain at freeshell.org
Wed Aug 26 02:56:30 CEST 2009


On Wed, Aug 26, 2009 at 1:19 AM, Flavio Cimolin<flavio.cimolin at polito.it> wrote:
> Hello everybody,
>
> I have a 2D mesh (for example in Nastran or STL format), which I want to
> import in freeFEM++.
> Surfing the archives I have seen that by means of gmsh it is possible to
> convert
> the .stl into the .mesh format, which can easily be modified from 3D to
> 2D in
> order to be importable by freeFEM++ with the readmesh command.
>
> However, I cannot figure out how to set the boundary labels of the mesh
> in order
> to properly define boundary conditions for the differential problem. Is
> it possible
> to import some kind of mesh realized outside freeFEM++ together with the
> boundary labels,
> or otherwise to easily re-define the boundaries from inside freeFEM++?
> What would you recommend for performing this task?

The basic problem here is that when Gmsh exports a mesh in MEDIT .mesh
format, it only exports certain element types (triangles,
quadrilaterals, and tetrahedra); see the function GModel::writeMESH in
Geo/GModelIO_Mesh.cpp.  In particular, it fails to export the 2-node
edge elements that constitute the boundary of a two-dimensional mesh.
You'll find that it works fine in three dimensions, since tetrahedra
(the domain elements) and triangles (the boundary elements) are
exported.
  I imagine that it shouldn't be too difficult to modify the Gmsh
source code to get it to export the edge elements required for
boundaries in two dimensions, but I'm not sufficiently familiar with
the internal coding of Gmsh yet to attempt this myself.  I'm copying
this to the Gmsh mailing list to see whether anyone there has any
suggestions.
  What I've done as a workaround in two dimensions is actually export
the Gmsh mesh in its native .msh format and then written a simple
translation function in GNU Octave.  I attach that in case it's
helpful.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: msh2mesh.m
Type: text/x-objcsrc
Size: 2204 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20090826/605a037c/attachment.m>