From: michael Date: Fri, 5 Nov 2021 21:58:50 +0000 (+0100) Subject: Updated python script X-Git-Tag: V9_8_0~63 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=12cab262f936ec6a04307203678f68fe3e590f21;p=tools%2Fsolverlab.git Updated python script --- diff --git a/CDMATH/tests/ressources/scripts/convert_gmsh_to_med.py b/CDMATH/tests/ressources/scripts/convert_gmsh_to_med.py index 82aa133..ef8ec13 100755 --- a/CDMATH/tests/ressources/scripts/convert_gmsh_to_med.py +++ b/CDMATH/tests/ressources/scripts/convert_gmsh_to_med.py @@ -3,19 +3,19 @@ import sys -import MEDCoupling as MC +import medcoupling as MC import MEDLoader as ML #filename = "locrafgrid_1_new.msh" #filename = "checkerboard_2x2x2_new.msh" if len(sys.argv) != 2: - print "USAGE: convert_gmsh_to_med.py file.msh" + print( "USAGE: convert_gmsh_to_med.py file.msh") sys.exit(-1) filename = sys.argv[1] -print "Converting ", filename +print( "Converting ", filename) # type de maille en fonction du nombre de noeuds. # cf INTERP_KERNEL/CellModel.cxx @@ -168,4 +168,4 @@ meshMEDFile.addGroup(-1, arr_front) med_filename = filename.replace(".msh", ".med") meshMEDFile.write(med_filename,2) # 2 stands for write from scratch -print "...done" +print( "...done") diff --git a/CDMATH/tests/ressources/scripts/convert_typ_to_med.py b/CDMATH/tests/ressources/scripts/convert_typ_to_med.py index c84cbed..90482a8 100644 --- a/CDMATH/tests/ressources/scripts/convert_typ_to_med.py +++ b/CDMATH/tests/ressources/scripts/convert_typ_to_med.py @@ -1,5 +1,5 @@ import MEDLoader as ml -import os +import os, sys def read_typ2(fichier, nom_med): with open(fichier, "r") as fic: lines = fic.readlines() @@ -112,18 +112,37 @@ def read_typ3(fichier, nom_med): mm.write("{}/mesh.med".format(nom_med), 2) -# maillages 3D -meshes = (("meshAA-random", "RandMesh", ("4", "8", "16", "32")), - #("meshBB_well", "WellMesh_", ("1", "2", "3", "4", "5", "6", "7")), - #("meshB_tetra", "tet.", ("00", "0", "1", "2", "3", "4", "5", "6")), - ("meshC_voro", "vmesh_", ("1", "2", "3", "4", "5")), - ("meshD_kershaw", "dkershaw", ("08", "16", "32", "64")), - ("meshF_dbls", "dbls_", ("10", "20", "30", "40"))) - # ("meshH_locrafgrid", "locrafgrid_", ("1", "2", "3", "4", "5")), - # ("meshI_checkerboard", "checkerboard_", ("2x2x2", "4x4x4", "8x8x8", "16x16x16", "32x32x32"))) -for t, m, d in meshes: - for n in d: - print t, n - folder = "{}/jdd_{}".format(t, n) - os.system("mkdir -p {}".format(folder)) - read_typ3("Meshes_3D/{}/{}{}.msh".format(t, m, n), folder) +# maillages 3D du benchmark FVCA6 +# meshes = (("meshAA-random", "RandMesh", ("4", "8", "16", "32")), + # #("meshBB_well", "WellMesh_", ("1", "2", "3", "4", "5", "6", "7")), + # #("meshB_tetra", "tet.", ("00", "0", "1", "2", "3", "4", "5", "6")), + # ("meshC_voro", "vmesh_", ("1", "2", "3", "4", "5")), + # ("meshD_kershaw", "dkershaw", ("08", "16", "32", "64")), + # ("meshF_dbls", "dbls_", ("10", "20", "30", "40"))) + # # ("meshH_locrafgrid", "locrafgrid_", ("1", "2", "3", "4", "5")), + # # ("meshI_checkerboard", "checkerboard_", ("2x2x2", "4x4x4", "8x8x8", "16x16x16", "32x32x32"))) +# for t, m, d in meshes: + # for n in d: + # print( t, n) + # folder = "{}/jdd_{}".format(t, n) + # os.system("mkdir -p {}".format(folder)) + # read_typ3("Meshes_3D/{}/{}{}.msh".format(t, m, n), folder) + +if __name__ == "__main__": + + if len(sys.argv) != 2: + print("USAGE: convert_gmsh_to_med.py file.typ") + sys.exit(-1) + + filename = sys.argv[1] + print("Converting ", filename) + + l=len(filename) + name=filename[:l-5] + extension=filename[l-5:] + if extension==".typ2": + read_typ2(filename, name+".med") + elif extension==".typ3": + read_typ3(filename, name+".med") + else : + raise ValueError("File "+filename+" has unknown file extension "+extension)