[cig-commits] r19694 - seismo/2D/SPECFEM2D/trunk/UTILS/Gmsh

dkomati1 at geodynamics.org dkomati1 at geodynamics.org
Tue Feb 28 13:33:03 PST 2012


Author: dkomati1
Date: 2012-02-28 13:33:03 -0800 (Tue, 28 Feb 2012)
New Revision: 19694

Modified:
   seismo/2D/SPECFEM2D/trunk/UTILS/Gmsh/LibGmsh2Specfem.py
Log:
Paul Cristini updated the Python script to convert from Gmsh format to SPECFEM2D


Modified: seismo/2D/SPECFEM2D/trunk/UTILS/Gmsh/LibGmsh2Specfem.py
===================================================================
--- seismo/2D/SPECFEM2D/trunk/UTILS/Gmsh/LibGmsh2Specfem.py	2012-02-28 18:42:18 UTC (rev 19693)
+++ seismo/2D/SPECFEM2D/trunk/UTILS/Gmsh/LibGmsh2Specfem.py	2012-02-28 21:33:03 UTC (rev 19694)
@@ -3,8 +3,17 @@
 #
 #  Python code to link gmsh with specfem
 #
+#@author: Cristini Paul, 
+#  Laboratoire de Mecanique et d'Acoustique, CNRS, Marseille, France
+#
+# Feb, 28, 2012
+#
 import sys, string, time
-from numpy import *
+from os.path import splitext, isfile
+try:
+    from numpy import *
+except ImportError:
+    print "numpy is not installed"
 #
 def SauvFicSpecfem(Ng, Ct, Var, Fv):
     # Sauvegarde au format ascii
@@ -20,7 +29,14 @@
 #
 def OuvreGmsh(Dir,Nom,Bords):
     # Lecture de fichiers .msh genere avec Gmsh
-    fic=Nom+'.msh'
+    if splitext(Nom)[-1]=='.msh':
+       fic=Nom
+    elif splitext(Nom)[-1]=='':
+       fic=Nom+'.msh'
+    else:
+        print 'File extension is not correct'
+        print 'script aborted'
+        sys.exit()
     #
     # Open the file and get the lines
     # 



More information about the CIG-COMMITS mailing list