From 002d16c31574b7ae676a91f880c05afe8dedd24e Mon Sep 17 00:00:00 2001 From: Gerald NICOLAS Date: Tue, 9 Jan 2018 16:58:07 +0100 Subject: [PATCH] automatisation FronTrack - tests --- src/tests/Test/test_1.py | 2 +- src/tests/Test/test_2.py | 2 +- src/tests/Test/test_3.py | 6 +- src/tests/Test/test_4.py | 2 +- src/tests/Test/test_5.py | 2 +- src/tests/Test/test_util.py | 101 ++++++--------- src/tests/Test/tutorial_1.py | 149 ++++++++++++++--------- src/tests/Test/tutorial_2.py | 170 ++++++++++++++++---------- src/tests/Test/tutorial_3.py | 229 +++++++++++++++++++++-------------- src/tests/Test/tutorial_4.py | 199 ++++++++++++++++++------------ src/tests/Test/tutorial_5.py | 175 ++++++++++++++++---------- 11 files changed, 611 insertions(+), 426 deletions(-) diff --git a/src/tests/Test/test_1.py b/src/tests/Test/test_1.py index dd221ebc..01055418 100755 --- a/src/tests/Test/test_1.py +++ b/src/tests/Test/test_1.py @@ -52,7 +52,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # ================================== salome.salome_init() diff --git a/src/tests/Test/test_2.py b/src/tests/Test/test_2.py index c73f71fa..5183eca0 100755 --- a/src/tests/Test/test_2.py +++ b/src/tests/Test/test_2.py @@ -52,7 +52,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # ================================== salome.salome_init() diff --git a/src/tests/Test/test_3.py b/src/tests/Test/test_3.py index 04dbec62..3318dd52 100755 --- a/src/tests/Test/test_3.py +++ b/src/tests/Test/test_3.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_3 """ -__revision__ = "V4.01" +__revision__ = "V4.02" #======================================================================== TEST_NAME = "test_3" @@ -53,7 +53,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # ================================== salome.salome_init() @@ -112,7 +112,7 @@ Python script for HOMARD mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med') case_test_3 = HOMARD.CreateCase(TEST_NAME, 'MOYEU', mesh_file) case_test_3.SetDirName(DIRCASE) - case_test_3.AddBoundaryGroup('courbes', '') + case_test_3.AddBoundary('courbes') case_test_3.AddBoundaryGroup('cyl_ext', 'EXT') case_test_3.AddBoundaryGroup('cyl_int', 'INT') case_test_3.AddBoundaryGroup('sphere_1', 'END_1') diff --git a/src/tests/Test/test_4.py b/src/tests/Test/test_4.py index c3d870c2..aae31029 100755 --- a/src/tests/Test/test_4.py +++ b/src/tests/Test/test_4.py @@ -60,7 +60,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # ================================== salome.salome_init() diff --git a/src/tests/Test/test_5.py b/src/tests/Test/test_5.py index 1c131ce3..bb3dad19 100755 --- a/src/tests/Test/test_5.py +++ b/src/tests/Test/test_5.py @@ -64,7 +64,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # ================================== salome.salome_init() diff --git a/src/tests/Test/test_util.py b/src/tests/Test/test_util.py index 6fb8c33f..e43156c8 100755 --- a/src/tests/Test/test_util.py +++ b/src/tests/Test/test_util.py @@ -21,7 +21,7 @@ Python script for HOMARD Utilitaires pour les tests """ -__revision__ = "V3.01" +__revision__ = "V3.03" import os import MEDLoader as ml @@ -61,16 +61,15 @@ Copyright EDF-R&D 2014 # test_file_suff = "apad.%02d.bilan" % n_iter_test_file rep_test_file = "I%02d" % n_rep_test_file +# +# Existence du fichier de référence # test_file = os.path.join(rep_test, test_name + "." + test_file_suff) mess_error_ref = "\nReference file: " + test_file -# -# Existence du fichier de référence -# + #print ("test_file = %s" % test_file) try : - file = open (test_file, "r") - les_lignes_ref = file.readlines() - file.close() + with open (test_file, "r") as fichier : + les_lignes_ref = fichier.readlines() except : mess_error = mess_error_ref + "\nThis file does not exist.\n" destroy_dir = False @@ -80,9 +79,8 @@ Copyright EDF-R&D 2014 # test_file = os.path.join(dircase, rep_test_file, test_file_suff) if os.path.isfile (test_file) : - file = open (test_file, "r") - les_lignes = file.readlines() - file.close() + with open (test_file, "r") as fichier : + les_lignes = fichier.readlines() else : mess_error = "\nResult file: " + test_file mess_error += "\nThis file does not exist.\n" @@ -164,7 +162,7 @@ def saveGeometry( xao_file, name, author="" ): #======================================================================== #======================================================================== # -def repositionnement (rep_calc, fic_med_brut, fic_med_new, xao_file, verbose=False) : +def repositionnement (rep_calc, fic_med_brut, fic_med_new, xao_file, menage=True, verbose=False) : # """ Pilote le repositionnement des noeuds qui ont bougé @@ -173,12 +171,14 @@ Entrées : fic_med_brut : fichier MED du calcul avec les coordonnées avant projection fic_med_new : fichier MED du calcul avec les coordonnées après projection xao_file : fichier XAO de la géométrie + menage : Suppression du fichier fic_med_brut """ if verbose : ligne = "rep_calc = %s" % rep_calc ligne += "\nfic_med_brut = %s" % fic_med_brut ligne += "\nfic_med_new = %s" % fic_med_new ligne += "\nxao_file = %s" % xao_file + ligne += "\nmenage = %d" % menage print(ligne) message = "" @@ -186,8 +186,6 @@ Entrées : while not erreur : # # 1. l_fr = liste des fichiers des lignes/surfaces a suivre -# Les fichiers des numéros de groupes par frontière sont renommés selon le support -# à condition de ne pas être vide. # fic_hom_med = None laux = os.listdir(rep_calc) @@ -197,33 +195,8 @@ Entrées : icpt_2D = 0 for fic in laux : #print "\t" + fic - if ( fic[:5] == 'fort.' ) : - fic_fort = os.path.join(rep_calc, fic) - fichier = open (fic_fort, "r") - les_lignes = fichier.readlines() - fichier.close() - os.remove(fic_fort) - a_faire = False - for ligne in les_lignes[1:] : - laux1 = ligne.split() - if ( len(laux1) >= 3 ) : - a_faire = True - break - if a_faire : - if ( "1D" in les_lignes[0] ) : - nomfic_bis = "fr1D.%02d" % icpt_1D - icpt_1D += 1 - else : - nomfic_bis = "fr2D.%02d" % icpt_2D - icpt_2D += 1 - fic_1 = os.path.join(rep_calc, nomfic_bis) - fichier = open (fic_1, "w") - for ligne in les_lignes[1:] : - if ( ( "1D" not in ligne ) and ( "2D" not in ligne ) ) : - fichier.write(ligne) - fichier.close() - #print "\t\tajout de %s" % fic_1 - l_fr.append(fic_1) + if ( fic[:2] == 'fr' ) : + l_fr.append(os.path.join(rep_calc, fic)) elif ( fic[-4:] == '.med' ) : fic_hom_med = os.path.join(rep_calc, fic) #print "\t\treperage de fic_hom_med =", fic_hom_med @@ -259,11 +232,14 @@ Entrées : #if erreur : #break # -# 2.3. Ménage de l'ancien fichier MED +# 2.3. Ménage éventuel de l'ancien fichier MED # - if ( fic_med_brut != fic_med_new ) : - print("Suppression du fichier %s" % fic_med_new) - os.remove(fic_med_brut) + if menage : +# + if ( fic_med_brut != fic_med_new ) : + if verbose : + print("Suppression du fichier %s" % fic_med_brut) + os.remove(fic_med_brut) # # 3. Renommage du fichier si aucun noeud n'est concerné # @@ -306,9 +282,8 @@ Entrées : # 1. Recherche des inforamtions permanentes dans le fichier de configuration # fic_conf = os.path.join(rep_calc, "HOMARD.Configuration") - fichier = open (fic_conf, "r") - les_lignes = fichier.readlines() - fichier.close() + with open (fic_conf, "r") as fichier : + les_lignes = fichier.readlines() # ligne0 = "" icpt = 0 @@ -336,22 +311,22 @@ Entrées : # 2. Création du fichier de configuration # fic_conf_sv = os.path.join(rep_calc, "HOMARD.Configuration.majc") - fichier = open (fic_conf_sv, "w") -# - ligne = ligne0 - ligne += "ModeHOMA 5\n" - fic = os.path.join(rep_calc, "Liste.%s.maj_coords.log" % s_iter) - ligne += "ListeStd %s\n" % fic - ligne += "CCMaiN__ %s\n" % fic_med_calc - ligne += "RepeTrav %s\n" % rep_calc - ligne += "RepeInfo %s\n" % rep_calc - ligne += "Action homa\n" - ligne += "CCAssoci med\n" - ligne += "EcriFiHO N_SANS_FRONTIERE\n" - ligne += "MessInfo 10\n" -# - fichier.write(ligne) - fichier.close() +# + with open (fic_conf_sv, "w") as fichier : +# + ligne = ligne0 + ligne += "ModeHOMA 5\n" + fic = os.path.join(rep_calc, "Liste.%s.maj_coords.log" % s_iter) + ligne += "ListeStd %s\n" % fic + ligne += "CCMaiN__ %s\n" % fic_med_calc + ligne += "RepeTrav %s\n" % rep_calc + ligne += "RepeInfo %s\n" % rep_calc + ligne += "Action homa\n" + ligne += "CCAssoci med\n" + ligne += "EcriFiHO N_SANS_FRONTIERE\n" + ligne += "MessInfo 10\n" +# + fichier.write(ligne) # # 3. Mise à jour # 3.1. Détermination de l'exécutable diff --git a/src/tests/Test/tutorial_1.py b/src/tests/Test/tutorial_1.py index b227bd2a..070277b5 100755 --- a/src/tests/Test/tutorial_1.py +++ b/src/tests/Test/tutorial_1.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_1 associe au tutorial 1 """ -__revision__ = "V4.01" +__revision__ = "V4.02" #======================================================================== TEST_NAME = "tutorial_1" @@ -52,7 +52,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # Repertoire des donnees du tutorial DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) @@ -67,70 +67,109 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(theStudy): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, verbose=False): """ Python script for HOMARD """ + erreur = 0 + message = "" # - homard.SetCurrentStudy(theStudy) - # - # Hypotheses - # ========== - hypo_1 = homard.CreateHypothesis('hypo_1') - hypo_1.SetUnifRefinUnRef(1) - # - # Cas - # === - case_1 = homard.CreateCase('case_1', 'MAILL', DATA_TUTORIAL+'/tutorial_1.00.med') - case_1.SetDirName(DIRCASE) - # - # 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) + while not erreur : + # + HOMARD.SetCurrentStudy(salome.myStudy) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + hypo_1 = HOMARD.CreateHypothesis('hypo_1') + hypo_1.SetUnifRefinUnRef(1) + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_1', nom, ficmed) + le_cas.SetDirName(DIRCASE) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # Iteration "iter_1_1" + iter_1_1 = le_cas.NextIteration('iter_1_1') + iter_1_1.SetMeshName('MESH') + iter_1_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_1_1.AssociateHypo('hypo_1') + erreur = iter_1_1.Compute(1, option) + if erreur : + break - # 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_2" + iter_1_2 = iter_1_1.NextIteration('iter_1_2') + iter_1_2.SetMeshName('MESH') + iter_1_2.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_1_2.AssociateHypo('hypo_1') + erreur = iter_1_2.Compute(1, option) + if erreur : + break - # 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) + # Iteration "iter_1_3" + iter_1_3 = iter_1_2.NextIteration('iter_1_3') + iter_1_3.SetMeshName('MESH') + iter_1_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med")) + iter_1_3.AssociateHypo('hypo_1') + erreur = iter_1_3.Compute(1, option) + if erreur : + break # - return error - -#======================================================================== - -homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert homard is not None, "Impossible to load homard engine" -homard.SetLanguageShort("fr") + break + # + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur + # + return erreur, message # -# Exec of HOMARD-SALOME +#========================== Fin de la fonction ================================== # -try : - ERROR = homard_exec(salome.myStudy) - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) +ERREUR = 0 +MESSAGE = "" +while not ERREUR : + # + # A. Exec of HOMARD-SALOME + # + HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') + assert HOMARD is not None, "Impossible to load homard engine" + HOMARD.SetLanguageShort("fr") # -# Test of the results + FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med") + try: + ERREUR, MESSAGE = homard_exec("MAILL", FICMED, DEBUG) + except Exception, eee: + ERREUR = 2 + MESSAGE = eee.message + # + if ERREUR : + MESSAGE += "Pb in homard_exec" + break + # + # B. Test of the results + # + N_REP_TEST_FILE = N_ITER_TEST_FILE + DESTROY_DIR = not DEBUG + test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) + # + break # -N_REP_TEST_FILE = N_ITER_TEST_FILE -DESTROY_DIR = not DEBUG -test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 1, 1) diff --git a/src/tests/Test/tutorial_2.py b/src/tests/Test/tutorial_2.py index ca731ac5..f8bfaf34 100755 --- a/src/tests/Test/tutorial_2.py +++ b/src/tests/Test/tutorial_2.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_2 associe au tutorial 2 """ -__revision__ = "V4.01" +__revision__ = "V4.02" #======================================================================== TEST_NAME = "tutorial_2" @@ -52,7 +52,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # Repertoire des donnees du tutorial DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) @@ -67,81 +67,125 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(theStudy): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, verbose=False): """ Python script for HOMARD """ + erreur = 0 + message = "" # - HOMARD.SetCurrentStudy(theStudy) + while not erreur : + # + HOMARD.SetCurrentStudy(salome.myStudy) + # + # Creation des zones + # ================== + if verbose : + print(". Zones") + # Box "Zone_12_0" + zone_12_0 = HOMARD.CreateZoneBox ('Zone_12_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1) + # + # Sphere "Zone_12_1" + zone_12_1 = HOMARD.CreateZoneSphere ('Zone_12_1', 0., 0., 0., 1.05) + # + # Box "Zone_12_2" + zone_12_2 = HOMARD.CreateZoneBox ('Zone_12_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + # Hypothese "hypo_2" + # ================== + hypo_2 = HOMARD.CreateHypothesis('hypo_2') + hypo_2.AddZone('Zone_12_1', 1) + hypo_2.AddZone('Zone_12_0', 1) + # + # Hypothese "hypo_2_bis" + # ====================== + hypo_2_bis = HOMARD.CreateHypothesis('hypo_2_bis') + hypo_2_bis.AddZone('Zone_12_0', -1) + hypo_2_bis.AddZone('Zone_12_2', 1) + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_2', nom, ficmed) + le_cas.SetDirName(DIRCASE) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # + # Iteration "iter_2_1" + # ==================== + iter_2_1 = le_cas.NextIteration('iter_2_1') + iter_2_1.SetMeshName('M_1') + iter_2_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_2_1.AssociateHypo('hypo_2') + erreur = iter_2_1.Compute(1, option) + if erreur : + break + # + # Iteration "iter_2_2" + # ==================== + iter_2_2 = iter_2_1.NextIteration('iter_2_2') + iter_2_2.SetMeshName('M_2') + iter_2_2.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_2_2.AssociateHypo('hypo_2_bis') + erreur = iter_2_2.Compute(1, option) + if erreur : + break # - # Creation des zones - # ================== - # Box "Zone_12_0" - zone_12_0 = HOMARD.CreateZoneBox ('Zone_12_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1) + break # - # Sphere "Zone_12_1" - zone_12_1 = HOMARD.CreateZoneSphere ('Zone_12_1', 0., 0., 0., 1.05) + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur # - # Box "Zone_12_2" - zone_12_2 = HOMARD.CreateZoneBox ('Zone_12_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) + return erreur, message +# +#========================== Fin de la fonction ================================== +# +ERREUR = 0 +MESSAGE = "" +while not ERREUR : # - # Hypothese "hypo_2" - # ================== - hypo_2 = HOMARD.CreateHypothesis('hypo_2') - hypo_2.AddZone('Zone_12_1', 1) - hypo_2.AddZone('Zone_12_0', 1) + # A. Exec of HOMARD-SALOME # - # Hypothese "hypo_2_bis" - # ====================== - hypo_2_bis = HOMARD.CreateHypothesis('hypo_2_bis') - hypo_2_bis.AddZone('Zone_12_0', -1) - hypo_2_bis.AddZone('Zone_12_2', 1) + HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') + assert HOMARD is not None, "Impossible to load homard engine" + HOMARD.SetLanguageShort("fr") +# + FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med") + try: + ERREUR, MESSAGE = homard_exec("MZERO", FICMED, DEBUG) + except Exception, eee: + ERREUR = 2 + MESSAGE = eee.message # - # Cas - # === - case_2 = HOMARD.CreateCase('case_2', 'MZERO', DATA_TUTORIAL+'/tutorial_2.00.med') - case_2.SetDirName(DIRCASE) + if ERREUR : + MESSAGE += "Pb in homard_exec" + break # - # 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) + # B. Test of the results # - # 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) + N_REP_TEST_FILE = N_ITER_TEST_FILE + DESTROY_DIR = not DEBUG + test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) # - 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 = homard_exec(salome.myStudy) - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) -# -# Test of the results + break # -N_REP_TEST_FILE = N_ITER_TEST_FILE -DESTROY_DIR = not DEBUG -test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 2, 1) diff --git a/src/tests/Test/tutorial_3.py b/src/tests/Test/tutorial_3.py index c4efe620..602ace5f 100755 --- a/src/tests/Test/tutorial_3.py +++ b/src/tests/Test/tutorial_3.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_3 associe au tutorial 3 """ -__revision__ = "V4.01" +__revision__ = "V4.02" #======================================================================== TEST_NAME = "tutorial_3" @@ -52,7 +52,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # Repertoire des donnees du tutorial DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) @@ -67,110 +67,153 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(theStudy): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, verbose=False): """ Python script for HOMARD """ + erreur = 0 + message = "" # - HOMARD.SetCurrentStudy(theStudy) + while not erreur : + # + HOMARD.SetCurrentStudy(salome.myStudy) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + # 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 + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_3', nom, ficmed) + le_cas.SetDirName(DIRCASE) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # Iteration "iter_3_1" + # ==================== + iter_3_1 = le_cas.NextIteration('iter_3_1') + iter_3_1.SetMeshName('H_1') + iter_3_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_3_1.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.00.med")) + iter_3_1.SetTimeStepRank( 1, 1) + iter_3_1.AssociateHypo('hypo_0vers1') + erreur = iter_3_1.Compute(1, option) + if erreur : + break + # + # Iteration "iter_3_2" + # ==================== + iter_3_2 = iter_3_1.NextIteration('iter_3_2') + iter_3_2.SetMeshName('H_2') + iter_3_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med")) + iter_3_2.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.01.med")) + iter_3_2.SetTimeStepRank(1, 1) + iter_3_2.AssociateHypo('hypo_1vers2') + erreur = iter_3_2.Compute(1, option) + if erreur : + break + # + # 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(os.path.join(DIRCASE, "maill.02.bis.med")) + iter_3_2_bis.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.01.med")) + iter_3_2_bis.SetTimeStepRank(1, 1) + iter_3_2_bis.AssociateHypo('hypo_1vers2_bis') + erreur = iter_3_2_bis.Compute(1, option) + if erreur : + break # - # 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__________') + break # - # 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__________') + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur + # + return erreur, message +# +#========================== Fin de la fonction ================================== +# +ERREUR = 0 +MESSAGE = "" +while not ERREUR : # - # 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) + # A. Exec of HOMARD-SALOME # - # Cas - # === - case_3 = HOMARD.CreateCase('case_3', 'G_0', DATA_TUTORIAL+'/tutorial_3.00.med') - case_3.SetDirName(DIRCASE) + HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') + assert HOMARD is not None, "Impossible to load homard engine" + HOMARD.SetLanguageShort("fr") +# + FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med") + try: + ERREUR, MESSAGE = homard_exec("G_0", FICMED, DEBUG) + except Exception, eee: + ERREUR = 2 + MESSAGE = eee.message # - # 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_TUTORIAL+'/tutorial_3.00.med') - iter_3_1.SetTimeStepRank( 1, 1) - iter_3_1.AssociateHypo('hypo_0vers1') - error = iter_3_1.Compute(1, 2) + if ERREUR : + MESSAGE += "Pb in homard_exec" + break # - # 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_TUTORIAL+'/tutorial_3.01.med') - iter_3_2.SetTimeStepRank(1, 1) - iter_3_2.AssociateHypo('hypo_1vers2') - error = iter_3_2.Compute(1, 2) + # B. Test of the results # - # 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_TUTORIAL+'/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) + N_REP_TEST_FILE = 3 + DESTROY_DIR = not DEBUG + test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) # - 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 = homard_exec(salome.myStudy) - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) -# -# Test of the results + break # -N_REP_TEST_FILE = 3 -DESTROY_DIR = not DEBUG -test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 3, 1) diff --git a/src/tests/Test/tutorial_4.py b/src/tests/Test/tutorial_4.py index 3816780d..9e05df94 100755 --- a/src/tests/Test/tutorial_4.py +++ b/src/tests/Test/tutorial_4.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_4 associe au tutorial 4 """ -__revision__ = "V4.01" +__revision__ = "V5.01" #======================================================================== TEST_NAME = "tutorial_4" @@ -52,7 +52,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # Repertoire des donnees du tutorial DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) @@ -67,97 +67,136 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(theStudy): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, xao_file, verbose=True): """ Python script for HOMARD """ - # - HOMARD.SetCurrentStudy(theStudy) + erreur = 0 + message = "" # - # Frontieres - # ========== - boun_4_1 = HOMARD.CreateBoundaryDi('intersection', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.fr.med') + while not erreur : + # + HOMARD.SetCurrentStudy(salome.myStudy) + # + # Frontières + # ========== + if verbose : + print(". Frontières") + cao_name = "CAO_" + nom + la_frontiere = HOMARD.CreateBoundaryCAO(cao_name, xao_file) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + # Creation of the hypothesis hypo_0_1 + l_hypothese_0_1 = HOMARD.CreateHypothesis('hypo_4_0_1') + l_hypothese_0_1.SetUnifRefinUnRef(1) + l_hypothese_0_1.AddGroup('IN1') + l_hypothese_0_1.AddGroup('IN2') + l_hypothese_0_1.AddGroup('T1_INT_I') + l_hypothese_0_1.AddGroup('T1_INT_O') + l_hypothese_0_1.AddGroup('T2_INT') + # Creation of the hypothesis hypo_1_2 + l_hypothese_1_2 = HOMARD.CreateHypothesis('hypo_4_1_2') + l_hypothese_1_2.SetUnifRefinUnRef(1) + l_hypothese_1_2.AddGroup('T1_EXT_I') + l_hypothese_1_2.AddGroup('T1_EXT_O') + l_hypothese_1_2.AddGroup('T2_EXT') + # Creation of the hypothesis hypo_2_3 + l_hypothese_2_3 = HOMARD.CreateHypothesis('hypo_4_2_3') + l_hypothese_2_3.SetUnifRefinUnRef(1) + l_hypothese_2_3.AddGroup('INT_I') + l_hypothese_2_3.AddGroup('INT_E') + l_hypothese_2_3.AddGroup('IN1') + l_hypothese_2_3.AddGroup('IN2') + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_'+nom, nom, ficmed) + le_cas.SetDirName(DIRCASE) + le_cas.AddBoundary(cao_name) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # Iteration iter_4_1 : raffinement selon les faces internes + iter_4_1 = le_cas.NextIteration('iter_4_1') + iter_4_1.SetMeshName('PIQUAGE_1') + iter_4_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_4_1.AssociateHypo('hypo_4_0_1') + erreur = iter_4_1.Compute(1, option) + print ("erreur = %d" % erreur) + if erreur : + break + # 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(os.path.join(DIRCASE, "maill.02.med")) + iter_4_2.AssociateHypo('hypo_4_1_2') + erreur = iter_4_2.Compute(1, option) + if erreur : + break + # 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(os.path.join(DIRCASE, "maill.03.med")) + iter_4_3.AssociateHypo('hypo_4_2_3') + erreur = iter_4_3.Compute(1, option) + if erreur : + break # - boun_4_2 = HOMARD.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.) + break # - boun_4_3 = HOMARD.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.) + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur # - boun_4_4 = HOMARD.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.) + return erreur, message +# +#========================== Fin de la fonction ================================== +# +ERREUR = 0 +MESSAGE = "" +while not ERREUR : # - boun_4_5 = HOMARD.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.) + # A. Exec of HOMARD-SALOME # - # 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') + HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') + assert HOMARD is not None, "Impossible to load homard engine" + HOMARD.SetLanguageShort("fr") +# + FICMED = os.path.join(DATA_TUTORIAL, "tutorial_4.00.med") + XAO_FILE = os.path.join(DATA_TUTORIAL, TEST_NAME+".xao") + try: + ERREUR, MESSAGE = homard_exec("PIQUAGE", FICMED, XAO_FILE, DEBUG) + except Exception, eee: + ERREUR = 2 + MESSAGE = eee.message # - # Cas - # === - case_4 = HOMARD.CreateCase('case_4', 'PIQUAGE', DATA_TUTORIAL+'/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' ) + if ERREUR : + MESSAGE += "Pb in homard_exec" + break # - # 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) + # B. Test of the results # - 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 = homard_exec(salome.myStudy) - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) -# -# Test of the results + N_REP_TEST_FILE = N_ITER_TEST_FILE + DESTROY_DIR = not DEBUG + test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) + # + break # -N_REP_TEST_FILE = N_ITER_TEST_FILE -DESTROY_DIR = not DEBUG -test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 4, 1) diff --git a/src/tests/Test/tutorial_5.py b/src/tests/Test/tutorial_5.py index 1ffd2720..afdad37e 100755 --- a/src/tests/Test/tutorial_5.py +++ b/src/tests/Test/tutorial_5.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_5 associe au tutorial 5 """ -__revision__ = "V4.01" +__revision__ = "V4.02" #======================================================================== TEST_NAME = "tutorial_5" @@ -52,7 +52,7 @@ if DEBUG : remove_dir(DIRCASE) os.mkdir(DIRCASE) else : - DIRCASE = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) # Repertoire des donnees du tutorial DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) @@ -67,81 +67,126 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(theStudy): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, nomfr, ficfrmed, verbose=False): """ Python script for HOMARD """ + erreur = 0 + message = "" +# + while not erreur : + # + HOMARD.SetCurrentStudy(salome.myStudy) + # + # Frontiere + # ========= + if verbose : + print(". Frontière") + # Creation of the discrete boundary Boun_5_1 + boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', nomfr, ficfrmed) + # + # Creation des zones + # ================== + if verbose : + print(". 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 + # ========== + if verbose : + print(". Hypothèses") + # 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 + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_5', nom, ficmed) + le_cas.SetDirName(DIRCASE) + le_cas.SetConfType(1) + le_cas.AddBoundary('Boun_5_1') + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # + # Iteration "iter_5_1" + # ==================== + iter_5_1 = le_cas.NextIteration('iter_5_1') + iter_5_1.SetMeshName('COEUR_2D_01') + iter_5_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_5_1.AssociateHypo('hypo_5') + erreur = iter_5_1.Compute(1, option) + if erreur : + break + # + # 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(os.path.join(DIRCASE, "maill.02.med")) + iter_5_2.AssociateHypo('hypo_5_bis') + erreur = iter_5_2.Compute(1, option) + if erreur : + break + # + break # - HOMARD.SetCurrentStudy(theStudy) + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur + # + return erreur, message + +#========================== Fin de la fonction ================================== # - # Frontiere - # ========= - # Creation of the discrete boundary Boun_5_1 - boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', DATA_TUTORIAL+'/tutorial_5.fr.med') +ERREUR = 0 +MESSAGE = "" +while not ERREUR : # - # 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 ) + # A. Exec of HOMARD-SALOME # - # 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) + HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') + assert HOMARD is not None, "Impossible to load homard engine" + HOMARD.SetLanguageShort("fr") +# + FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med") + FICFRMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".fr.med") + try: + ERREUR, MESSAGE = homard_exec("COEUR_2D", FICMED, "MAIL_EXT", FICFRMED, DEBUG) + except Exception, eee: + ERREUR = 2 + MESSAGE = eee.message # - # Cas - # === - case_5 = HOMARD.CreateCase('case_5', 'COEUR_2D', DATA_TUTORIAL+'/tutorial_5.00.med') - case_5.SetDirName(DIRCASE) - case_5.SetConfType(1) - case_5.AddBoundaryGroup('Boun_5_1', '') + if ERREUR : + MESSAGE += "Pb in homard_exec" + break # - # 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) + # B. Test of the results # - # 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) + N_REP_TEST_FILE = N_ITER_TEST_FILE + DESTROY_DIR = not DEBUG + test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) # - 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 = homard_exec(salome.myStudy) - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) -# -# Test of the results + break # -N_REP_TEST_FILE = N_ITER_TEST_FILE -DESTROY_DIR = not DEBUG -test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 5, 1) -- 2.39.2