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
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")
#
#========================================================================
#========================================================================
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():