From f2b4cab72c1c1db82f0ee276d8588179ef4f1018 Mon Sep 17 00:00:00 2001 From: Gerald NICOLAS Date: Wed, 13 Jan 2016 15:03:51 +0100 Subject: [PATCH] =?utf8?q?Mise=20=C3=A0=20jour=20des=20cas-tests=20pour=20?= =?utf8?q?tenir=20compte=20des=20d=C3=A9placements?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 73 ++++++----- doc/files/tutorial_util.py | 22 ++-- src/CMakeLists.txt | 10 +- src/tests/CMakeLists.txt | 7 +- src/tests/Test/test_1.py | 211 +++++++++++++++---------------- src/tests/Test/test_11.py | 107 ++++++++-------- src/tests/Test/test_12.py | 121 +++++++++--------- src/tests/Test/test_13.py | 181 +++++++++++++-------------- src/tests/Test/test_14.py | 159 ++++++++++++------------ src/tests/Test/test_15.py | 122 +++++++++--------- src/tests/Test/test_2.py | 169 ++++++++++++------------- src/tests/Test/test_3.py | 185 ++++++++++++++-------------- src/tests/Test/test_4.py | 239 ++++++++++++++++++------------------ src/tests/Test/test_util.py | 12 +- 14 files changed, 836 insertions(+), 782 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d316ef97..de79735f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR) + PROJECT(SalomeHOMARD C CXX) # Ensure a proper linker behavior: @@ -46,6 +47,20 @@ ELSE(EXISTS ${KERNEL_ROOT_DIR}) MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR") ENDIF(EXISTS ${KERNEL_ROOT_DIR}) +# Find SALOME GUI +# =============== +SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI") +IF(EXISTS ${GUI_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeGUI REQUIRED) + SALOME_GUI_WITH_CORBA() # check whether GUI builded with CORBA + SALOME_GUI_MODE(OPTIONAL SALOME_USE_PYCONSOLE) + ADD_DEFINITIONS(${GUI_DEFINITIONS}) + INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS}) +ELSE(EXISTS ${GUI_ROOT_DIR}) + MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR") +ENDIF(EXISTS ${GUI_ROOT_DIR}) + # Platform setup # ============== INCLUDE(SalomeSetupPlatform) # From KERNEL @@ -54,13 +69,23 @@ SET(BUILD_SHARED_LIBS TRUE) # Local macros: LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files") +# additional preprocessor / compiler flags +#ADD_DEFINITIONS(-DCMAKE_BUILD) +IF(WIN32) + ADD_DEFINITIONS(-DNOGDI) +ENDIF(WIN32) + # User options # ============ OPTION(SALOME_BUILD_DOC "Generate SALOME HOMARD documentation" ON) OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) +# For salome test +# ============ IF(SALOME_BUILD_TESTS) ENABLE_TESTING() + FIND_PACKAGE(SalomeCppUnit) + SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS) ENDIF() ## @@ -83,19 +108,6 @@ IF(SALOME_BUILD_DOC) SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC) ENDIF() -# Find GUI -# =========== -SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI") -IF(EXISTS ${GUI_ROOT_DIR}) - LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files") - FIND_PACKAGE(SalomeGUI REQUIRED) - SALOME_GUI_WITH_CORBA() # check whether GUI builded with CORBA - SALOME_GUI_MODE(OPTIONAL SALOME_USE_PYCONSOLE) - ADD_DEFINITIONS(${GUI_DEFINITIONS}) - INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS}) -ELSE(EXISTS ${GUI_ROOT_DIR}) - MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR") -ENDIF(EXISTS ${GUI_ROOT_DIR}) ## ## From GUI: @@ -152,21 +164,21 @@ SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOM SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs") SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files") SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers") -SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH +SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH "Install path: SALOME scripts") -SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH +SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH "Install path: SALOME script data") -SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH +SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH "Install path: SALOME Python scripts") -SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH +SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH "Install path: SALOME application skeleton - scripts") -SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH +SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH "Install path: SALOME application skeleton - Python") SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff") -SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH +SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH "Install path: SALOME Python shared modules") -SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH - "Install path: local SALOME CMake files") +SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH + "Install path: local SALOME CMake files") SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH "Install path: local SALOME config files (obsolete, to be removed)") SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources") @@ -174,6 +186,12 @@ SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME # Specific to HOMARD: SET(SALOME_HOMARD_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/homard" CACHE PATH + "Install path: SALOME HOMARD specific data") +SET(SALOME_HOMARD_INSTALL_SAMPLES share/salome/homardsamples CACHE PATH + "Install path: SALOME HOMARD samples") +SET(SALOME_HOMARD_INSTALL_TEST ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test CACHE PATH + "Install path: SALOME HOMARD Test files") +SET(SALOME_HOMARD_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/homard" CACHE PATH "Install path: SALOME HOMARD specific data") MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS) @@ -187,21 +205,18 @@ MARK_AS_ADVANCED(SALOME_HOMARD_INSTALL_RES_DATA) SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED}) -SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) - -# Sources +SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) + +# Sources # ======== ADD_SUBDIRECTORY(idl) ADD_SUBDIRECTORY(adm_local) ADD_SUBDIRECTORY(resources) ADD_SUBDIRECTORY(src) -ADD_SUBDIRECTORY(bin) -IF(SALOME_BUILD_TESTS) - ADD_SUBDIRECTORY(tests) -ENDIF(SALOME_BUILD_TESTS) IF(SALOME_BUILD_DOC) ADD_SUBDIRECTORY(doc) +ADD_SUBDIRECTORY(bin) ENDIF(SALOME_BUILD_DOC) # Header configuration @@ -252,5 +267,5 @@ INSTALL(FILES DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}") # Install the export set for use with the install-tree -INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" +INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" FILE ${PROJECT_NAME}Targets.cmake) diff --git a/doc/files/tutorial_util.py b/doc/files/tutorial_util.py index ebad1ad1..ba4f7ada 100755 --- a/doc/files/tutorial_util.py +++ b/doc/files/tutorial_util.py @@ -21,16 +21,16 @@ Python script for HOMARD Copyright EDF-R&D 2014 """ -__revision__ = "V1.1" +__revision__ = "V1.2" 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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire +REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "resources", "homard") +REP_DATA = os.path.normpath(REP_DATA) +sys.path.append(REP_DATA) from test_util import remove_dir #======================================================================== @@ -46,14 +46,14 @@ Copyright EDF-R&D 2014 # ficloc_basis = "tutorial_%d" % num_tuto # - ok = True + erreur = 0 num = -1 # # Uncompression # if ( option == -1 ) : # - while ok : + while not erreur : num += 1 ficloc = ficloc_basis + ".%02d.med" % num nomfic = os.path.join(data_dir, ficloc) @@ -63,7 +63,7 @@ Copyright EDF-R&D 2014 if os.path.isfile(nomfic) : os.system("gunzip "+nomfic) else : - ok = False + erreur = 1 break # ficloc = ficloc_basis + ".fr.med" @@ -78,7 +78,7 @@ Copyright EDF-R&D 2014 # elif ( option == 1 ) : # - while ok : + while not erreur : num += 1 ficloc = ficloc_basis + ".%02d.med.gz" % num nomfic = os.path.join(data_dir, ficloc) @@ -88,7 +88,7 @@ Copyright EDF-R&D 2014 if os.path.isfile(nomfic) : os.system("gzip "+nomfic) else : - ok = False + erreur = 2 break # ficloc = ficloc_basis + ".fr.med.gz" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f71b030c..aad68b6e 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2015 CEA/DEN, EDF R&D +# Copyright (C) 2016 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 @@ -25,12 +25,20 @@ SET(SUBDIRS_COMMON HOMARD_I HOMARDGUI HOMARD_SWIG + tests ) SET(SUBDIRS ${SUBDIRS_COMMON} ) +# For salome test +IF(SALOME_BUILD_TESTS) + INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${SALOME_HOMARD_INSTALL_TEST} + RENAME CTestTestfile.cmake) +ENDIF(SALOME_BUILD_TESTS) + FOREACH(dir ${SUBDIRS}) ADD_SUBDIRECTORY(${dir}) ENDFOREACH(dir ${SUBDIRS}) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 1dbb4424..11b1f061 100755 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -54,4 +54,9 @@ SET(HOMARD_TEST_FILES test_15.apad.02.bilan ) -INSTALL(FILES ${HOMARD_TEST_FILES} DESTINATION ${SALOME_HOMARD_INSTALL_RES_DATA}) +# INSTALL(FILES ${HOMARD_TEST_FILES} DESTINATION ${SALOME_HOMARD_INSTALL_RES_DATA}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake + DESTINATION ${SALOME_HOMARD_INSTALL_TEST} + RENAME CTestTestfile.cmake) +INSTALL(FILES ${HOMARD_TEST_FILES} + DESTINATION ${SALOME_HOMARD_INSTALL_TEST}) \ No newline at end of file diff --git a/src/tests/Test/test_1.py b/src/tests/Test/test_1.py index 2a1d1897..0d7746c1 100755 --- a/src/tests/Test/test_1.py +++ b/src/tests/Test/test_1.py @@ -21,12 +21,12 @@ Python script for HOMARD Test test_1 """ -__revision__ = "V2.6" +__revision__ = "V3.1" #======================================================================== -Test_Name = "test_1" -debug=False -n_iter_test_file = 3 +TEST_NAME = "test_1" +DEBUG = False +N_ITER_TEST_FILE = 3 #======================================================================== import os import tempfile @@ -35,27 +35,30 @@ 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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # ================================== salome.salome_init() import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -67,15 +70,15 @@ Python script for HOMARD # while not error : # - homard.SetCurrentStudy(theStudy) + HOMARD.SetCurrentStudy(theStudy) # # Creation of the zones # ===================== - # Creation of the box Zone_1_1 - Zone_1_1 = homard.CreateZoneBox('Zone_1_1', -0.01, 1.01, -0.01, 0.4, -0.01, 0.6) + # Creation of the box zone_1_1 + zone_1_1 = HOMARD.CreateZoneBox('Zone_1_1', -0.01, 1.01, -0.01, 0.4, -0.01, 0.6) - # Creation of the sphere Zone_1_2 - Zone_1_2 = homard.CreateZoneSphere('Zone_1_2', 0.5, 0.6, 0.7, 0.75) + # Creation of the sphere zone_1_2 + zone_1_2 = HOMARD.CreateZoneSphere('Zone_1_2', 0.5, 0.6, 0.7, 0.75) # # Creation of the hypotheses # ========================== @@ -83,106 +86,106 @@ Python script for HOMARD dico["1"] = "raffinement" dico["-1"] = "deraffinement" # Creation of the hypothesis a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM - HypoName_1 = "a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM" - print "-------- Creation of the hypothesis", HypoName_1 - Hypo_1_1 = homard.CreateHypothesis(HypoName_1) - Hypo_1_1.SetField('RESU____ERRE_ELEM_SIGM__________') - Hypo_1_1.SetUseComp(0) - Hypo_1_1.AddComp('ERREST') - Hypo_1_1.SetRefinThr(3, 10.1) - Hypo_1_1.AddFieldInterp('RESU____DEPL____________________') - Hypo_1_1.AddFieldInterp('RESU____ERRE_ELEM_SIGM__________') - print HypoName_1, " : champ utilisé :", Hypo_1_1.GetFieldName() - print HypoName_1, " : composantes utilisées :", Hypo_1_1.GetComps() - if ( len (Hypo_1_1.GetFieldName()) > 0 ) : - print ".. caractéristiques de l'adaptation :", Hypo_1_1.GetField() - print HypoName_1, " : champs interpolés :", Hypo_1_1.GetFieldInterps() + hyponame_1 = "a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM" + print "-------- Creation of the hypothesis", hyponame_1 + hypo_1_1 = HOMARD.CreateHypothesis(hyponame_1) + hypo_1_1.SetField('RESU____ERRE_ELEM_SIGM__________') + hypo_1_1.SetUseComp(0) + hypo_1_1.AddComp('ERREST') + hypo_1_1.SetRefinThr(3, 10.1) + hypo_1_1.AddFieldInterp('RESU____DEPL____________________') + hypo_1_1.AddFieldInterp('RESU____ERRE_ELEM_SIGM__________') + print hyponame_1, " : champ utilisé :", hypo_1_1.GetFieldName() + print hyponame_1, " : composantes utilisées :", hypo_1_1.GetComps() + if ( len (hypo_1_1.GetFieldName()) > 0 ) : + print ".. caractéristiques de l'adaptation :", hypo_1_1.GetField() + print hyponame_1, " : champs interpolés :", hypo_1_1.GetFieldInterps() # Creation of the hypothesis Zones_1_et_2 - HypoName_2 = "Zones_1_et_2" - print "-------- Creation of the hypothesis", HypoName_2 - Zones_1_et_2 = homard.CreateHypothesis(HypoName_2) - Zones_1_et_2.AddZone('Zone_1_1', 1) - Zones_1_et_2.AddZone('Zone_1_2', 1) - laux = Zones_1_et_2.GetZones() + hyponame_2 = "Zones_1_et_2" + print "-------- Creation of the hypothesis", hyponame_2 + zones_1_et_2 = HOMARD.CreateHypothesis(hyponame_2) + zones_1_et_2.AddZone('Zone_1_1', 1) + zones_1_et_2.AddZone('Zone_1_2', 1) + laux = zones_1_et_2.GetZones() nbzone = len(laux)/2 jaux = 0 for iaux in range(nbzone) : - print HypoName_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux] + print hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux] jaux += 2 - print HypoName_2, " : champ utilisé :", Zones_1_et_2.GetFieldName() - if ( len (Zones_1_et_2.GetFieldName()) > 0 ) : - print ".. caractéristiques de l'adaptation :", Zones_1_et_2.GetField() - print HypoName_2, " : champs interpolés :", Zones_1_et_2.GetFieldInterps() + print hyponame_2, " : champ utilisé :", zones_1_et_2.GetFieldName() + if ( len (zones_1_et_2.GetFieldName()) > 0 ) : + print ".. caractéristiques de l'adaptation :", zones_1_et_2.GetField() + print hyponame_2, " : champs interpolés :", zones_1_et_2.GetFieldInterps() # # Creation of the cases # ===================== # Creation of the case - CaseName = "Case_" + Test_Name - 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(dircase) + casename = "Case_" + TEST_NAME + print "-------- Creation of the case", casename + mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med') + case_test_1 = HOMARD.CreateCase(casename, 'MAILL', mesh_file) + case_test_1.SetDirName(DIRCASE) # # Creation of the iterations # ========================== # Creation of the iteration 1 - IterName = "I_" + Test_Name + "_1" - print "-------- Creation of the iteration", IterName - Iter_test_1_1 = Case_test_1.NextIteration(IterName) - 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(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) - Iter_test_1_1.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1) - print ". Instants d'interpolation :", Iter_test_1_1.GetFieldInterpsTimeStepRank() - error = Iter_test_1_1.Compute(1, 1) + iter_name = "I_" + TEST_NAME + "_1" + print "-------- Creation of the iteration", iter_name + iter_test_1_1 = case_test_1.NextIteration(iter_name) + 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(DIRCASE, 'maill.01.med')) + iter_test_1_1.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.00.med')) + iter_test_1_1.SetTimeStepRank(1, 1) + iter_test_1_1.SetFieldInterpTimeStep('RESU____DEPL____________________', 1) + iter_test_1_1.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1) + print ". Instants d'interpolation :", iter_test_1_1.GetFieldInterpsTimeStepRank() + error = iter_test_1_1.Compute(1, 1) if error : error = 1 break # Creation of the iteration 2 - IterName = "I_" + Test_Name + "_2" - print "-------- Creation of the iteration", IterName - Iter_test_1_2 = Iter_test_1_1.NextIteration(IterName) - 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(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) - Iter_test_1_2.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1) - print ". Instants d'interpolation :", Iter_test_1_2.GetFieldInterpsTimeStepRank() - error = Iter_test_1_2.Compute(1, 1) + iter_name = "I_" + TEST_NAME + "_2" + print "-------- Creation of the iteration", iter_name + iter_test_1_2 = iter_test_1_1.NextIteration(iter_name) + 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(DIRCASE, 'maill.02.med')) + iter_test_1_2.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.01.med')) + iter_test_1_2.SetTimeStepRank(1, 1) + iter_test_1_2.SetFieldInterpTimeStep('RESU____DEPL____________________', 1) + iter_test_1_2.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1) + print ". Instants d'interpolation :", iter_test_1_2.GetFieldInterpsTimeStepRank() + error = iter_test_1_2.Compute(1, 1) if error : error = 2 break # Creation of the iteration 3 - IterName = "I_" + Test_Name + "_3" - print "-------- Creation of the iteration", IterName - Iter_test_1_3 = Iter_test_1_2.NextIteration(IterName) - 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(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) + iter_name = "I_" + TEST_NAME + "_3" + print "-------- Creation of the iteration", iter_name + iter_test_1_3 = iter_test_1_2.NextIteration(iter_name) + 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(DIRCASE, 'maill.03.med')) + iter_test_1_2.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.02.med')) + print ". Instants d'interpolation :", iter_test_1_3.GetFieldInterpsTimeStepRank() + error = iter_test_1_3.Compute(1, 1) if error : error = 3 break # # Creation of the schema YACS # =========================== - ScriptFile = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py") - ScriptFile = os.path.normpath(ScriptFile) - DirName = dircase - YACS_test_1 = Case_test_1.CreateYACSSchema("YACS_test_1", ScriptFile, DirName, MeshFile) - error = YACS_test_1.Write() + scriptfile = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py") + scriptfile = os.path.normpath(scriptfile) + dirname = DIRCASE + yacs_test_1 = case_test_1.CreateYACSSchema("YACS_test_1", scriptfile, dirname, mesh_file) + error = yacs_test_1.Write() if error : error = 4 break @@ -193,24 +196,24 @@ Python script for HOMARD #======================================================================== -homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert homard is not None, "Impossible to load homard engine" -homard.SetLanguageShort("fr") +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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, 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_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +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 salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/src/tests/Test/test_11.py b/src/tests/Test/test_11.py index 00f8770d..867f5cfc 100755 --- a/src/tests/Test/test_11.py +++ b/src/tests/Test/test_11.py @@ -21,12 +21,12 @@ Python script for HOMARD Test test_11 associe au tutorial 1 """ -__revision__ = "V2.3" +__revision__ = "V3.1" #======================================================================== -Test_Name = "test_11" -debug=False -n_iter_test_file = 3 +TEST_NAME = "test_11" +DEBUG = False +N_ITER_TEST_FILE = 3 #======================================================================== import os import tempfile @@ -35,34 +35,37 @@ 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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # 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) +DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== -gzip_gunzip(data_dir, 1, -1) +gzip_gunzip(DATA_TUTORIAL, 1, -1) # ================================== salome.salome_init() import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -75,36 +78,36 @@ Python script for HOMARD # # Hypotheses # ========== - Hypo_1 = homard.CreateHypothesis('Hypo_1') - Hypo_1.SetUnifRefinUnRef(1) + 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 = 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) + # 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_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) + # 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 @@ -117,20 +120,20 @@ 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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, 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_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +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) # # ================================== -gzip_gunzip(data_dir, 1, 1) +gzip_gunzip(DATA_TUTORIAL, 1, 1) # ================================== # if salome.sg.hasDesktop(): diff --git a/src/tests/Test/test_12.py b/src/tests/Test/test_12.py index f938775b..08230e9c 100755 --- a/src/tests/Test/test_12.py +++ b/src/tests/Test/test_12.py @@ -21,12 +21,12 @@ Python script for HOMARD Test test_12 associe au tutorial 2 """ -__revision__ = "V2.3" +__revision__ = "V3.1" #======================================================================== -Test_Name = "test_12" -debug=False -n_iter_test_file = 2 +TEST_NAME = "test_12" +DEBUG = False +N_ITER_TEST_FILE = 2 #======================================================================== import os import tempfile @@ -35,34 +35,37 @@ 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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # 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) +DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== -gzip_gunzip(data_dir, 2, -1) +gzip_gunzip(DATA_TUTORIAL, 2, -1) # ================================== salome.salome_init() import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -71,77 +74,77 @@ def homard_exec(theStudy): Python script for HOMARD """ # - homard.SetCurrentStudy(theStudy) + HOMARD.SetCurrentStudy(theStudy) # # 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) + 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) + 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) + zone_12_2 = HOMARD.CreateZoneBox ('Zone_12_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) # - # Hypothese "Hypo_2" + # Hypothese "hypo_2" # ================== - Hypo_2 = homard.CreateHypothesis('Hypo_2') - Hypo_2.AddZone('Zone_12_1', 1) - Hypo_2.AddZone('Zone_12_0', 1) + hypo_2 = HOMARD.CreateHypothesis('hypo_2') + hypo_2.AddZone('Zone_12_1', 1) + hypo_2.AddZone('Zone_12_0', 1) # - # Hypothese "Hypo_2_bis" + # 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) + 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 # === - Case_2 = homard.CreateCase('Case_2', 'MZERO', data_dir+'/tutorial_2.00.med') - Case_2.SetDirName(dircase) + case_2 = HOMARD.CreateCase('case_2', 'MZERO', DATA_TUTORIAL+'/tutorial_2.00.med') + case_2.SetDirName(DIRCASE) # - # Iteration "Iter_2_1" + # 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) + 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" + # 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) + 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") +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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, 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_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +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) # # ================================== -gzip_gunzip(data_dir, 2, 1) +gzip_gunzip(DATA_TUTORIAL, 2, 1) # ================================== # if salome.sg.hasDesktop(): diff --git a/src/tests/Test/test_13.py b/src/tests/Test/test_13.py index a904186f..14a8369a 100755 --- a/src/tests/Test/test_13.py +++ b/src/tests/Test/test_13.py @@ -21,12 +21,12 @@ Python script for HOMARD Test test_13 associe au tutorial 3 """ -__revision__ = "V2.3" +__revision__ = "V3.1" #======================================================================== -Test_Name = "test_13" -debug=False -n_iter_test_file = 2 +TEST_NAME = "test_13" +DEBUG = False +N_ITER_TEST_FILE = 2 #======================================================================== import os import tempfile @@ -35,34 +35,37 @@ 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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # 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) +DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== -gzip_gunzip(data_dir, 3, -1) +gzip_gunzip(DATA_TUTORIAL, 3, -1) # ================================== salome.salome_init() import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -71,106 +74,106 @@ def homard_exec(theStudy): Python script for HOMARD """ # - homard.SetCurrentStudy(theStudy) + HOMARD.SetCurrentStudy(theStudy) # - # Hypothese "Hypo_0vers1" + # Hypothese "hypo_0vers1" # ======================= - Hypo_0vers1 = homard.CreateHypothesis('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__________') + 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" + # Hypothese "hypo_1vers2" # ======================= - Hypo_1vers2 = homard.CreateHypothesis('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__________') + 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" + # Hypothese "hypo_1vers2_bis" # =========================== - Hypo_1vers2_bis = homard.CreateHypothesis('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) + 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) + case_3 = HOMARD.CreateCase('case_3', 'G_0', DATA_TUTORIAL+'/tutorial_3.00.med') + case_3.SetDirName(DIRCASE) # - # Iteration "Iter_3_1" + # 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) + 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) # - # Iteration "Iter_3_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) + 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) # - # Iteration "Iter_3_2_bis" + # 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) + 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) # return error #======================================================================== -homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert homard is not None, "Impossible to load homard engine" -homard.SetLanguageShort("fr") +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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, eee: + raise Exception('Pb in homard_exec: '+eee.message) # # Test of the results # -n_rep_test_file = 3 -destroy_dir = not debug -test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +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) # # ================================== -gzip_gunzip(data_dir, 3, 1) +gzip_gunzip(DATA_TUTORIAL, 3, 1) # ================================== # if salome.sg.hasDesktop(): diff --git a/src/tests/Test/test_14.py b/src/tests/Test/test_14.py index 1928ffc3..83415dee 100755 --- a/src/tests/Test/test_14.py +++ b/src/tests/Test/test_14.py @@ -21,12 +21,12 @@ Python script for HOMARD Test test_14 associe au tutorial 4 """ -__revision__ = "V2.3" +__revision__ = "V3.1" #======================================================================== -Test_Name = "test_14" -debug=False -n_iter_test_file = 3 +TEST_NAME = "test_14" +DEBUG = False +N_ITER_TEST_FILE = 3 #======================================================================== import os import tempfile @@ -35,34 +35,37 @@ 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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # 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) +DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== -gzip_gunzip(data_dir, 4, -1) +gzip_gunzip(DATA_TUTORIAL, 4, -1) # ================================== salome.salome_init() import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -71,93 +74,93 @@ def homard_exec(theStudy): Python script for HOMARD """ # - homard.SetCurrentStudy(theStudy) + HOMARD.SetCurrentStudy(theStudy) # # Frontieres # ========== - Boun_4_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', data_dir+'/tutorial_4.fr.med') + boun_4_1 = HOMARD.CreateBoundaryDi('intersection', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.fr.med') # - Boun_4_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.) + 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_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_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.) + 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') + # 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' ) + 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' ) # # 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) + # 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") +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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, 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_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +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) # # ================================== -gzip_gunzip(data_dir, 4, 1) +gzip_gunzip(DATA_TUTORIAL, 4, 1) # ================================== # if salome.sg.hasDesktop(): diff --git a/src/tests/Test/test_15.py b/src/tests/Test/test_15.py index a3164536..c116d25d 100755 --- a/src/tests/Test/test_15.py +++ b/src/tests/Test/test_15.py @@ -21,12 +21,12 @@ Python script for HOMARD Test test_15 associe au tutorial 5 """ -__revision__ = "V2.3" +__revision__ = "V3.1" #======================================================================== -Test_Name = "test_15" -debug=False -n_iter_test_file = 2 +TEST_NAME = "test_15" +DEBUG = False +N_ITER_TEST_FILE = 2 #======================================================================== import os import tempfile @@ -35,35 +35,37 @@ 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) -sys.path.append(Rep_Test) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # 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) +DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") +DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== -gzip_gunzip(data_dir, 5, -1) +gzip_gunzip(DATA_TUTORIAL, 5, -1) # ================================== salome.salome_init() import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -72,77 +74,77 @@ def homard_exec(theStudy): Python script for HOMARD """ # - homard.SetCurrentStudy(theStudy) + 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') + boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', DATA_TUTORIAL+'/tutorial_5.fr.med') # # Creation des zones # ================== # Creation of the disk with hole enveloppe - enveloppe = homard.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 ) + 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 ) + 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) + # 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(1) - Case_5.AddBoundaryGroup('Boun_5_1', '') + 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', '') # - # Iteration "Iter_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) + 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" + # 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) + 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") +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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, 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_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +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) # # ================================== -gzip_gunzip(data_dir, 5, 1) +gzip_gunzip(DATA_TUTORIAL, 5, 1) # ================================== # if salome.sg.hasDesktop(): diff --git a/src/tests/Test/test_2.py b/src/tests/Test/test_2.py index c2c2c97f..e4120362 100755 --- a/src/tests/Test/test_2.py +++ b/src/tests/Test/test_2.py @@ -21,12 +21,12 @@ Python script for HOMARD Test test_2 """ -__revision__ = "V2.5" +__revision__ = "V3.1" #======================================================================== -Test_Name = "test_2" -debug=False -n_iter_test_file = 3 +TEST_NAME = "test_2" +DEBUG = False +N_ITER_TEST_FILE = 3 #======================================================================== import os import tempfile @@ -35,27 +35,30 @@ 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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # ================================== salome.salome_init() import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -67,94 +70,94 @@ Python script for HOMARD # while not error : # - homard.SetCurrentStudy(theStudy) + HOMARD.SetCurrentStudy(theStudy) # # Creation of the boundaries # ========================== - # Creation of the discrete boundary Boundary_1 - Boundary_1 = homard.CreateBoundaryDi('internal_boundary', 'plaque', os.path.join(Rep_Test, Test_Name + '.fr.med')) + # Creation of the discrete boundary boundary_1 + boundary_1 = HOMARD.CreateBoundaryDi('internal_boundary', 'plaque', os.path.join(REP_DATA, TEST_NAME + '.fr.med')) # # Creation of the hypotheses # ========================== # Creation of the hypothesis 1 - HypoName_1 = "Hypo_" + Test_Name + "_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() - if ( len (Hypo_test_2_1.GetFieldName()) > 0 ) : - print ".. caractéristiques de l'adaptation :", Hypo_test_2_1.GetField() + hyponame_1 = "hypo_" + TEST_NAME + "_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() + if ( len (hypo_test_2_1.GetFieldName()) > 0 ) : + 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 - 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() - if ( len (Hypo_test_2_2.GetFieldName()) > 0 ) : - print ".. caractéristiques de l'adaptation :", Hypo_test_2_2.GetField() + hyponame_2 = "hypo_" + TEST_NAME + "_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() + if ( len (hypo_test_2_2.GetFieldName()) > 0 ) : + print ".. caractéristiques de l'adaptation :", hypo_test_2_2.GetField() # # Creation of the cases # ===================== # Creation of the case - 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(dircase) - Case_test_2.AddBoundaryGroup('internal_boundary', '') + 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.SetDirName(DIRCASE) + case_test_2.AddBoundaryGroup('internal_boundary', '') # # Creation of the iterations # ========================== # Creation of the iteration 1 - 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(dircase, 'maill.01.med')) - Iter_test_2_1.AssociateHypo(HypoName_1) - error = Iter_test_2_1.Compute(1, 1) + iter_name = "I_" + TEST_NAME + "_1" + iter_test_2_1 = case_test_2.NextIteration(iter_name) + iter_test_2_1.SetMeshName('PLAQUE_1') + 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 : error = 1 break # Creation of the iteration 2 - 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(dircase, 'maill.02.med')) - Iter_test_2_2.AssociateHypo(HypoName_1) - error = Iter_test_2_2.Compute(1, 1) + iter_name = "I_" + TEST_NAME + "_2" + iter_test_2_2 = iter_test_2_1.NextIteration(iter_name) + iter_test_2_2.SetMeshName('PLAQUE_2') + 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 : error = 2 break # Creation of the iteration 3 - 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(dircase, 'maill.03.med')) - Iter_test_2_3.AssociateHypo(HypoName_2) - error = Iter_test_2_3.Compute(1, 1) + iter_name = "I_" + TEST_NAME + "_3" + iter_test_2_3 = iter_test_2_2.NextIteration(iter_name) + iter_test_2_3.SetMeshName('PLAQUE_3') + 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 : error = 3 break # # Creation of the schema YACS # =========================== - ScriptFile = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py") - ScriptFile = os.path.normpath(ScriptFile) - DirName = dircase - YACS_test_2 = Case_test_2.CreateYACSSchema("YACS_test_2", ScriptFile, DirName, MeshFile) - YACS_test_2.SetMaxIter(4) - YACS_test_2.SetType(1) - filexml = os.path.join(dircase, 'YACS_test_2.xml') - error = YACS_test_2.WriteOnFile(filexml) + scriptfile = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py") + 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.SetType(1) + filexml = os.path.join(DIRCASE, 'yacs_test_2.xml') + error = yacs_test_2.WriteOnFile(filexml) if error : error = 4 break @@ -165,24 +168,24 @@ Python script for HOMARD #======================================================================== -homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert homard is not None, "Impossible to load homard engine" -homard.SetLanguageShort("fr") +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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, 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_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +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 salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/src/tests/Test/test_3.py b/src/tests/Test/test_3.py index 358a17fd..cf133325 100755 --- a/src/tests/Test/test_3.py +++ b/src/tests/Test/test_3.py @@ -21,13 +21,13 @@ Python script for HOMARD Test test_3 """ -__revision__ = "V2.4" +__revision__ = "V3.1" #======================================================================== -Test_Name = "test_3" -debug=False -n_boucle = 2 -n_iter_test_file = 2 +TEST_NAME = "test_3" +DEBUG = False +N_BOUCLE = 2 +N_ITER_TEST_FILE = 2 #======================================================================== import os import tempfile @@ -36,27 +36,30 @@ 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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # ================================== salome.salome_init() import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -67,92 +70,92 @@ Python script for HOMARD error = 0 # while not error : -# - homard.SetCurrentStudy(theStudy) + # + HOMARD.SetCurrentStudy(theStudy) # # Creation of the boundaries # ========================== # Creation of the discrete boundary - Boundary_3_1 = homard.CreateBoundaryDi('courbes', 'COURBES', os.path.join(Rep_Test, Test_Name + '.fr.med')) + boundary_3_1 = HOMARD.CreateBoundaryDi('courbes', 'COURBES', os.path.join(REP_DATA, TEST_NAME + '.fr.med')) # # Creation of the external cylinder - Boundary_3_2 = homard.CreateBoundaryCylinder('cyl_ext', 50.0, 25., -25., 1., 0., 0., 100.) + boundary_3_2 = HOMARD.CreateBoundaryCylinder('cyl_ext', 50.0, 25., -25., 1., 0., 0., 100.) # # Creation of the internal cylinder - Boundary_3_3 = homard.CreateBoundaryCylinder('cyl_int', 50.0, 25., -25., 1., 0., 0., 50.) + boundary_3_3 = HOMARD.CreateBoundaryCylinder('cyl_int', 50.0, 25., -25., 1., 0., 0., 50.) # # Creation of the first sphere - Boundary_3_4 = homard.CreateBoundarySphere('sphere_1', 50.0, 25., -25., 100.) + boundary_3_4 = HOMARD.CreateBoundarySphere('sphere_1', 50.0, 25., -25., 100.) # # Creation of the second sphere - Boundary_3_5 = homard.CreateBoundarySphere('sphere_2', 450.0, 25., -25., 100.) + boundary_3_5 = HOMARD.CreateBoundarySphere('sphere_2', 450.0, 25., -25., 100.) # # Creation of the hypotheses # ========================== # Uniform refinement - HypoName = "Hypo_" + Test_Name - print "-------- Creation of the hypothesis", HypoName - Hypo_test_3 = homard.CreateHypothesis(HypoName) - Hypo_test_3.SetUnifRefinUnRef(1) - print HypoName, " : zones utilisées :", Hypo_test_3.GetZones() - print HypoName, " : champ utilisé :", Hypo_test_3.GetFieldName() - print HypoName, " : composantes utilisées :", Hypo_test_3.GetComps() + hyponame = "hypo_" + TEST_NAME + print "-------- Creation of the hypothesis", hyponame + hypo_test_3 = HOMARD.CreateHypothesis(hyponame) + hypo_test_3.SetUnifRefinUnRef(1) + print hyponame, " : zones utilisées :", hypo_test_3.GetZones() + print hyponame, " : champ utilisé :", hypo_test_3.GetFieldName() + print hyponame, " : composantes utilisées :", hypo_test_3.GetComps() # - for num in range (n_boucle+1) : + for num in range (N_BOUCLE+1) : # print "-------- num =", num, "--------" # - # Creation of the case Case_test_3 + # Creation of the case case_test_3 # =========================== if ( num <= 1 ) : - CaseName = "Case_" + Test_Name - 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(dircase) - Case_test_3.AddBoundaryGroup('courbes', '') - Case_test_3.AddBoundaryGroup('cyl_ext', 'EXT') - Case_test_3.AddBoundaryGroup('cyl_int', 'INT') - Case_test_3.AddBoundaryGroup('sphere_1', 'END_1') - Case_test_3.AddBoundaryGroup('sphere_2', 'END_2') + casename = "case_" + TEST_NAME + print "-------- Creation of the case", casename + mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med') + case_test_3 = HOMARD.CreateCase(casename, 'MOYEU', mesh_file) + case_test_3.SetDirName(DIRCASE) + case_test_3.AddBoundaryGroup('courbes', '') + case_test_3.AddBoundaryGroup('cyl_ext', 'EXT') + case_test_3.AddBoundaryGroup('cyl_int', 'INT') + case_test_3.AddBoundaryGroup('sphere_1', 'END_1') + case_test_3.AddBoundaryGroup('sphere_2', 'END_2') # # Creation of the iterations # ========================== # Creation of the iteration 1 - IterName = "I_" + Test_Name + "_1" - 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(dircase, 'maill.01.med')) - Iter_test_3_1.AssociateHypo('Hypo_test_3') - error = Iter_test_3_1.Compute(1, 1) + iter_name = "I_" + TEST_NAME + "_1" + print "-------- Creation of the iteration", iter_name + iter_test_3_1 = case_test_3.NextIteration(iter_name) + iter_test_3_1.SetMeshName('MOYEU_1') + 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 : error = 10*num + 1 break # Creation of the iteration 2 - IterName = "I_" + Test_Name + "_2" - 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(dircase, 'maill.02.med')) - Iter_test_3_2.AssociateHypo('Hypo_test_3') - error = Iter_test_3_2.Compute(1, 1) + iter_name = "I_" + TEST_NAME + "_2" + print "-------- Creation of the iteration", iter_name + iter_test_3_2 = iter_test_3_1.NextIteration(iter_name) + iter_test_3_2.SetMeshName('MOYEU_2') + 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 : error = 10*num + 2 break # # Creation of the schema YACS # =========================== - ScriptFile = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py") - ScriptFile = os.path.normpath(ScriptFile) - DirName = dircase - YACSName = "YACS_" + Test_Name - print "-------- Creation of the schema", YACSName - YACS_test_3 = Case_test_3.CreateYACSSchema(YACSName, ScriptFile, DirName, MeshFile) - YACS_test_3.SetType(2) - YACS_test_3.SetMaxIter(2) - error = YACS_test_3.Write() + scriptfile = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py") + scriptfile = os.path.normpath(scriptfile) + dirname = DIRCASE + yacsname = "YACS_" + TEST_NAME + print "-------- Creation of the schema", yacsname + yacs_test_3 = case_test_3.CreateYACSSchema(yacsname, scriptfile, dirname, mesh_file) + yacs_test_3.SetType(2) + yacs_test_3.SetMaxIter(2) + error = yacs_test_3.Write() if error : error = 10*num + 5 break @@ -160,38 +163,38 @@ Python script for HOMARD # Destructions # ============ # Destruction of the schema, sauf a la fin - if ( num < n_boucle ) : - print "-------- Destruction of the schema", YACS_test_3.GetName() - error = YACS_test_3.Delete(1) + if ( num < N_BOUCLE ) : + print "-------- Destruction of the schema", yacs_test_3.GetName() + error = yacs_test_3.Delete(1) if error : error = 10*num + 6 break # After the first loop, the case is deleted, except the final mesh files # All the iterations are deleted if ( num == 0 ) : - print "-------- Destruction of the case", Case_test_3.GetName() - error = Case_test_3.Delete(0) + print "-------- Destruction of the case", case_test_3.GetName() + error = case_test_3.Delete(0) if error : break # After the second loop, the iterations are deleted, with the final mesh files elif ( num == 1 ) : # Recursive destruction of the iterations - print "-------- Recursive destruction of the iteration", Iter_test_3_1.GetName() - error = Iter_test_3_1.Delete(1) + print "-------- Recursive destruction of the iteration", iter_test_3_1.GetName() + error = iter_test_3_1.Delete(1) if error : error = 10*num + 3 break # Destruction and creation of the hypothese if ( num == 1 ) : - print "-------- Destruction of the hypothese", Hypo_test_3.GetName() - error = Hypo_test_3.Delete() + print "-------- Destruction of the hypothese", hypo_test_3.GetName() + error = hypo_test_3.Delete() if error : error = 10*num + 4 break - HypoName = "Hypo_test_3" - print "-------- Creation of the hypothesis", HypoName - Hypo_test_3 = homard.CreateHypothesis(HypoName) - Hypo_test_3.SetUnifRefinUnRef(1) + hyponame = "hypo_test_3" + print "-------- Creation of the hypothesis", hyponame + hypo_test_3 = HOMARD.CreateHypothesis(hyponame) + hypo_test_3.SetUnifRefinUnRef(1) # break # @@ -199,24 +202,24 @@ Python script for HOMARD #======================================================================== -homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert homard is not None, "Impossible to load homard engine" -homard.SetLanguageShort("fr") +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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, eee: + raise Exception('Pb in homard_exec: '+eee.message) # # Test of the results # -n_rep_test_file = n_iter_test_file*n_boucle -destroy_dir = not debug -test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +N_REP_TEST_FILE = N_ITER_TEST_FILE*N_BOUCLE +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) diff --git a/src/tests/Test/test_4.py b/src/tests/Test/test_4.py index 99585010..c2ec0752 100755 --- a/src/tests/Test/test_4.py +++ b/src/tests/Test/test_4.py @@ -21,12 +21,12 @@ Python script for HOMARD Test test_4 """ -__revision__ = "V1.0" +__revision__ = "V2.1" #======================================================================== -Test_Name = "test_4" -debug=False -n_iter_test_file = 3 +TEST_NAME = "test_4" +DEBUG = False +N_ITER_TEST_FILE = 3 DX = 600. DY = 400. DZ = 200. @@ -43,21 +43,24 @@ import MEDCoupling as mc import MEDLoader as ml # # ================================== -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) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 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) +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) else : - dircase = tempfile.mkdtemp() + DIRCASE = tempfile.mkdtemp() # ================================== salome.salome_init() @@ -71,8 +74,8 @@ from MEDLoader import MEDLoader from MEDCouplingRemapper import MEDCouplingRemapper import iparameters -ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) -ipar.append("AP_MODULES_LIST", "Homard") +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") # #======================================================================== #======================================================================== @@ -88,34 +91,34 @@ Python script for GEOM and SMESH # # Creation of the box # =================== - BOX = geompy.MakeBoxDXDYDZ(DX, DY, DZ, "BOX") + box_g = geompy.MakeBoxDXDYDZ(DX, DY, DZ, "BOX") # Creation of the mesh # ==================== smesh = smeshBuilder.New(theStudy) - MESH = smesh.Mesh(BOX) - smesh.SetName(MESH.GetMesh(), 'MESH') + box_m = smesh.Mesh(box_g) + smesh.SetName(box_m.GetMesh(), 'MESH') # # Creation of the hypotheses # ========================== - Regular_1D = MESH.Segment() - smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') - Length = min(DX, DY, DZ) / 5. - Local_Length = Regular_1D.LocalLength(Length,None,1e-07) - smesh.SetName(Local_Length, 'Local Length') + regular_1d = box_m.Segment() + smesh.SetName(regular_1d.GetAlgorithm(), 'Regular_1D') + length = min(DX, DY, DZ) / 5. + local_length = regular_1d.LocalLength(length, None, 1e-07) + smesh.SetName(local_length, 'Local Length') # - Quadrangle_2D = MESH.Quadrangle(algo=smeshBuilder.QUADRANGLE) - smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') - Quadrangle_Parameters = Quadrangle_2D.QuadrangleParameters(StdMeshersBuilder.QUAD_STANDARD,-1,[],[]) - smesh.SetName(Quadrangle_Parameters, 'Quadrangle Parameters') + quadrangle_2d = box_m.Quadrangle(algo=smeshBuilder.QUADRANGLE) + smesh.SetName(quadrangle_2d.GetAlgorithm(), 'Quadrangle_2D') + quadrangle_parameters = quadrangle_2d.QuadrangleParameters(StdMeshersBuilder.QUAD_STANDARD, -1, [], []) + smesh.SetName(quadrangle_parameters, 'Quadrangle Parameters') # - Hexa_3D = MESH.Hexahedron(algo=smeshBuilder.Hexa) - smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D') + hexa_3d = box_m.Hexahedron(algo=smeshBuilder.Hexa) + smesh.SetName(hexa_3d.GetAlgorithm(), 'Hexa_3D') # # Computation # =========== # - isDone = MESH.Compute() + isDone = box_m.Compute() if not isDone : error = 1 break @@ -124,11 +127,11 @@ Python script for GEOM and SMESH # =============== # try: - ficmed = os.path.join(dircase, 'maill.00.med') - MESH.ExportMED( ficmed, 0, SMESH.MED_V2_2, 1, None ,1) - except Exception, e: - raise Exception('ExportToMEDX() failed. '+e.message) + ficmed = os.path.join(DIRCASE, 'maill.00.med') + box_m.ExportMED( ficmed, 0, SMESH.MED_V2_2, 1, None, 1) + except Exception, eee: error = 2 + raise Exception('ExportToMEDX() failed. '+eee.message) # break # @@ -147,7 +150,7 @@ Python script for MEDCoupling # # The mesh # ======== - ficmed = os.path.join(dircase, 'maill.%02d.med' % niter) + ficmed = os.path.join(DIRCASE, 'maill.%02d.med' % niter) meshMEDFileRead = ml.MEDFileMesh.New(ficmed) meshRead0 = meshMEDFileRead.getMeshAtLevel(0) # Valeurs of the field @@ -191,98 +194,98 @@ Python script for HOMARD # while not error : # - homard.SetCurrentStudy(theStudy) + HOMARD.SetCurrentStudy(theStudy) # # Creation of the zones # ===================== # epsilon = min(DX, DY, DZ) / 100. - # Creation of the box Zone_4_1 - Zone_4_1 = homard.CreateZoneBox('Zone_4_1', -epsilon, DX/3.+epsilon, DY/4.-epsilon, 3.*DY/4.+epsilon, 4.*DZ/5.-epsilon, DZ+epsilon) + # Creation of the box zone_4_1 + zone_4_1 = HOMARD.CreateZoneBox('Zone_4_1', -epsilon, DX/3.+epsilon, DY/4.-epsilon, 3.*DY/4.+epsilon, 4.*DZ/5.-epsilon, DZ+epsilon) - # Creation of the sphere Zone_4_2 + # Creation of the sphere zone_4_2 rayon = min(DX, DY, DZ) / 4. - Zone_4_2 = homard.CreateZoneSphere('Zone_4_2', DX/3., DY*0.3, DZ*0.6, rayon) + zone_4_2 = HOMARD.CreateZoneSphere('Zone_4_2', DX/3., DY*0.3, DZ*0.6, rayon) # # Creation of the hypotheses # ========================== dico = {} dico["1"] = "raffinement" dico["-1"] = "deraffinement" - # Creation of the hypothesis Hypo_4_1 - HypoName_1 = "Zone_1" - print "-------- Creation of the hypothesis", HypoName_1 - Hypo_4_1 = homard.CreateHypothesis(HypoName_1) - Hypo_4_1.AddZone('Zone_4_1', 1) - Hypo_4_1.SetExtraOutput(2) - laux = Hypo_4_1.GetZones() + # Creation of the hypothesis hypo_4_1 + hyponame_1 = "Zone_1" + print "-------- Creation of the hypothesis", hyponame_1 + hypo_4_1 = HOMARD.CreateHypothesis(hyponame_1) + hypo_4_1.AddZone('Zone_4_1', 1) + hypo_4_1.SetExtraOutput(2) + laux = hypo_4_1.GetZones() nbzone = len(laux)/2 jaux = 0 for iaux in range(nbzone) : - print HypoName_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux] + print hyponame_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux] jaux += 2 - # Creation of the hypothesis Hypo_4_2 - HypoName_2 = "Zone_2" - print "-------- Creation of the hypothesis", HypoName_2 - Hypo_4_2 = homard.CreateHypothesis(HypoName_2) - Hypo_4_2.AddZone('Zone_4_2', 1) - Hypo_4_2.SetExtraOutput(2) - laux = Hypo_4_2.GetZones() + # Creation of the hypothesis hypo_4_2 + hyponame_2 = "Zone_2" + print "-------- Creation of the hypothesis", hyponame_2 + hypo_4_2 = HOMARD.CreateHypothesis(hyponame_2) + hypo_4_2.AddZone('Zone_4_2', 1) + hypo_4_2.SetExtraOutput(2) + laux = hypo_4_2.GetZones() nbzone = len(laux)/2 jaux = 0 for iaux in range(nbzone) : - print HypoName_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux] + print hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux] jaux += 2 # Creation of the hypothesis DISTANCE INVERSE - HypoName_3 = "DISTANCE INVERSE" - print "-------- Creation of the hypothesis", HypoName_3 - Hypo_4_3 = homard.CreateHypothesis(HypoName_3) - Hypo_4_3.SetField('DISTANCE') - Hypo_4_3.SetUseComp(0) - Hypo_4_3.SetRefinThr(1, 0.3) - Hypo_4_3.SetUnRefThr(1, 0.2) - Hypo_4_3.AddFieldInterp('DISTANCE') - Hypo_4_3.SetExtraOutput(2) - print HypoName_3, " : zones utilisées :", Hypo_4_3.GetZones() - print HypoName_3, " : champ utilisé :", Hypo_4_3.GetFieldName() - print HypoName_3, " : composantes utilisées :", Hypo_4_3.GetComps() - if ( len (Hypo_4_3.GetFieldName()) > 0 ) : - print ".. caractéristiques de l'adaptation :", Hypo_4_3.GetField() - print HypoName_3, " : champs interpolés :", Hypo_4_3.GetFieldInterps() + hyponame_3 = "DISTANCE INVERSE" + print "-------- Creation of the hypothesis", hyponame_3 + hypo_4_3 = HOMARD.CreateHypothesis(hyponame_3) + hypo_4_3.SetField('DISTANCE') + hypo_4_3.SetUseComp(0) + hypo_4_3.SetRefinThr(1, 0.3) + hypo_4_3.SetUnRefThr(1, 0.2) + hypo_4_3.AddFieldInterp('DISTANCE') + hypo_4_3.SetExtraOutput(2) + print hyponame_3, " : zones utilisées :", hypo_4_3.GetZones() + print hyponame_3, " : champ utilisé :", hypo_4_3.GetFieldName() + print hyponame_3, " : composantes utilisées :", hypo_4_3.GetComps() + if ( len (hypo_4_3.GetFieldName()) > 0 ) : + print ".. caractéristiques de l'adaptation :", hypo_4_3.GetField() + print hyponame_3, " : champs interpolés :", hypo_4_3.GetFieldInterps() # # Creation of the cases # ===================== # Creation of the case - CaseName = "Case_" + Test_Name - print "-------- Creation of the case", CaseName - MeshFile = os.path.join(dircase, 'maill.00.med') - Case_test_4 = homard.CreateCase(CaseName, 'MESH', MeshFile) - Case_test_4.SetDirName(dircase) + casename = "case_" + TEST_NAME + print "-------- Creation of the case", casename + mesh_file = os.path.join(DIRCASE, 'maill.00.med') + case_test_4 = HOMARD.CreateCase(casename, 'MESH', mesh_file) + case_test_4.SetDirName(DIRCASE) # # Creation of the iterations # ========================== # Creation of the iteration 1 - IterName = "I_" + Test_Name + "_1" - print "-------- Creation of the iteration", IterName - Iter_test_4_1 = Case_test_4.NextIteration(IterName) - Iter_test_4_1.AssociateHypo(HypoName_1) - print ". Hypothese :", HypoName_1 - Iter_test_4_1.SetMeshName('M1') - Iter_test_4_1.SetMeshFile(os.path.join(dircase, 'maill.01.med')) - error = Iter_test_4_1.Compute(1, 2) + iter_name = "I_" + TEST_NAME + "_1" + print "-------- Creation of the iteration", iter_name + iter_test_4_1 = case_test_4.NextIteration(iter_name) + iter_test_4_1.AssociateHypo(hyponame_1) + print ". Hypothese :", hyponame_1 + iter_test_4_1.SetMeshName('M1') + iter_test_4_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med')) + error = iter_test_4_1.Compute(1, 2) if error : error = 1 break # Creation of the iteration 2 - IterName = "I_" + Test_Name + "_2" - print "-------- Creation of the iteration", IterName - Iter_test_4_2 = Iter_test_4_1.NextIteration(IterName) - Iter_test_4_2.AssociateHypo(HypoName_2) - print ". Hypothese :", HypoName_2 - Iter_test_4_2.SetMeshName('M2') - Iter_test_4_2.SetMeshFile(os.path.join(dircase, 'maill.02.med')) - error = Iter_test_4_2.Compute(1, 2) + iter_name = "I_" + TEST_NAME + "_2" + print "-------- Creation of the iteration", iter_name + iter_test_4_2 = iter_test_4_1.NextIteration(iter_name) + iter_test_4_2.AssociateHypo(hyponame_2) + print ". Hypothese :", hyponame_2 + iter_test_4_2.SetMeshName('M2') + iter_test_4_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med')) + error = iter_test_4_2.Compute(1, 2) if error : error = 2 break @@ -294,15 +297,15 @@ Python script for HOMARD error = 30 break # - IterName = "I_" + Test_Name + "_3" - print "-------- Creation of the iteration", IterName - Iter_test_4_3 = Iter_test_4_2.NextIteration(IterName) - Iter_test_4_3.AssociateHypo(HypoName_3) - print ". Hypothese :", HypoName_3 - Iter_test_4_3.SetMeshName('M3') - Iter_test_4_3.SetFieldFile(os.path.join(dircase, 'maill.02.med')) - Iter_test_4_3.SetMeshFile(os.path.join(dircase, 'maill.03.med')) - error = Iter_test_4_3.Compute(1, 2) + iter_name = "I_" + TEST_NAME + "_3" + print "-------- Creation of the iteration", iter_name + iter_test_4_3 = iter_test_4_2.NextIteration(iter_name) + iter_test_4_3.AssociateHypo(hyponame_3) + print ". Hypothese :", hyponame_3 + iter_test_4_3.SetMeshName('M3') + iter_test_4_3.SetFieldFile(os.path.join(DIRCASE, 'maill.02.med')) + iter_test_4_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med')) + error = iter_test_4_3.Compute(1, 2) if error : error = 3 break @@ -316,30 +319,30 @@ Python script for HOMARD # Geometry and Mesh # try : - error_main = geom_smesh_exec(salome.myStudy) - if error_main : + ERROR = geom_smesh_exec(salome.myStudy) + if ERROR : raise Exception('Pb in geom_smesh_exec') -except Exception, e: - raise Exception('Pb in geom_smesh_exec: '+e.message) +except Exception, eee: + raise Exception('Pb in geom_smesh_exec: '+eee.message) -homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert homard is not None, "Impossible to load homard engine" -homard.SetLanguageShort("fr") +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) + ERROR = homard_exec(salome.myStudy) + if ERROR : + raise Exception('Pb in homard_exec at iteration %d' %ERROR ) +except Exception, 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_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir) +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 salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/src/tests/Test/test_util.py b/src/tests/Test/test_util.py index e5723983..baef9ad9 100755 --- a/src/tests/Test/test_util.py +++ b/src/tests/Test/test_util.py @@ -20,9 +20,9 @@ """ Python script for HOMARD Copyright EDF-R&D 2014 -Test test_1 +Utilitaires pour les tests """ -__revision__ = "V1.2" +__revision__ = "V1.3" import os #======================================================================== @@ -46,11 +46,11 @@ Copyright EDF-R&D 2013 # #======================================================================== #======================================================================== -def test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir = True) : +def test_results(rep_test, test_name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir = True) : """ Test of the result -Rep_Test: repertoire des tests -Test_Name: nom du test +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 @@ -61,7 +61,7 @@ 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) + 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") -- 2.30.2