[Gmsh] [Freefempp] Import a 2D mesh

Christophe Geuzaine cgeuzaine at ulg.ac.be
Wed Sep 2 21:56:09 CEST 2009


Geordie McBain wrote:
> 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

Indeed, that should be easy. Currently we only save "Triangles", 
"Quadrilaterals" and "Tetrahedra" in the MESH format. Is the format for 
the edges similar? (What is the label?)



> 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.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh


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