[Gmsh] Fwd: Re: about mesh refinement by scripting

Mikhail Titov mlt at gmx.us
Wed May 12 21:05:39 CEST 2010


Giuseppe:

Take a look at Gmsh source code namely `utils/solvers/c++/GmshSocket.h` .
You should use not `system` (except for initial Gmsh launch if you want),
but sockets! Aforementioned header file along with c++ examples can help you
find out how to feed string commands for Gmsh to parse.

Mikhail

> -----Original Message-----
> From: gmsh-bounces at ace20.montefiore.ulg.ac.be [mailto:gmsh-
> bounces at ace20.montefiore.ulg.ac.be] On Behalf Of David Colignon
> Sent: Wednesday, May 12, 2010 10:59 AM
> To: gmsh at geuz.org
> Subject: [Gmsh] Fwd: Re: about mesh refinement by scripting
> 
> 
> -------- Original Message --------
> Subject: 	Re: [Gmsh] about mesh refinement by scripting
> Date: 	Wed, 12 May 2010 17:46:54 +0200
> From: 	Giuseppe Zagari <gzagari at unical.it>
> To: 	David Colignon <David.Colignon at ulg.ac.be>
> 
> 
> Hi David,
> thank you for the reply.
> 
> Something like this:
> 
> i#include <stdlib.h>
> #include <stdio.h>
> #include <sys/types.h>
> #include <signal.h>
> #include "MySolver.h"
> 
>    int main(int argc, char* argv[])
> {
>      int i, pid;
> 
>     system("gmsh -pid -listen test.geo > /tmp/gmsh.pid &");
>     //system("gmsh -pid -listen -2 test.geo > /tmp/gmsh.pid &");
>     for(i = 0; i < 5; i++)
>     {
>           system("  ??? "); // put here the command for refine
>           MySolver ms("test");
>           ms.analyze();
>     }
> 
>     kill(pid, 9);
> }
> 
> I hope I understod right.
> 
> Best Regards,
> GZ
> 
> 
> 2010/5/12 David Colignon <David.Colignon at ulg.ac.be
> <mailto:David.Colignon at ulg.ac.be>>
> 
> 
>      On 12/05/10 09:56, Giuseppe Zagari wrote:
> 
>          Hi,
> 
>          I am using gmsh gui for checking
>          convergence of my finite elements following this procedure:
>          open gmsh, open filename, go to mesh module, clicking 2D and
> refine
>          many times as I want and run the analysis.
> 
> 
> 
>      Hi Giuseppe,
> 
>      I suppose you mean that after refining, you save the mesh, perform
>      your FE calculations, go back to the Gmsh GUI, click on refine,
>      save, etc. ?
> 
> 
> 
>          But now I would like to use it in a script like this:
> 
>          gmsh -2 filename.geo
>          analyze filename // it use both .geo and .msh files
>          gmsh -refine filename.msh
>          analyze filename.msh
>          gmsh -refine filename.msh
>          analyze filename.msh
>          ....
> 
>          but, used in this way, gmsh change the node numbering.
> 
> 
> 
>      yes, if you save the mesh, quit Gmsh, relaunch Gmsh,reload the
> mesh,
>      refine, save, quit,  etc. like in your script above, the node
>      numbering will probably change.
> 
>      One solution could be to launch Gmsh in "server" mode (launch Gmsh
>      on the command line with "gmsh -listen") and interact with it
>      through "sockets", like explained here (point 3):
> 
>      http://www.geuz.org/gmsh/doc/texinfo/gmsh.html#Solver-module-
> questions
> 
>      or launch your FE code from within Gmsh :
> 
>      http://www.geuz.org/gmsh/doc/texinfo/gmsh.html#Solver
> 
>      http://www.geuz.org/gmsh/doc/texinfo/gmsh.html#Solver-module
> 
>      Regards,
> 
>      Dave
> 
>      --
>      David Colignon, Ph.D.
>      Collaborateur Logistique du F.R.S.-FNRS
>      CÉCI - Consortium des Équipements de Calcul Intensif
>      ACE - Applied & Computational Electromagnetics
>      Sart-Tilman B28
>      Université de Liège
>      4000 Liège - BELGIQUE
>      Tél: +32 (0)4 366 37 32
>      Fax: +32 (0)4 366 29 10
>      WWW: http://hpc.montefiore.ulg.ac.be/
>      Agenda:
> 
> http://www.google.com/calendar/embed?src=david.colignon%40gmail.com
> 
> 
> 
> 
>          Please suggest me in wich way I can obtaine the same
>          behavoiur of the gmsh-gui.
> 
> 
>          Best Regards and Many Thanks for gmsh
> 
>          Giuseppe
> 
> 
>          --
>          Ing. Giuseppe Zagari, Ph. D.
>          Dip. Modellistica per l'Ing. - UNICAL
>          Via P. Bucci, Cubo 39/b 87036
>          Arcavacata di Rende CS ITALY
> 
> 
> 
> 
> _______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh