[Gmsh] Geometry import

Geordie McBain gdmcbain at freeshell.org
Thu Apr 30 01:50:31 CEST 2015


2015-04-29 22:00 GMT+10:00 Yu Jing <yu.jing at student.unsw.edu.au>:
> created on Matlab, and it seems to be impossible to input the coordinates of
> thousands of points by hand, is it possible to import geometry from matlab
> output?

Hello.  I'm not sure whether there's an automatic importer but what I
have done in the past in similar cases is generate .geo scripts for
Gmsh in MATLAB.  (Actually I used Octave, but that's effectively
equivalent for the present purpose.)  I attach a simple example:

u = 2 * pi * sort (rand (1, 2^7));
xy = diag([1; (1 + sqrt(5) / 2)]) * [cos(u); sin(u)];
for p = 1:columns(xy)
  printf("Point(%d) = {%g, %g, 0};\n", p, xy(:, p))
  if p > 1
    printf("Line(%d) = {%d, %d};\n", p - 1, p - 1, p)
  end%if
end%for
printf("Line(%d) = {%d, 1};\n", p, p)

Call this with "octave -f polygon.m > polygon.geo", then "gmsh polygon.geo".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polygon.m
Type: text/x-objcsrc
Size: 289 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20150430/2dd0a0dc/attachment.m>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polygon.geo
Type: application/octet-stream
Size: 7545 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20150430/2dd0a0dc/attachment.geo>