From: Gerald Nicolas Date: Fri, 21 Mar 2014 13:07:41 +0000 (+0100) Subject: Ajout de 5 tests qui sont les clones des 5 tutorials X-Git-Tag: V7_4_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bb4659c87071220a19ba3564eb8eece0b06592b1;p=modules%2Fhomard.git Ajout de 5 tests qui sont les clones des 5 tutorials --- diff --git a/doc/en/tutorials.rst b/doc/en/tutorials.rst index 9d5f7fa8..e057799b 100644 --- a/doc/en/tutorials.rst +++ b/doc/en/tutorials.rst @@ -37,7 +37,7 @@ One will make here three successive uniform refinements of the mesh contained in .. literalinclude:: ../files/tutorial_1.py - :lines: 62-94 + :lines: 52-85 .. note:: Download the files @@ -55,7 +55,7 @@ Refinement by zones One proceeds here to refinement according to zones. To pass from the initial mesh to the mesh 'M_1', one uses a box framing the z=1 plane and a sphere centered on the origin with radius 1.05. Then to pass from the mesh 'M_1' to the mesh 'M_2', one replaces the sphere by a box framing the cube on side 0.5, pointing on the origin and the meshes in the very first zone are unrefined. .. literalinclude:: ../files/tutorial_2.py - :lines: 62-104 + :lines: 52-95 .. note:: Download the files @@ -73,7 +73,7 @@ One proceeds here to refinement according to a field. The hypotheses are used to To adapt the H_1 mesh resulting from the Iter_1 iteration, two alternatives are applied. In the first, Iter_2, the field is a scalar field of indicators of error and one cuts out the 1.5% of elements where the error is largest. In the second alternative, Iter_2_bis, one is based on a vector field and one examines the jump of this vector between an element and its neighbors: one will cut out where the infinite standard of this jump is higher than the absolute threshold of 0.0001. .. literalinclude:: ../files/tutorial_3.py - :lines: 62-133 + :lines: 52-124 .. note:: Download the files @@ -93,7 +93,7 @@ One tests the follow-up of the curved borders here: analytical borders to descri Scheme YACS carrying out this adaptation is downloadable. .. literalinclude:: ../files/tutorial_4.py - :lines: 62-120 + :lines: 52-111 .. note:: Download the files @@ -113,7 +113,7 @@ The instructions to adapt a 2D mesh are exactly identical to those necessary to In the case presented here, one for the first time refines all the elements contained in a bored disk, then in one second iteration, all the elements contained in a rectangle. One will note the use of the follow-up of the circular borders of the field. .. literalinclude:: ../files/tutorial_5.py - :lines: 62-104 + :lines: 52-95 .. note:: Download the files diff --git a/doc/files/tutorial_1.py b/doc/files/tutorial_1.py index ae8e5548..bfb44fae 100755 --- a/doc/files/tutorial_1.py +++ b/doc/files/tutorial_1.py @@ -24,30 +24,21 @@ Exemple de couplage HOMARD-Salome Copyright EDF-R&D 1996, 2010, 2014 """ -__revision__ = "V1.8" +__revision__ = "V1.9" # import os import sys # # ================================== -# Repertoire a personnaliser -# Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med, maill.03.med -if os.environ.has_key("LOGNAME") : - user = os.environ ["LOGNAME"] -else : - user = "anonymous" -dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -dircase = os.path.join( dircase, "tutorial_1" ) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -# ================================== -# Ce repertoire contient les fichiers de donnees : tutorial_1.00.med pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du tutorial data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) sys.path.append(data_dir) from tutorial_util import gzip_gunzip +from tutorial_util import creation_dircase +# ================================== +dircase = creation_dircase(1) gzip_gunzip(data_dir, 1, -1) # ================================== # @@ -77,21 +68,21 @@ Iter_1_1 = Case_1.NextIteration('Iter_1_1') Iter_1_1.SetMeshName('MESH') Iter_1_1.SetMeshFile(dircase+'/maill.01.med') Iter_1_1.AssociateHypo('Hypo_1') -codret = Iter_1_1.Compute(1, 2) +error = Iter_1_1.Compute(1, 2) # Iteration "Iter_1_2" Iter_1_2 = Iter_1_1.NextIteration('Iter_1_2') Iter_1_2.SetMeshName('MESH') Iter_1_2.SetMeshFile(dircase+'/maill.02.med') Iter_1_2.AssociateHypo('Hypo_1') -codret = Iter_1_2.Compute(1, 2) +error = Iter_1_2.Compute(1, 2) # Iteration "Iter_1_3" Iter_1_3 = Iter_1_2.NextIteration('Iter_1_3') Iter_1_3.SetMeshName('MESH') Iter_1_3.SetMeshFile(dircase+'/maill.03.med') Iter_1_3.AssociateHypo('Hypo_1') -codret = Iter_1_3.Compute(1, 2) +error = Iter_1_3.Compute(1, 2) # ================================== gzip_gunzip(data_dir, 1, 1) diff --git a/doc/files/tutorial_2.py b/doc/files/tutorial_2.py index 01f36f6d..51b9323b 100755 --- a/doc/files/tutorial_2.py +++ b/doc/files/tutorial_2.py @@ -24,30 +24,21 @@ Exemple de couplage HOMARD-Salome Copyright EDF-R&D 1996, 2010, 2014 """ -__revision__ = "V1.9" +__revision__ = "V1.10" # import os import sys # # ================================== -# Repertoire a personnaliser -# Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med -if os.environ.has_key("LOGNAME") : - user = os.environ ["LOGNAME"] -else : - user = "anonymous" -dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -dircase = os.path.join( dircase, "tutorial_2" ) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -# ================================== -# Ce repertoire contient les fichiers de donnees : tutorial_2.00.med pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du tutorial data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) sys.path.append(data_dir) from tutorial_util import gzip_gunzip +from tutorial_util import creation_dircase +# ================================== +dircase = creation_dircase(2) gzip_gunzip(data_dir, 2, -1) # ================================== # @@ -93,7 +84,7 @@ Iter_2_1 = Case_2.NextIteration('Iter_2_1') Iter_2_1.SetMeshName('M_1') Iter_2_1.SetMeshFile(dircase+'/maill.01.med') Iter_2_1.AssociateHypo('Hypo_2') -codret = Iter_2_1.Compute(1, 2) +error = Iter_2_1.Compute(1, 2) # # Iteration "Iter_2_2" # ==================== @@ -101,7 +92,7 @@ Iter_2_2 = Iter_2_1.NextIteration('Iter_2_2') Iter_2_2.SetMeshName('M_2') Iter_2_2.SetMeshFile(dircase+'/maill.02.med') Iter_2_2.AssociateHypo('Hypo_2_bis') -codret = Iter_2_2.Compute(1, 2) +error = Iter_2_2.Compute(1, 2) # ================================== gzip_gunzip(data_dir, 2, 1) diff --git a/doc/files/tutorial_3.py b/doc/files/tutorial_3.py index ad3afb33..728c7919 100755 --- a/doc/files/tutorial_3.py +++ b/doc/files/tutorial_3.py @@ -24,30 +24,21 @@ Exemple de couplage HOMARD-Salome Copyright EDF-R&D 1996, 2010, 2014 """ -__revision__ = "V1.8" +__revision__ = "V1.9" # import os import sys # # ================================== -# Repertoire a personnaliser -# Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med -if os.environ.has_key("LOGNAME") : - user = os.environ ["LOGNAME"] -else : - user = "anonymous" -dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -dircase = os.path.join( dircase, "tutorial_3" ) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -# ================================== -# Ce repertoire contient les fichiers de donnees : tutorial_3.00.med, tutorial_3.01.med pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du tutorial data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) sys.path.append(data_dir) from tutorial_util import gzip_gunzip +from tutorial_util import creation_dircase +# ================================== +dircase = creation_dircase(3) gzip_gunzip(data_dir, 3, -1) # ================================== # @@ -110,7 +101,7 @@ Iter_3_1.SetMeshFile(dircase+'/maill.01.med') Iter_3_1.SetFieldFile(data_dir+'/tutorial_3.00.med') Iter_3_1.SetTimeStepRank( 1, 1) Iter_3_1.AssociateHypo('Hypo_0vers1') -codret = Iter_3_1.Compute(1, 2) +error = Iter_3_1.Compute(1, 2) # # Iteration "Iter_3_2" # ==================== @@ -120,7 +111,7 @@ Iter_3_2.SetMeshFile(dircase+'/maill.02.med') Iter_3_2.SetFieldFile(data_dir+'/tutorial_3.01.med') Iter_3_2.SetTimeStepRank(1, 1) Iter_3_2.AssociateHypo('Hypo_1vers2') -codret = Iter_3_2.Compute(1, 2) +error = Iter_3_2.Compute(1, 2) # # Iteration "Iter_3_2_bis" # ======================== @@ -130,7 +121,7 @@ Iter_3_2_bis.SetMeshFile(dircase+'/maill.02.bis.med') Iter_3_2_bis.SetFieldFile(data_dir+'/tutorial_3.01.med') Iter_3_2_bis.SetTimeStepRank(1, 1) Iter_3_2_bis.AssociateHypo('Hypo_1vers2_bis') -codret = Iter_3_2_bis.Compute(1, 2) +error = Iter_3_2_bis.Compute(1, 2) # ================================== gzip_gunzip(data_dir, 3, 1) diff --git a/doc/files/tutorial_4.py b/doc/files/tutorial_4.py index 27405636..8c7a0b20 100755 --- a/doc/files/tutorial_4.py +++ b/doc/files/tutorial_4.py @@ -24,30 +24,21 @@ Exemple de couplage HOMARD-Salome Copyright EDF-R&D 1996, 2011, 2014 """ -__revision__ = "V2.4" +__revision__ = "V2.5" # import os import sys # # ================================== -# Repertoire a personnaliser -# Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med, maill.03.med -if os.environ.has_key("LOGNAME") : - user = os.environ ["LOGNAME"] -else : - user = "anonymous" -dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -dircase = os.path.join( dircase, "tutorial_4" ) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -# ================================== -# Ce repertoire contient les fichiers de donnees : tutorial_4.00.med, tutorial_4.fr.med pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du tutorial data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) sys.path.append(data_dir) from tutorial_util import gzip_gunzip +from tutorial_util import creation_dircase +# ================================== +dircase = creation_dircase(4) gzip_gunzip(data_dir, 4, -1) # ================================== # @@ -105,19 +96,19 @@ Iter_4_1 = Case_4.NextIteration('Iter_4_1') Iter_4_1.SetMeshName('PIQUAGE_1') Iter_4_1.SetMeshFile(dircase+'/maill.01.med') Iter_4_1.AssociateHypo('Hypo_4') -codret = Iter_4_1.Compute(1, 2) +error = Iter_4_1.Compute(1, 2) # Iteration Iter_4_2 : raffinement selon les faces externes Iter_4_2 = Iter_4_1.NextIteration('Iter_4_2') Iter_4_2.SetMeshName('PIQUAGE_2') Iter_4_2.SetMeshFile(dircase+'/maill.02.med') Iter_4_2.AssociateHypo('Hypo_4_bis') -codret = Iter_4_2.Compute(1, 2) +error = Iter_4_2.Compute(1, 2) # Iteration Iter_4_3 : second raffinement selon les faces externes Iter_4_3 = Iter_4_2.NextIteration('Iter_4_3') Iter_4_3.SetMeshName('PIQUAGE_3') Iter_4_3.SetMeshFile(dircase+'/maill.03.med') Iter_4_3.AssociateHypo('Hypo_4_bis') -codret = Iter_4_3.Compute(1, 2) +error = Iter_4_3.Compute(1, 2) # ================================== gzip_gunzip(data_dir, 4, 1) diff --git a/doc/files/tutorial_5.py b/doc/files/tutorial_5.py index e82b99cd..b049f561 100755 --- a/doc/files/tutorial_5.py +++ b/doc/files/tutorial_5.py @@ -24,30 +24,21 @@ Exemple de couplage HOMARD-Salome Copyright EDF-R&D 1996, 2010, 2014 """ -__revision__ = "V1.7" +__revision__ = "V1.8" # import os import sys # # ================================== -# Repertoire a personnaliser -# Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med -if os.environ.has_key("LOGNAME") : - user = os.environ ["LOGNAME"] -else : - user = "anonymous" -dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -dircase = os.path.join( dircase, "tutorial_5" ) -if not os.path.isdir(dircase) : - os.mkdir (dircase) -# ================================== -# Ce repertoire contient les fichiers de donnees : tutorial_5.00.med, tutorial_5.fr.med pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du tutorial data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) sys.path.append(data_dir) from tutorial_util import gzip_gunzip +from tutorial_util import creation_dircase +# ================================== +dircase = creation_dircase(5) gzip_gunzip(data_dir, 5, -1) # ================================== # @@ -93,7 +84,7 @@ Iter_5_1 = Case_5.NextIteration('Iter_5_1') Iter_5_1.SetMeshName('COEUR_2D_01') Iter_5_1.SetMeshFile(dircase+'/maill.01.med') Iter_5_1.AssociateHypo('Hypo_5') -codret = Iter_5_1.Compute(1, 2) +error = Iter_5_1.Compute(1, 2) # # Iteration "Iter_5_2" # ==================== @@ -101,7 +92,7 @@ Iter_5_2 = Iter_5_1.NextIteration('Iter_5_2') Iter_5_2.SetMeshName('COEUR_2D_02') Iter_5_2.SetMeshFile(dircase+'/maill.02.med') Iter_5_2.AssociateHypo('Hypo_5_bis') -codret = Iter_5_2.Compute(1, 2) +error = Iter_5_2.Compute(1, 2) # ================================== gzip_gunzip(data_dir, 5, 1) diff --git a/doc/files/tutorial_util.py b/doc/files/tutorial_util.py index 19f3b53d..b409c7a3 100755 --- a/doc/files/tutorial_util.py +++ b/doc/files/tutorial_util.py @@ -21,10 +21,18 @@ Python script for HOMARD Copyright EDF-R&D 2014 """ -__revision__ = "V1.0" +__revision__ = "V1.1" import os import sys + +pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des tests +Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") +Rep_Test = os.path.normpath(Rep_Test) +sys.path.append(Rep_Test) +from test_util import remove_dir + #======================================================================== #======================================================================== def gzip_gunzip(data_dir, num_tuto, option) : @@ -95,3 +103,27 @@ Copyright EDF-R&D 2014 # #======================================================================== #======================================================================== +def creation_dircase(num_tuto) : + """ +Creation of a directory for the results of tutorial_x +num_tuto: number of the tutorial +Copyright EDF-R&D 2014 + """ +# + if os.environ.has_key("LOGNAME") : + user = os.environ ["LOGNAME"] + else : + user = "anonymous" + dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user) + if not os.path.isdir(dircase) : + os.mkdir (dircase) + dirtuto_basis = "tutorial_%d" % num_tuto + dircase = os.path.join( dircase, dirtuto_basis ) + if os.path.isdir(dircase) : + remove_dir(dircase) + os.mkdir (dircase) +# + return dircase +#======================================================================== +#======================================================================== +# diff --git a/doc/fr/tutorials.rst b/doc/fr/tutorials.rst index 204a67f0..92ce134d 100644 --- a/doc/fr/tutorials.rst +++ b/doc/fr/tutorials.rst @@ -36,7 +36,7 @@ On fera ici trois raffinements uniformes successifs du maillage contenu dans le * le maillage produit porte toujours le même nom. Cela ne pose pas de problème car il est stocké dans des fichiers différents. .. literalinclude:: ../files/tutorial_1.py - :lines: 62-94 + :lines: 52-85 .. note:: Téléchargement des fichiers @@ -53,7 +53,7 @@ Raffinement par des zones On procède ici au raffinement selon des zones. Pour passer du maillage initial au maillage 'M_1', on utilise une boîte encadrant le plan z=1 et une sphère centrée sur l'origine de rayon 1.05. Puis pour passer du maillage 'M_1' au maillage 'M_2', on remplace la sphère par une boîte encadrant le cube de côté 0.5, pointant sur l'origine et on déraffine les mailles contenues dans la toute première zone. .. literalinclude:: ../files/tutorial_2.py - :lines: 62-104 + :lines: 52-95 .. note:: Téléchargement des fichiers @@ -71,7 +71,7 @@ On proc Pour adapter le maillage H_1 issu de l'itération Iter_1, deux variantes sont appliquées. Dans la première, Iter_2, le champ est un champ scalaire d'indicateurs d'erreur et on découpe les 1.5% de mailles où l'erreur est la plus grande. Dans la seconde variante, Iter_2_bis, on se base sur un champ vectoriel et on examine le saut de ce vecteur entre une maille et ses voisines : on découpera là où la norme infinie de ce saut est supérieure au seuil absolu de 0.0001. .. literalinclude:: ../files/tutorial_3.py - :lines: 62-133 + :lines: 52-124 .. note:: Téléchargement des fichiers @@ -91,7 +91,7 @@ On teste ici le suivi des fronti Le schéma YACS réalisant cette adaptation est téléchargeable. .. literalinclude:: ../files/tutorial_4.py - :lines: 62-120 + :lines: 52-111 .. note:: Téléchargement des fichiers @@ -111,7 +111,7 @@ Les instructions pour adapter un maillage 2D sont exactement identiques Dans le cas présenté ici, on raffine une première fois toutes les mailles contenues dans un disque percé, puis dans une seconde itération, toutes les mailles contenues dans un rectangle. On notera l'utilisation du suivi des frontières circulaires du domaine. .. literalinclude:: ../files/tutorial_5.py - :lines: 62-104 + :lines: 52-95 .. note:: Téléchargement des fichiers diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9f423bf3..481fba41 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -38,6 +38,16 @@ SET(HOMARD_TEST_FILES test_3.00.med test_3.fr.med test_3.apad.02.bilan + test_11.py + test_11.apad.03.bilan + test_12.py + test_12.apad.02.bilan + test_13.py + test_13.apad.02.bilan + test_14.py + test_14.apad.03.bilan + test_15.py + test_15.apad.02.bilan ) INSTALL(FILES ${HOMARD_TEST_FILES} DESTINATION ${SALOME_HOMARD_INSTALL_RES_DATA}) diff --git a/tests/test_1.py b/tests/test_1.py index 5b160bc6..f9027d90 100755 --- a/tests/test_1.py +++ b/tests/test_1.py @@ -19,10 +19,10 @@ # """ Python script for HOMARD -Copyright EDF-R&D 2010, 2013 +Copyright EDF-R&D 2010, 2014 Test test_1 """ -__revision__ = "V2.1" +__revision__ = "V2.2" #======================================================================== Test_Name = "test_1" @@ -34,14 +34,18 @@ import sys import HOMARD import salome # +# ================================== pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du test Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") Rep_Test = os.path.normpath(Rep_Test) -Rep_Test_Resu = tempfile.mktemp() -os.mkdir(Rep_Test_Resu) - sys.path.append(Rep_Test) -from test_util import remove_dir +from test_util import test_results +# Repertoire des resultats +dircase = tempfile.mktemp() +os.mkdir(dircase) +# ================================== + salome.salome_init() import iparameters @@ -53,7 +57,6 @@ ipar.append("AP_MODULES_LIST", "Homard") def homard_exec(theStudy): """ Python script for HOMARD -Copyright EDF-R&D 2010, 2013 """ error = 0 # @@ -106,7 +109,7 @@ Copyright EDF-R&D 2010, 2013 print "-------- Creation of the case", CaseName MeshFile = os.path.join(Rep_Test, Test_Name + '.00.med') Case_test_1 = homard.CreateCase(CaseName, 'MAILL', MeshFile) - Case_test_1.SetDirName(Rep_Test_Resu) + Case_test_1.SetDirName(dircase) Case_test_1.SetConfType(1) # # Creation of the iterations @@ -118,7 +121,7 @@ Copyright EDF-R&D 2010, 2013 Iter_test_1_1.AssociateHypo(HypoName_1) print ". Hypothese :", HypoName_1 Iter_test_1_1.SetMeshName('M1') - Iter_test_1_1.SetMeshFile(os.path.join(Rep_Test_Resu, 'maill.01.med')) + Iter_test_1_1.SetMeshFile(os.path.join(dircase, 'maill.01.med')) Iter_test_1_1.SetFieldFile(os.path.join(Rep_Test, Test_Name + '.00.med')) Iter_test_1_1.SetTimeStepRank(1, 1) Iter_test_1_1.SetFieldInterpTimeStep('RESU____DEPL____________________', 1) @@ -136,7 +139,7 @@ Copyright EDF-R&D 2010, 2013 Iter_test_1_2.AssociateHypo(HypoName_1) print ". Hypothese :", HypoName_1 Iter_test_1_2.SetMeshName('M2') - Iter_test_1_2.SetMeshFile(os.path.join(Rep_Test_Resu, 'maill.02.med')) + Iter_test_1_2.SetMeshFile(os.path.join(dircase, 'maill.02.med')) Iter_test_1_2.SetFieldFile(os.path.join(Rep_Test, Test_Name + '.01.med')) Iter_test_1_2.SetTimeStepRank(1, 1) Iter_test_1_2.SetFieldInterpTimeStep('RESU____DEPL____________________', 1) @@ -154,7 +157,7 @@ Copyright EDF-R&D 2010, 2013 Iter_test_1_3.AssociateHypo(HypoName_2) print ". Hypothese :", HypoName_2 Iter_test_1_3.SetMeshName('M3') - Iter_test_1_3.SetMeshFile(os.path.join(Rep_Test_Resu, 'maill.03.med')) + Iter_test_1_3.SetMeshFile(os.path.join(dircase, 'maill.03.med')) Iter_test_1_2.SetFieldFile(os.path.join(Rep_Test, Test_Name + '.02.med')) print ". Instants d'interpolation :", Iter_test_1_3.GetFieldInterpsTimeStepRank() error = Iter_test_1_3.Compute(1, 1) @@ -166,7 +169,7 @@ Copyright EDF-R&D 2010, 2013 # =========================== ScriptFile = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script.py") ScriptFile = os.path.normpath(ScriptFile) - DirName = Rep_Test_Resu + DirName = dircase YACS_test_1 = Case_test_1.CreateYACSSchema("YACS_test_1", ScriptFile, DirName, MeshFile) error = YACS_test_1.Write() if error : @@ -182,7 +185,6 @@ Copyright EDF-R&D 2010, 2013 homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') assert homard is not None, "Impossible to load homard engine" homard.SetLanguageShort("fr") - # # Exec of HOMARD-SALOME # @@ -193,45 +195,10 @@ try : except Exception, e: raise Exception('Pb in homard_exec: '+e.message) # -# Test of the result -# -test_file_suff = "apad.%02d.bilan" % n_iter_test_file -rep_test_file = "I%02d" % n_iter_test_file -# -test_file = os.path.join(Rep_Test, Test_Name + "." + test_file_suff) -mess_error_ref = "\nReference file: " + test_file -try : - file = open (test_file, "r") - mess_ref = file.readlines() - file.close() -except : - mess_error = mess_error_ref + "\nThis file does not exist.\n" - raise Exception(mess_error) -# -test_file = os.path.join(Rep_Test_Resu, rep_test_file, test_file_suff) -if os.path.isfile (test_file) : - file = open (test_file, "r") - mess = file.readlines() - file.close() -else : - mess_error = "\nResult file: " + test_file - mess_error += "\nThis file does not exist.\n" - raise Exception(mess_error) - -nblign = len(mess_ref) -if ( len(mess) != nblign ): - mess_error = mess_error_ref + "\nResult file: " + test_file - mess_error += "\nThe number of lines of the files are not the same.\n" - raise Exception(mess_error) - -for num in range(nblign) : - if (( "creation" not in mess_ref[num] ) and ( mess_ref[num] != mess[num])) : - message_erreur = "\nRefe : " + mess_ref[num] - message_erreur += "Test : " + mess[num][:-1] - message_erreur += "\nThe test is different from the reference." - raise Exception(message_erreur) +# Test of the results # -remove_dir(Rep_Test_Resu) +n_rep_test_file = n_iter_test_file +test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) # if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/tests/test_11.apad.03.bilan b/tests/test_11.apad.03.bilan new file mode 100644 index 00000000..c9c88613 --- /dev/null +++ b/tests/test_11.apad.03.bilan @@ -0,0 +1,72 @@ + + +ANALYSE DU MAILLAGE +=================== + + Maillage apres adaptation + MAILL + Date de creation : vendredi 21 mars 2014 a 13 h 35 mn 56 s + Dimension : 3 + Degre : 2 + C'est un maillage obtenu apres 3 adaptations. + Le niveau minimum actif est : 3 + Le niveau maximum atteint est : 3 + + Direction | Unite | Minimum | Maximum + --------------------------------------------------------------- + X | INCONNUE | 0.0000 | 1.0000 + Y | INCONNUE | 0.0000 | 1.0000 + Z | INCONNUE | 0.0000 | 1.0000 + + + NOMBRE D'ENTITES DU CALCUL + ========================== + + + ************************************************************ + * Noeuds * + ************************************************************ + * Nombre total * 4913 * + * . dont sommets d'aretes * 729 * + * . dont milieux d'aretes * 4184 * + ************************************************************ + + ************************************************************ + * Mailles-Points * + ************************************************************ + * Nombre total * 2 * + ************************************************************ + + ************************************************************ + * Segments * + ************************************************************ + * Nombre total * 8 * + * . dont aretes isolees * 0 * + * . dont aretes de bord de regions 2D * 0 * + * . dont aretes internes aux faces/volumes * 8 * + ************************************************************ + + ************************************************************ + * Triangles * + ************************************************************ + * Nombre total * 768 * + * . dont triangles de regions 2D * 0 * + * . dont triangles de bord * 768 * + * . dont triangles internes aux volumes * 0 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 0 * + * . du niveau 2 * 0 * + * . du niveau 3 * 768 * + ************************************************************ + + ************************************************************ + * Tetraedres * + ************************************************************ + * Nombre total * 3072 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 0 * + * . du niveau 2 * 0 * + * . du niveau 3 * 3072 * + ************************************************************ diff --git a/tests/test_11.py b/tests/test_11.py new file mode 100755 index 00000000..eab14b50 --- /dev/null +++ b/tests/test_11.py @@ -0,0 +1,133 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2011-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +Python script for HOMARD +Copyright EDF-R&D 2010, 2014 +Test test_11 associe au tutorial 1 +""" +__revision__ = "V2.1" + +#======================================================================== +Test_Name = "test_11" +n_iter_test_file = 3 +#======================================================================== +import os +import tempfile +import sys +import HOMARD +import salome +# +# ================================== +pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du test +Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") +Rep_Test = os.path.normpath(Rep_Test) +sys.path.append(Rep_Test) +from test_util import test_results +# Repertoire des resultats +dircase = tempfile.mktemp() +os.mkdir(dircase) +# Repertoire des donnees du tutorial +data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) +sys.path.append(data_dir) +from tutorial_util import gzip_gunzip +# ================================== +gzip_gunzip(data_dir, 1, -1) +# ================================== + +salome.salome_init() +import iparameters +ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +ipar.append("AP_MODULES_LIST", "Homard") +# +#======================================================================== +#======================================================================== +def homard_exec(theStudy): + """ +Python script for HOMARD + """ + # + homard.SetCurrentStudy(theStudy) + # + # Hypotheses + # ========== + Hypo_1 = homard.CreateHypothesis('Hypo_1') + Hypo_1.SetUnifRefinUnRef(1) + # + # Cas + # === + Case_1 = homard.CreateCase('Case_1', 'MAILL', data_dir+'/tutorial_1.00.med') + Case_1.SetDirName(dircase) + Case_1.SetConfType(1) + # + # Iterations + # ========== + # Iteration "Iter_1_1" + Iter_1_1 = Case_1.NextIteration('Iter_1_1') + Iter_1_1.SetMeshName('MESH') + Iter_1_1.SetMeshFile(dircase+'/maill.01.med') + Iter_1_1.AssociateHypo('Hypo_1') + error = Iter_1_1.Compute(1, 2) + + # Iteration "Iter_1_2" + Iter_1_2 = Iter_1_1.NextIteration('Iter_1_2') + Iter_1_2.SetMeshName('MESH') + Iter_1_2.SetMeshFile(dircase+'/maill.02.med') + Iter_1_2.AssociateHypo('Hypo_1') + error = Iter_1_2.Compute(1, 2) + + # Iteration "Iter_1_3" + Iter_1_3 = Iter_1_2.NextIteration('Iter_1_3') + Iter_1_3.SetMeshName('MESH') + Iter_1_3.SetMeshFile(dircase+'/maill.03.med') + Iter_1_3.AssociateHypo('Hypo_1') + error = Iter_1_3.Compute(1, 2) + # + return error + +#======================================================================== + +homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') +assert homard is not None, "Impossible to load homard engine" +homard.SetLanguageShort("fr") +# +# Exec of HOMARD-SALOME +# +try : + error_main = homard_exec(salome.myStudy) + if error_main : + raise Exception('Pb in homard_exec at iteration %d' %error_main ) +except Exception, e: + raise Exception('Pb in homard_exec: '+e.message) +# +# Test of the results +# +n_rep_test_file = n_iter_test_file +test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) +# +# ================================== +gzip_gunzip(data_dir, 1, 1) +# ================================== +# +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + iparameters.getSession().restoreVisualState(1) + diff --git a/tests/test_12.apad.02.bilan b/tests/test_12.apad.02.bilan new file mode 100644 index 00000000..fd32dc5e --- /dev/null +++ b/tests/test_12.apad.02.bilan @@ -0,0 +1,70 @@ + + +ANALYSE DU MAILLAGE +=================== + + Maillage apres adaptation + MZERO + Date de creation : vendredi 21 mars 2014 a 11 h 33 mn 28 s + Dimension : 3 + Degre : 2 + C'est un maillage obtenu apres 2 adaptations. + Le niveau minimum actif est : 1 + Le niveau maximum atteint est : 2 + + Direction | Unite | Minimum | Maximum + --------------------------------------------------------------- + X | INCONNUE | 0.0000 | 1.0000 + Y | INCONNUE | 0.0000 | 1.0000 + Z | INCONNUE | 0.0000 | 1.0000 + + + NOMBRE D'ENTITES DU CALCUL + ========================== + + + ************************************************************ + * Noeuds * + ************************************************************ + * Nombre total * 231 * + * . dont sommets d'aretes * 43 * + * . dont milieux d'aretes * 188 * + ************************************************************ + + ************************************************************ + * Mailles-Points * + ************************************************************ + * Nombre total * 2 * + ************************************************************ + + ************************************************************ + * Segments * + ************************************************************ + * Nombre total * 3 * + * . dont aretes isolees * 0 * + * . dont aretes de bord de regions 2D * 0 * + * . dont aretes internes aux faces/volumes * 3 * + ************************************************************ + + ************************************************************ + * Triangles * + ************************************************************ + * Nombre total * 66 * + * . dont triangles de regions 2D * 0 * + * . dont triangles de bord * 66 * + * . dont triangles internes aux volumes * 0 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 30 * + * . du niveau 2 * 36 * + ************************************************************ + + ************************************************************ + * Tetraedres * + ************************************************************ + * Nombre total * 113 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 23 * + * . du niveau 2 * 90 * + ************************************************************ diff --git a/tests/test_12.py b/tests/test_12.py new file mode 100755 index 00000000..0164c33f --- /dev/null +++ b/tests/test_12.py @@ -0,0 +1,143 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2011-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +Python script for HOMARD +Copyright EDF-R&D 2010, 2014 +Test test_11 associe au tutorial 2 +""" +__revision__ = "V2.1" + +#======================================================================== +Test_Name = "test_12" +n_iter_test_file = 2 +#======================================================================== +import os +import tempfile +import sys +import HOMARD +import salome +# +# ================================== +pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du test +Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") +Rep_Test = os.path.normpath(Rep_Test) +sys.path.append(Rep_Test) +from test_util import test_results +# Repertoire des resultats +dircase = tempfile.mktemp() +os.mkdir(dircase) +# Repertoire des donnees du tutorial +data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) +sys.path.append(data_dir) +from tutorial_util import gzip_gunzip +# ================================== +gzip_gunzip(data_dir, 2, -1) +# ================================== + +salome.salome_init() +import iparameters +ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +ipar.append("AP_MODULES_LIST", "Homard") +# +#======================================================================== +#======================================================================== +def homard_exec(theStudy): + """ +Python script for HOMARD + """ + # + homard.SetCurrentStudy(theStudy) + # + # Creation des zones + # ================== + # Box "Zone_0" + Zone_0 = homard.CreateZoneBox ('Zone_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1) + # + # Sphere "Zone_1" + Zone_1 = homard.CreateZoneSphere ('Zone_1', 0., 0., 0., 1.05) + # + # Box "Zone_2" + Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) + # + # Hypothese "Hypo_2" + # ================== + Hypo_2 = homard.CreateHypothesis('Hypo_2') + Hypo_2.AddZone('Zone_1', 1) + Hypo_2.AddZone('Zone_0', 1) + # + # Hypothese "Hypo_2_bis" + # ====================== + Hypo_2_bis = homard.CreateHypothesis('Hypo_2_bis') + Hypo_2_bis.AddZone('Zone_0', -1) + Hypo_2_bis.AddZone('Zone_2', 1) + # + # Cas + # === + Case_2 = homard.CreateCase('Case_2', 'MZERO', data_dir+'/tutorial_2.00.med') + Case_2.SetDirName(dircase) + # + # Iteration "Iter_2_1" + # ==================== + Iter_2_1 = Case_2.NextIteration('Iter_2_1') + Iter_2_1.SetMeshName('M_1') + Iter_2_1.SetMeshFile(dircase+'/maill.01.med') + Iter_2_1.AssociateHypo('Hypo_2') + error = Iter_2_1.Compute(1, 2) + # + # Iteration "Iter_2_2" + # ==================== + Iter_2_2 = Iter_2_1.NextIteration('Iter_2_2') + Iter_2_2.SetMeshName('M_2') + Iter_2_2.SetMeshFile(dircase+'/maill.02.med') + Iter_2_2.AssociateHypo('Hypo_2_bis') + error = Iter_2_2.Compute(1, 2) + # + return error + +#======================================================================== + +homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') +assert homard is not None, "Impossible to load homard engine" +homard.SetLanguageShort("fr") +# +# Exec of HOMARD-SALOME +# +try : + error_main = homard_exec(salome.myStudy) + if error_main : + raise Exception('Pb in homard_exec at iteration %d' %error_main ) +except Exception, e: + raise Exception('Pb in homard_exec: '+e.message) +# +# Test of the results +# +n_rep_test_file = n_iter_test_file +test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) +# +# ================================== +gzip_gunzip(data_dir, 2, 1) +# ================================== +# +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + iparameters.getSession().restoreVisualState(1) + diff --git a/tests/test_13.apad.02.bilan b/tests/test_13.apad.02.bilan new file mode 100644 index 00000000..62cc1e37 --- /dev/null +++ b/tests/test_13.apad.02.bilan @@ -0,0 +1,97 @@ + + +ANALYSE DU MAILLAGE +=================== + + Maillage apres adaptation + G_0 + Date de creation : vendredi 21 mars 2014 a 11 h 33 mn 32 s + Dimension : 3 + Degre : 2 + C'est un maillage obtenu apres 2 adaptations. + Le niveau minimum actif est : 0 + Le niveau maximum atteint est : 2 + + Direction | Unite | Minimum | Maximum + --------------------------------------------------------------- + X | INCONNUE | 0.0000 | 0.60000 + Y | INCONNUE | 0.0000 | 0.30000 + Z | INCONNUE | 0.0000 | 0.20000 + + + NOMBRE D'ENTITES DU CALCUL + ========================== + + + ************************************************************ + * Noeuds * + ************************************************************ + * Nombre total * 14455 * + * . dont sommets d'aretes * 3839 * + * . dont milieux d'aretes * 10616 * + ************************************************************ + + ************************************************************ + * Segments * + ************************************************************ + * Nombre total * 764 * + * . dont aretes isolees * 0 * + * . dont aretes de bord de regions 2D * 0 * + * . dont aretes internes aux faces/volumes * 764 * + ************************************************************ + + ************************************************************ + * Triangles * + ************************************************************ + * Nombre total * 288 * + * . dont triangles de regions 2D * 0 * + * . dont triangles de bord * 288 * + * . dont triangles internes aux volumes * 0 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 168 * + * . du niveau 2 * 120 * + ************************************************************ + + ************************************************************ + * Quadrangles * + ************************************************************ + * Nombre total * 2534 * + * . dont quadrangles de regions 2D * 0 * + * . dont quadrangles de bord * 2534 * + * . dont quadrangles internes aux volumes * 0 * + ************************************************************ + * . du niveau 0 * 142 * + * . du niveau 1 * 2296 * + * . du niveau 2 * 96 * + ************************************************************ + + ************************************************************ + * Tetraedres * + ************************************************************ + * Nombre total * 256 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 96 * + * . du niveau 2 * 160 * + ************************************************************ + + ************************************************************ + * Hexaedres * + ************************************************************ + * Nombre total * 2230 * + ************************************************************ + * . du niveau 0 * 66 * + * . du niveau 1 * 1972 * + * . du niveau 2 * 192 * + ************************************************************ + + ************************************************************ + * Pyramides * + ************************************************************ + * Nombre total * 432 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 120 * + * . du niveau 2 * 312 * + ************************************************************ diff --git a/tests/test_13.py b/tests/test_13.py new file mode 100755 index 00000000..b75e25ec --- /dev/null +++ b/tests/test_13.py @@ -0,0 +1,172 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2011-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +Python script for HOMARD +Copyright EDF-R&D 2010, 2014 +Test test_11 associe au tutorial 3 +""" +__revision__ = "V2.1" + +#======================================================================== +Test_Name = "test_13" +n_iter_test_file = 2 +#======================================================================== +import os +import tempfile +import sys +import HOMARD +import salome +# +# ================================== +pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du test +Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") +Rep_Test = os.path.normpath(Rep_Test) +sys.path.append(Rep_Test) +from test_util import test_results +# Repertoire des resultats +dircase = tempfile.mktemp() +os.mkdir(dircase) +# Repertoire des donnees du tutorial +data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) +sys.path.append(data_dir) +from tutorial_util import gzip_gunzip +# ================================== +gzip_gunzip(data_dir, 3, -1) +# ================================== + +salome.salome_init() +import iparameters +ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +ipar.append("AP_MODULES_LIST", "Homard") +# +#======================================================================== +#======================================================================== +def homard_exec(theStudy): + """ +Python script for HOMARD + """ + # + homard.SetCurrentStudy(theStudy) + # + # Hypothese "Hypo_0vers1" + # ======================= + Hypo_0vers1 = homard.CreateHypothesis('Hypo_0vers1') + # Characterization of the field + Hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________') + Hypo_0vers1.SetUseComp(0) + Hypo_0vers1.AddComp('ERREST ') + Hypo_0vers1.SetRefinThr(3, 1.0) + Hypo_0vers1.SetTypeFieldInterp(2) + Hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________') + Hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________') + # + # Hypothese "Hypo_1vers2" + # ======================= + Hypo_1vers2 = homard.CreateHypothesis('Hypo_1vers2') + # Characterization of the field + Hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________') + Hypo_1vers2.SetUseComp(0) + Hypo_1vers2.AddComp('ERREST ') + Hypo_1vers2.SetRefinThr(3, 1.5) + Hypo_1vers2.SetUnRefThr(3, 6.) + Hypo_1vers2.SetTypeFieldInterp(2) + Hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________') + Hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________') + # + # Hypothese "Hypo_1vers2_bis" + # =========================== + Hypo_1vers2_bis = homard.CreateHypothesis('Hypo_1vers2_bis') + # Characterization of the field + Hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________') + Hypo_1vers2_bis.SetUseComp(1) + Hypo_1vers2_bis.AddComp('DX') + Hypo_1vers2_bis.AddComp('DY') + Hypo_1vers2_bis.AddComp('DZ') + Hypo_1vers2_bis.SetRefinThr(1, 0.0001) + Hypo_1vers2_bis.SetUnRefThr(1, 0.000001) + Hypo_1vers2_bis.SetTypeFieldInterp(0) + # + # Cas + # === + Case_3 = homard.CreateCase('Case_3', 'G_0', data_dir+'/tutorial_3.00.med') + Case_3.SetDirName(dircase) + # + # Iteration "Iter_3_1" + # ==================== + Iter_3_1 = Case_3.NextIteration('Iter_3_1') + Iter_3_1.SetMeshName('H_1') + Iter_3_1.SetMeshFile(dircase+'/maill.01.med') + Iter_3_1.SetFieldFile(data_dir+'/tutorial_3.00.med') + Iter_3_1.SetTimeStepRank( 1, 1) + Iter_3_1.AssociateHypo('Hypo_0vers1') + error = Iter_3_1.Compute(1, 2) + # + # Iteration "Iter_3_2" + # ==================== + Iter_3_2 = Iter_3_1.NextIteration('Iter_3_2') + Iter_3_2.SetMeshName('H_2') + Iter_3_2.SetMeshFile(dircase+'/maill.02.med') + Iter_3_2.SetFieldFile(data_dir+'/tutorial_3.01.med') + Iter_3_2.SetTimeStepRank(1, 1) + Iter_3_2.AssociateHypo('Hypo_1vers2') + error = Iter_3_2.Compute(1, 2) + # + # Iteration "Iter_3_2_bis" + # ======================== + Iter_3_2_bis = Iter_3_1.NextIteration('Iter_3_2_bis') + Iter_3_2_bis.SetMeshName('H_2_bis') + Iter_3_2_bis.SetMeshFile(dircase+'/maill.02.bis.med') + Iter_3_2_bis.SetFieldFile(data_dir+'/tutorial_3.01.med') + Iter_3_2_bis.SetTimeStepRank(1, 1) + Iter_3_2_bis.AssociateHypo('Hypo_1vers2_bis') + error = Iter_3_2_bis.Compute(1, 2) + # + return error + +#======================================================================== + +homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') +assert homard is not None, "Impossible to load homard engine" +homard.SetLanguageShort("fr") +# +# Exec of HOMARD-SALOME +# +try : + error_main = homard_exec(salome.myStudy) + if error_main : + raise Exception('Pb in homard_exec at iteration %d' %error_main ) +except Exception, e: + raise Exception('Pb in homard_exec: '+e.message) +# +# Test of the results +# +n_rep_test_file = 3 +test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) +# +# ================================== +gzip_gunzip(data_dir, 3, 1) +# ================================== +# +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + iparameters.getSession().restoreVisualState(1) + diff --git a/tests/test_14.apad.03.bilan b/tests/test_14.apad.03.bilan new file mode 100644 index 00000000..e96ae904 --- /dev/null +++ b/tests/test_14.apad.03.bilan @@ -0,0 +1,62 @@ + + +ANALYSE DU MAILLAGE +=================== + + Maillage apres adaptation + PIQUAGE + Date de creation : vendredi 21 mars 2014 a 11 h 35 mn 40 s + Dimension : 3 + Degre : 1 + C'est un maillage obtenu apres 3 adaptations. + Le niveau minimum actif est : 1 + Le niveau maximum atteint est : 2 + + Direction | Unite | Minimum | Maximum + --------------------------------------------------------------- + | | -230.00 | 136.45 + | | -250.62 | 189.69 + | | -285.21 | 155.03 + + + NOMBRE D'ENTITES DU CALCUL + ========================== + + + ************************************************************ + * Noeuds * + ************************************************************ + * Nombre total * 12825 * + ************************************************************ + + ************************************************************ + * Segments * + ************************************************************ + * Nombre total * 758 * + * . dont aretes isolees * 0 * + * . dont aretes de bord de regions 2D * 0 * + * . dont aretes internes aux faces/volumes * 758 * + ************************************************************ + + ************************************************************ + * Triangles * + ************************************************************ + * Nombre total * 20838 * + * . dont triangles de regions 2D * 0 * + * . dont triangles de bord * 20560 * + * . dont triangles internes aux volumes * 278 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 3530 * + * . du niveau 2 * 17308 * + ************************************************************ + + ************************************************************ + * Tetraedres * + ************************************************************ + * Nombre total * 43490 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 1 * 18174 * + * . du niveau 2 * 25316 * + ************************************************************ diff --git a/tests/test_14.py b/tests/test_14.py new file mode 100755 index 00000000..8a24a3b5 --- /dev/null +++ b/tests/test_14.py @@ -0,0 +1,159 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2011-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +Python script for HOMARD +Copyright EDF-R&D 2010, 2014 +Test test_11 associe au tutorial 4 +""" +__revision__ = "V2.1" + +#======================================================================== +Test_Name = "test_14" +n_iter_test_file = 3 +#======================================================================== +import os +import tempfile +import sys +import HOMARD +import salome +# +# ================================== +pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du test +Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") +Rep_Test = os.path.normpath(Rep_Test) +sys.path.append(Rep_Test) +from test_util import test_results +# Repertoire des resultats +dircase = tempfile.mktemp() +os.mkdir(dircase) +# Repertoire des donnees du tutorial +data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) +sys.path.append(data_dir) +from tutorial_util import gzip_gunzip +# ================================== +gzip_gunzip(data_dir, 4, -1) +# ================================== + +salome.salome_init() +import iparameters +ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +ipar.append("AP_MODULES_LIST", "Homard") +# +#======================================================================== +#======================================================================== +def homard_exec(theStudy): + """ +Python script for HOMARD + """ + # + homard.SetCurrentStudy(theStudy) +# + # Frontieres + # ========== + Boun_4_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', data_dir+'/tutorial_4.fr.med') + # + Boun_4_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.) + # + Boun_4_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.) + # + Boun_4_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.) + # + Boun_4_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.) + # + # Hypotheses + # ========== + # Creation of the hypothesis Hypo_4 + Hypo_4 = homard.CreateHypothesis('Hypo_4') + Hypo_4.SetUnifRefinUnRef(1) + Hypo_4.AddGroup('T1_INT_I') + Hypo_4.AddGroup('T1_INT_O') + Hypo_4.AddGroup('T2_INT') + # Creation of the hypothesis Hypo_4_bis + Hypo_4_bis = homard.CreateHypothesis('Hypo_4_bis') + Hypo_4_bis.SetUnifRefinUnRef(1) + Hypo_4_bis.AddGroup('T1_EXT_I') + Hypo_4_bis.AddGroup('T1_EXT_O') + Hypo_4_bis.AddGroup('T2_EXT') + # + # Cas + # === + Case_4 = homard.CreateCase('Case_4', 'PIQUAGE', data_dir+'/tutorial_4.00.med') + Case_4.SetDirName(dircase) + Case_4.AddBoundaryGroup( 'intersection', '' ) + Case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' ) + Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' ) + Case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' ) + Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' ) + Case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' ) + Case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' ) + # + # Iterations + # ========== + # Iteration Iter_4_1 : raffinement selon les faces internes + Iter_4_1 = Case_4.NextIteration('Iter_4_1') + Iter_4_1.SetMeshName('PIQUAGE_1') + Iter_4_1.SetMeshFile(dircase+'/maill.01.med') + Iter_4_1.AssociateHypo('Hypo_4') + error = Iter_4_1.Compute(1, 2) + # Iteration Iter_4_2 : raffinement selon les faces externes + Iter_4_2 = Iter_4_1.NextIteration('Iter_4_2') + Iter_4_2.SetMeshName('PIQUAGE_2') + Iter_4_2.SetMeshFile(dircase+'/maill.02.med') + Iter_4_2.AssociateHypo('Hypo_4_bis') + error = Iter_4_2.Compute(1, 2) + # Iteration Iter_4_3 : second raffinement selon les faces externes + Iter_4_3 = Iter_4_2.NextIteration('Iter_4_3') + Iter_4_3.SetMeshName('PIQUAGE_3') + Iter_4_3.SetMeshFile(dircase+'/maill.03.med') + Iter_4_3.AssociateHypo('Hypo_4_bis') + error = Iter_4_3.Compute(1, 2) + # + return error + +#======================================================================== + +homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') +assert homard is not None, "Impossible to load homard engine" +homard.SetLanguageShort("fr") +# +# Exec of HOMARD-SALOME +# +try : + error_main = homard_exec(salome.myStudy) + if error_main : + raise Exception('Pb in homard_exec at iteration %d' %error_main ) +except Exception, e: + raise Exception('Pb in homard_exec: '+e.message) +# +# Test of the results +# +n_rep_test_file = n_iter_test_file +test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) +# +# ================================== +gzip_gunzip(data_dir, 4, 1) +# ================================== +# +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + iparameters.getSession().restoreVisualState(1) + diff --git a/tests/test_15.apad.02.bilan b/tests/test_15.apad.02.bilan new file mode 100644 index 00000000..5e5f91a8 --- /dev/null +++ b/tests/test_15.apad.02.bilan @@ -0,0 +1,58 @@ + + +ANALYSE DU MAILLAGE +=================== + + Maillage apres adaptation + COEUR_2D + Date de creation : vendredi 21 mars 2014 a 11 h 33 mn 45 s + Dimension : 2 + Degre : 1 + C'est un maillage obtenu apres 2 adaptations. + Le niveau minimum actif est : 0 + Le niveau maximum atteint est : 2 + + Direction | Unite | Minimum | Maximum + --------------------------------------------------------------- + | | -248.00 | 248.00 + | | -248.00 | 248.00 + + + NOMBRE D'ENTITES DU CALCUL + ========================== + + + ************************************************************ + * Noeuds * + ************************************************************ + * Nombre total * 1542 * + ************************************************************ + + ************************************************************ + * Segments * + ************************************************************ + * Nombre total * 359 * + * . dont aretes isolees * 0 * + * . dont aretes de bord de regions 2D * 240 * + * . dont aretes internes aux faces/volumes * 119 * + ************************************************************ + + ************************************************************ + * Triangles * + ************************************************************ + * Nombre total * 2204 * + ************************************************************ + * . du niveau 0 * 88 * + * . du niveau 1 * 980 * + * . du niveau 2 * 1136 * + ************************************************************ + + ************************************************************ + * Quadrangles * + ************************************************************ + * Nombre total * 334 * + ************************************************************ + * . du niveau 0 * 162 * + * . du niveau 1 * 172 * + * . du niveau 2 * 0 * + ************************************************************ diff --git a/tests/test_15.py b/tests/test_15.py new file mode 100755 index 00000000..d75bb444 --- /dev/null +++ b/tests/test_15.py @@ -0,0 +1,143 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2011-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +Python script for HOMARD +Copyright EDF-R&D 2010, 2014 +Test test_11 associe au tutorial 5 +""" +__revision__ = "V2.1" + +#======================================================================== +Test_Name = "test_15" +n_iter_test_file = 2 +#======================================================================== +import os +import tempfile +import sys +import HOMARD +import salome +# +# ================================== +pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du test +Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") +Rep_Test = os.path.normpath(Rep_Test) +sys.path.append(Rep_Test) +from test_util import test_results +# Repertoire des resultats +dircase = tempfile.mktemp() +os.mkdir(dircase) +# Repertoire des donnees du tutorial +data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +data_dir = os.path.normpath(data_dir) +sys.path.append(data_dir) +from tutorial_util import gzip_gunzip +# ================================== +gzip_gunzip(data_dir, 5, -1) +# ================================== + +salome.salome_init() +import iparameters +ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +ipar.append("AP_MODULES_LIST", "Homard") +# +#======================================================================== +#======================================================================== +def homard_exec(theStudy): + """ +Python script for HOMARD + """ + # + homard.SetCurrentStudy(theStudy) +# + # Frontiere + # ========= + # Creation of the discrete boundary Boun_5_1 + Boun_5_1 = homard.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', data_dir+'/tutorial_5.fr.med') + # + # Creation des zones + # ================== + # Creation of the disk with hole enveloppe + enveloppe = homard.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 ) + # Creation of the rectangle quart_sup + quart_sup = homard.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 ) + # + # Hypotheses + # ========== + # Creation of the hypothesis Hypo_5 + Hypo_5 = homard.CreateHypothesis('Hypo_5') + Hypo_5.AddZone('enveloppe', 1) + # Creation of the hypothesis Hypo_5_bis + Hypo_5_bis = homard.CreateHypothesis('Hypo_5_bis') + Hypo_5_bis.AddZone('quart_sup', 1) + # + # Cas + # === + Case_5 = homard.CreateCase('Case_5', 'COEUR_2D', data_dir+'/tutorial_5.00.med') + Case_5.SetDirName(dircase) + Case_5.SetConfType(3) + Case_5.AddBoundaryGroup('Boun_5_1', '') + # + # Iteration "Iter_5_1" + # ==================== + Iter_5_1 = Case_5.NextIteration('Iter_5_1') + Iter_5_1.SetMeshName('COEUR_2D_01') + Iter_5_1.SetMeshFile(dircase+'/maill.01.med') + Iter_5_1.AssociateHypo('Hypo_5') + error = Iter_5_1.Compute(1, 2) + # + # Iteration "Iter_5_2" + # ==================== + Iter_5_2 = Iter_5_1.NextIteration('Iter_5_2') + Iter_5_2.SetMeshName('COEUR_2D_02') + Iter_5_2.SetMeshFile(dircase+'/maill.02.med') + Iter_5_2.AssociateHypo('Hypo_5_bis') + error = Iter_5_2.Compute(1, 2) + # + return error + +#======================================================================== + +homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') +assert homard is not None, "Impossible to load homard engine" +homard.SetLanguageShort("fr") +# +# Exec of HOMARD-SALOME +# +try : + error_main = homard_exec(salome.myStudy) + if error_main : + raise Exception('Pb in homard_exec at iteration %d' %error_main ) +except Exception, e: + raise Exception('Pb in homard_exec: '+e.message) +# +# Test of the results +# +n_rep_test_file = n_iter_test_file +test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) +# +# ================================== +gzip_gunzip(data_dir, 5, 1) +# ================================== +# +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + iparameters.getSession().restoreVisualState(1) + diff --git a/tests/test_2.py b/tests/test_2.py index f4f5c248..df819821 100755 --- a/tests/test_2.py +++ b/tests/test_2.py @@ -19,10 +19,10 @@ # """ Python script for HOMARD -Copyright EDF-R&D 2010, 2013 +Copyright EDF-R&D 2010, 2014 Test test_2 """ -__revision__ = "V2.1" +__revision__ = "V2.2" #======================================================================== Test_Name = "test_2" @@ -34,14 +34,18 @@ import sys import HOMARD import salome # +# ================================== pathHomard = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des donnees du test Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") Rep_Test = os.path.normpath(Rep_Test) -Rep_Test_Resu = tempfile.mktemp() -os.mkdir(Rep_Test_Resu) - sys.path.append(Rep_Test) -from test_util import remove_dir +from test_util import test_results +# Repertoire des resultats +dircase = tempfile.mktemp() +os.mkdir(dircase) +# ================================== + salome.salome_init() import iparameters @@ -53,7 +57,6 @@ ipar.append("AP_MODULES_LIST", "Homard") def homard_exec(theStudy): """ Python script for HOMARD -Copyright EDF-R&D 2010, 2013 """ error = 0 # @@ -99,7 +102,7 @@ Copyright EDF-R&D 2010, 2013 CaseName = "Case_" + Test_Name MeshFile = os.path.join(Rep_Test, Test_Name + '.00.med') Case_test_2 = homard.CreateCase(CaseName, 'PLAQUE_0', MeshFile) - Case_test_2.SetDirName(Rep_Test_Resu) + Case_test_2.SetDirName(dircase) Case_test_2.SetConfType(1) Case_test_2.AddBoundaryGroup('internal_boundary', '') # @@ -109,7 +112,7 @@ Copyright EDF-R&D 2010, 2013 IterName = "I_" + Test_Name + "_1" Iter_test_2_1 = Case_test_2.NextIteration(IterName) Iter_test_2_1.SetMeshName('PLAQUE_1') - Iter_test_2_1.SetMeshFile(os.path.join(Rep_Test_Resu, 'maill.01.med')) + Iter_test_2_1.SetMeshFile(os.path.join(dircase, 'maill.01.med')) Iter_test_2_1.AssociateHypo(HypoName_1) error = Iter_test_2_1.Compute(1, 1) if error : @@ -120,7 +123,7 @@ Copyright EDF-R&D 2010, 2013 IterName = "I_" + Test_Name + "_2" Iter_test_2_2 = Iter_test_2_1.NextIteration(IterName) Iter_test_2_2.SetMeshName('PLAQUE_2') - Iter_test_2_2.SetMeshFile(os.path.join(Rep_Test_Resu, 'maill.02.med')) + Iter_test_2_2.SetMeshFile(os.path.join(dircase, 'maill.02.med')) Iter_test_2_2.AssociateHypo(HypoName_1) error = Iter_test_2_2.Compute(1, 1) if error : @@ -131,7 +134,7 @@ Copyright EDF-R&D 2010, 2013 IterName = "I_" + Test_Name + "_3" Iter_test_2_3 = Iter_test_2_2.NextIteration(IterName) Iter_test_2_3.SetMeshName('PLAQUE_3') - Iter_test_2_3.SetMeshFile(os.path.join(Rep_Test_Resu, 'maill.03.med')) + Iter_test_2_3.SetMeshFile(os.path.join(dircase, 'maill.03.med')) Iter_test_2_3.AssociateHypo(HypoName_2) error = Iter_test_2_3.Compute(1, 1) if error : @@ -142,10 +145,10 @@ Copyright EDF-R&D 2010, 2013 # =========================== ScriptFile = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script.py") ScriptFile = os.path.normpath(ScriptFile) - DirName = Rep_Test_Resu + DirName = dircase YACS_test_2 = Case_test_2.CreateYACSSchema("YACS_test_2", ScriptFile, DirName, MeshFile) YACS_test_2.SetType(1) - filexml = os.path.join(Rep_Test_Resu, 'YACS_test_2.xml') + filexml = os.path.join(dircase, 'YACS_test_2.xml') error = YACS_test_2.WriteOnFile(filexml) if error : error = 4 @@ -169,47 +172,11 @@ try : raise Exception('Pb in homard_exec at iteration %d' %error_main ) except Exception, e: raise Exception('Pb in homard_exec: '+e.message) - -# -# Test of the result -# -test_file_suff = "apad.%02d.bilan" % n_iter_test_file -rep_test_file = "I%02d" % n_iter_test_file # -test_file = os.path.join(Rep_Test, Test_Name + "." + test_file_suff) -mess_error_ref = "\nReference file: " + test_file -try : - file = open (test_file, "r") - mess_ref = file.readlines() - file.close() -except : - mess_error = mess_error_ref + "\nThis file does not exist.\n" - raise Exception(mess_error) -# -test_file = os.path.join(Rep_Test_Resu, rep_test_file, test_file_suff) -if os.path.isfile (test_file) : - file = open (test_file, "r") - mess = file.readlines() - file.close() -else : - mess_error = "\nResult file: " + test_file - mess_error += "\nThis file does not exist.\n" - raise Exception(mess_error) - -nblign = len(mess_ref) -if ( len(mess) != nblign ): - mess_error = mess_error_ref + "\nResult file: " + test_file - mess_error += "\nThe number of lines of the files are not the same.\n" - raise Exception(mess_error) - -for num in range(nblign) : - if (( "creation" not in mess_ref[num] ) and ( mess_ref[num] != mess[num])) : - message_erreur = "\nRefe : " + mess_ref[num] - message_erreur += "Test : " + mess[num][:-1] - message_erreur += "\nThe test is different from the reference." - raise Exception(message_erreur) +# Test of the results # -remove_dir(Rep_Test_Resu) +n_rep_test_file = n_iter_test_file +test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) # if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/tests/test_3.py b/tests/test_3.py old mode 100644 new mode 100755 index 3f55458e..936c1a2d --- a/tests/test_3.py +++ b/tests/test_3.py @@ -38,11 +38,11 @@ import salome pathHomard = os.getenv('HOMARD_ROOT_DIR') Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") Rep_Test = os.path.normpath(Rep_Test) -Rep_Test_Resu = tempfile.mktemp() -os.mkdir(Rep_Test_Resu) +dircase = tempfile.mktemp() +os.mkdir(dircase) sys.path.append(Rep_Test) -from test_util import remove_dir +from test_util import test_results salome.salome_init() import iparameters @@ -101,7 +101,7 @@ Copyright EDF-R&D 2010, 2013 print "-------- Creation of the case", CaseName MeshFile = os.path.join(Rep_Test, Test_Name + '.00.med') Case_test_3 = homard.CreateCase(CaseName, 'MOYEU', MeshFile) - Case_test_3.SetDirName(Rep_Test_Resu) + Case_test_3.SetDirName(dircase) Case_test_3.SetConfType(1) Case_test_3.AddBoundaryGroup('courbes', '') Case_test_3.AddBoundaryGroup('cyl_ext', 'EXT') @@ -116,7 +116,7 @@ Copyright EDF-R&D 2010, 2013 print "-------- Creation of the iteration", IterName Iter_test_3_1 = Case_test_3.NextIteration(IterName) Iter_test_3_1.SetMeshName('MOYEU_1') - Iter_test_3_1.SetMeshFile(os.path.join(Rep_Test_Resu, 'maill.01.med')) + Iter_test_3_1.SetMeshFile(os.path.join(dircase, 'maill.01.med')) Iter_test_3_1.AssociateHypo('Hypo_test_3') error = Iter_test_3_1.Compute(1, 1) if error : @@ -128,7 +128,7 @@ Copyright EDF-R&D 2010, 2013 print "-------- Creation of the iteration", IterName Iter_test_3_2 = Iter_test_3_1.NextIteration(IterName) Iter_test_3_2.SetMeshName('MOYEU_2') - Iter_test_3_2.SetMeshFile(os.path.join(Rep_Test_Resu, 'maill.02.med')) + Iter_test_3_2.SetMeshFile(os.path.join(dircase, 'maill.02.med')) Iter_test_3_2.AssociateHypo('Hypo_test_3') error = Iter_test_3_2.Compute(1, 1) if error : @@ -139,7 +139,7 @@ Copyright EDF-R&D 2010, 2013 # =========================== ScriptFile = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script.py") ScriptFile = os.path.normpath(ScriptFile) - DirName = Rep_Test_Resu + DirName = dircase YACSName = "YACS_" + Test_Name print "-------- Creation of the schema", YACSName YACS_test_3 = Case_test_3.CreateYACSSchema(YACSName, ScriptFile, DirName, MeshFile) @@ -204,45 +204,10 @@ try : except Exception, e: raise Exception('Pb in homard_exec: '+e.message) # -# Test of the result +# Test of the results # -test_file_suff = "apad.%02d.bilan" % n_iter_test_file -rep_test_file = "I%02d" % (n_iter_test_file*n_boucle) -# -test_file = os.path.join(Rep_Test, Test_Name + "." + test_file_suff) -mess_error_ref = "\nReference file: " + test_file -try : - file = open (test_file, "r") - mess_ref = file.readlines() - file.close() -except : - mess_error = mess_error_ref + "\nThis file does not exist.\n" - raise Exception(mess_error) -# -test_file = os.path.join(Rep_Test_Resu, rep_test_file, test_file_suff) -if os.path.isfile (test_file) : - file = open (test_file, "r") - mess = file.readlines() - file.close() -else : - mess_error = "\nResult file: " + test_file - mess_error += "\nThis file does not exist.\n" - raise Exception(mess_error) - -nblign = len(mess_ref) -if ( len(mess) != nblign ): - mess_error = mess_error_ref + "\nResult file: " + test_file - mess_error += "\nThe number of lines of the files are not the same.\n" - raise Exception(mess_error) - -for num in range(nblign) : - if (( "creation" not in mess_ref[num] ) and ( mess_ref[num] != mess[num])) : - message_erreur = "\nRefe : " + mess_ref[num] - message_erreur += "Test : " + mess[num][:-1] - message_erreur += "\nThe test is different from the reference." - raise Exception(message_erreur) -# -remove_dir(Rep_Test_Resu) +n_rep_test_file = n_iter_test_file*n_boucle +test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) # if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/tests/test_util.py b/tests/test_util.py index 7fa94840..596f7d54 100755 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -46,3 +46,56 @@ Copyright EDF-R&D 2013 # #======================================================================== #======================================================================== +def test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file) : + """ +Test of the result +Rep_Test: repertoire des tests +Test_Name: nom du test +dircase: repertoire des resultats du test +n_iter_test_file: numero de l'iteration a tester +n_rep_test_file: numero du repertoire de l'iteration a tester +Copyright EDF-R&D 2014 + """ + # + test_file_suff = "apad.%02d.bilan" % n_iter_test_file + rep_test_file = "I%02d" % n_rep_test_file + # + test_file = os.path.join(Rep_Test, Test_Name + "." + test_file_suff) + mess_error_ref = "\nReference file: " + test_file + try : + file = open (test_file, "r") + mess_ref = file.readlines() + file.close() + except : + mess_error = mess_error_ref + "\nThis file does not exist.\n" + raise Exception(mess_error) + # + test_file = os.path.join(dircase, rep_test_file, test_file_suff) + if os.path.isfile (test_file) : + file = open (test_file, "r") + mess = file.readlines() + file.close() + else : + mess_error = "\nResult file: " + test_file + mess_error += "\nThis file does not exist.\n" + raise Exception(mess_error) + + nblign = len(mess_ref) + if ( len(mess) != nblign ): + mess_error = mess_error_ref + "\nResult file: " + test_file + mess_error += "\nThe number of lines of the files are not the same.\n" + raise Exception(mess_error) + + for num in range(nblign) : + if (( "creation" not in mess_ref[num] ) and ( mess_ref[num] != mess[num])) : + message_erreur = "\nRefe : " + mess_ref[num] + message_erreur += "Test : " + mess[num][:-1] + message_erreur += "\nThe test is different from the reference." + raise Exception(message_erreur) + # + remove_dir(dircase) +# + return +# +#======================================================================== +#========================================================================