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