X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Ftests%2FTest%2Ftest_2.py;h=88beb83389544ca2b7a06c209bd0da779e4761af;hb=refs%2Ftags%2FV9_13_0b1;hp=e4120362c03f22971c832863100d0f2e2e2b79ee;hpb=f2b4cab72c1c1db82f0ee276d8588179ef4f1018;p=modules%2Fhomard.git diff --git a/src/tests/Test/test_2.py b/src/tests/Test/test_2.py index e4120362..88beb833 100755 --- a/src/tests/Test/test_2.py +++ b/src/tests/Test/test_2.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2011-2015 CEA/DEN, EDF R&D +# Copyright (C) 2011-2024 CEA, EDF # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -21,7 +21,7 @@ Python script for HOMARD Test test_2 """ -__revision__ = "V3.1" +__revision__ = "V4.05" #======================================================================== TEST_NAME = "test_2" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,29 +39,21 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD") REP_PYTHON = os.path.normpath(REP_PYTHON) sys.path.append(REP_PYTHON) -from test_util import remove_dir +from test_util import get_dir from test_util import test_results -# Repertoire des donnees du test -REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples") -REP_DATA = os.path.normpath(REP_DATA) -# Repertoire des resultats -if DEBUG : - DIRCASE = os.path.join("/tmp", TEST_NAME) - if ( os.path.isdir(DIRCASE) ) : - remove_dir(DIRCASE) - os.mkdir(DIRCASE) -else : - DIRCASE = tempfile.mkdtemp() +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== -salome.salome_init() +salome.salome_init_without_session() import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== -def homard_exec(theStudy): +def homard_exec(): """ Python script for HOMARD """ @@ -70,7 +61,7 @@ Python script for HOMARD # while not error : # - HOMARD.SetCurrentStudy(theStudy) + # HOMARD.UpdateStudy() # # Creation of the boundaries # ========================== @@ -81,35 +72,34 @@ Python script for HOMARD # ========================== # Creation of the hypothesis 1 hyponame_1 = "hypo_" + TEST_NAME + "_1" - print "-------- Creation of the hypothesis", hyponame_1 + print("-------- Creation of the hypothesis", hyponame_1) hypo_test_2_1 = HOMARD.CreateHypothesis(hyponame_1) hypo_test_2_1.SetUnifRefinUnRef(1) hypo_test_2_1.AddGroup('EG') hypo_test_2_1.AddGroup('BANDE') - print hyponame_1, " : zones utilisées :", hypo_test_2_1.GetZones() - print hyponame_1, " : champ utilisé :", hypo_test_2_1.GetFieldName() - print hyponame_1, " : composantes utilisées :", hypo_test_2_1.GetComps() + print(hyponame_1, " : zones utilisées :", hypo_test_2_1.GetZones()) + print(hyponame_1, " : champ utilisé :", hypo_test_2_1.GetFieldName()) + print(hyponame_1, " : composantes utilisées :", hypo_test_2_1.GetComps()) if ( len (hypo_test_2_1.GetFieldName()) > 0 ) : - print ".. caractéristiques de l'adaptation :", hypo_test_2_1.GetField() + print(".. caractéristiques de l'adaptation :", hypo_test_2_1.GetField()) # Creation of the hypothesis 2 hyponame_2 = "hypo_" + TEST_NAME + "_2" - print "-------- Creation of the hypothesis", hyponame_2 + print("-------- Creation of the hypothesis", hyponame_2) hypo_test_2_2 = HOMARD.CreateHypothesis(hyponame_2) hypo_test_2_2.SetUnifRefinUnRef(1) hypo_test_2_2.AddGroup('M_D') - print hyponame_2, " : zones utilisées :", hypo_test_2_2.GetZones() - print hyponame_2, " : champ utilisé :", hypo_test_2_2.GetFieldName() - print hyponame_2, " : composantes utilisées :", hypo_test_2_2.GetComps() + print(hyponame_2, " : zones utilisées :", hypo_test_2_2.GetZones()) + print(hyponame_2, " : champ utilisé :", hypo_test_2_2.GetFieldName()) + print(hyponame_2, " : composantes utilisées :", hypo_test_2_2.GetComps()) if ( len (hypo_test_2_2.GetFieldName()) > 0 ) : - print ".. caractéristiques de l'adaptation :", hypo_test_2_2.GetField() + print(".. caractéristiques de l'adaptation :", hypo_test_2_2.GetField()) # # Creation of the cases # ===================== # Creation of the case - casename = "case_" + TEST_NAME mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med') - case_test_2 = HOMARD.CreateCase(casename, 'PLAQUE_0', mesh_file) + case_test_2 = HOMARD.CreateCase(TEST_NAME, 'PLAQUE_0', mesh_file) case_test_2.SetDirName(DIRCASE) case_test_2.AddBoundaryGroup('internal_boundary', '') # @@ -154,7 +144,7 @@ Python script for HOMARD scriptfile = os.path.normpath(scriptfile) dirname = DIRCASE yacs_test_2 = case_test_2.CreateYACSSchema("YACS_test_2", scriptfile, dirname, mesh_file) - yacs_test_2.SetMaxIter(4) + yacs_test_2.SetMaxIter(N_ITER_TEST_FILE+1) yacs_test_2.SetType(1) filexml = os.path.join(DIRCASE, 'yacs_test_2.xml') error = yacs_test_2.WriteOnFile(filexml) @@ -175,11 +165,11 @@ HOMARD.SetLanguageShort("fr") # Exec of HOMARD-SALOME # try : - ERROR = homard_exec(salome.myStudy) + ERROR = homard_exec() if ERROR : raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception, eee: - raise Exception('Pb in homard_exec: '+eee.message) +except RuntimeError as eee: + raise Exception('Pb in homard_exec: '+str(eee.message)) # # Test of the results # @@ -188,6 +178,6 @@ DESTROY_DIR = not DEBUG test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) # if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) + salome.sg.updateObjBrowser() iparameters.getSession().restoreVisualState(1)