[Gmsh] pointsources and Nodes and Elements lists

Bart Vandewoestyne Bart.Vandewoestyne at telenet.be
Mon Oct 11 10:40:59 CEST 2010


Hello list,

For an application I'm working on, we use gmsh as our mesher, we parse the .msh
file and then run our solver in Matlab.  From the .msh file, we extract the X
and Y coordinates of the nodes (from $Nodes) in the mesh.  We also have a
matrix representing the triangular elements in the mesh (extracted from
$Elements).

We would like our users to be able to specify pointsources in our computational
domain.  The location of the pointsource is an arbitrary point that a user
specifies and has nothing to do with the mesh.  In gmsh, we currently specify
it as follows:


----------------------- small example ------------------
lc = 0.6;

// Corner points.
Point(1) = {0, 0, 0, lc};
Point(2) = {0, 1, 0, lc};
Point(3) = {1, 1, 0, lc};
Point(4) = {1, 0, 0, lc};

// Point sources.
Point(5) = {0.6, 0.6, 0, lc};
Point(6) = {0.7, 0.7, 0, lc};

Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};

Line Loop(5) = {1, 2, 3, 4};
Plane Surface(6) = {5};

Physical Point("Pointsource") = {5, 6};
Physical Surface("My Surface") = {6};
----------------------- end small example ------------------


And now here is the problem: if I mesh this .geo file with

  gmsh -2 pointsource_test.geo

then this is the result:


------------------ small example mesh ---------------------

$MeshFormat
2.1 0 8
$EndMeshFormat
$PhysicalNames
2
0 1 "Pointsource"
2 2 "My Surface"
$EndPhysicalNames
$Nodes
7
1 0 0 0
2 0 1 0
3 1 1 0
4 1 0 0
5 0.6 0.6 0
6 0.7 0.7 0
7 0.5 0.5 0
$EndNodes
$Elements
6
1 15 3 1 5 0 5
2 15 3 1 6 0 6
3 2 3 2 6 0 1 7 4
4 2 3 2 6 0 3 7 2
5 2 3 2 6 0 7 3 4
6 2 3 2 6 0 7 1 2
$EndElements

----------------------- end small example mesh ---------


The 'problem' is that the coordinates of the pointsource appear in the list
of nodal coordinates.  This has two consequences:

1) Our solver cannot have the pointsource coordinates in its list of x and y
   coordinates.  It should only have the x and y coordinates of the *real*
   nodes in our mesh.

2) Using the tags in the $Elements section, i can of course detect which
   nodes are pointsources, and remove them from the $Nodes section in my
   Matlab parser, but removing nodes from the $Nodes section also means that
   a lot of indices in the $Elements section need to change!  For example,
   if I remove nodes 5 and 6, then every 7 in the $Elements section has to be
   replaced by a 5 (because node 5 and 6 were removed, and node 7 has become
   node 5).


Is there a way to circumvent this troublesome bookkeeping?  Maybe somehow
prevent gmsh from putting our pointsources in the list of nodes, and returning
the coordinates of our pointsources in another section somehow? (I'm just
guessing here...)

Kind regards,
Bart

-- 
	"Share what you know.  Learn what you don't."