1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2016 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Python script for HOMARD
22 Test tutorial_1 associe au tutorial 1
26 #========================================================================
27 TEST_NAME = "tutorial_1"
30 #========================================================================
37 # ==================================
38 PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
39 # Repertoire des scripts utilitaires
40 REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
41 REP_PYTHON = os.path.normpath(REP_PYTHON)
42 sys.path.append(REP_PYTHON)
43 from test_util import remove_dir
44 from test_util import test_results
45 # Repertoire des donnees du test
46 REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
47 REP_DATA = os.path.normpath(REP_DATA)
48 # Repertoire des resultats
50 DIRCASE = os.path.join("/tmp", TEST_NAME)
51 if ( os.path.isdir(DIRCASE) ) :
55 DIRCASE = tempfile.mkdtemp()
56 # Repertoire des donnees du tutorial
57 DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
58 DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
59 sys.path.append(DATA_TUTORIAL)
60 from tutorial_util import gzip_gunzip
61 # ==================================
62 gzip_gunzip(DATA_TUTORIAL, 1, -1)
63 # ==================================
67 IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
68 IPAR.append("AP_MODULES_LIST", "Homard")
70 #========================================================================
71 #========================================================================
72 def homard_exec(theStudy):
74 Python script for HOMARD
77 homard.SetCurrentStudy(theStudy)
81 hypo_1 = homard.CreateHypothesis('hypo_1')
82 hypo_1.SetUnifRefinUnRef(1)
86 case_1 = homard.CreateCase('case_1', 'MAILL', DATA_TUTORIAL+'/tutorial_1.00.med')
87 case_1.SetDirName(DIRCASE)
91 # Iteration "iter_1_1"
92 iter_1_1 = case_1.NextIteration('iter_1_1')
93 iter_1_1.SetMeshName('MESH')
94 iter_1_1.SetMeshFile(DIRCASE+'/maill.01.med')
95 iter_1_1.AssociateHypo('hypo_1')
96 error = iter_1_1.Compute(1, 2)
98 # Iteration "iter_1_2"
99 iter_1_2 = iter_1_1.NextIteration('iter_1_2')
100 iter_1_2.SetMeshName('MESH')
101 iter_1_2.SetMeshFile(DIRCASE+'/maill.02.med')
102 iter_1_2.AssociateHypo('hypo_1')
103 error = iter_1_2.Compute(1, 2)
105 # Iteration "iter_1_3"
106 iter_1_3 = iter_1_2.NextIteration('iter_1_3')
107 iter_1_3.SetMeshName('MESH')
108 iter_1_3.SetMeshFile(DIRCASE+'/maill.03.med')
109 iter_1_3.AssociateHypo('hypo_1')
110 error = iter_1_3.Compute(1, 2)
114 #========================================================================
116 homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
117 assert homard is not None, "Impossible to load homard engine"
118 homard.SetLanguageShort("fr")
120 # Exec of HOMARD-SALOME
123 ERROR = homard_exec(salome.myStudy)
125 raise Exception('Pb in homard_exec at iteration %d' %ERROR )
126 except Exception, eee:
127 raise Exception('Pb in homard_exec: '+eee.message)
129 # Test of the results
131 N_REP_TEST_FILE = N_ITER_TEST_FILE
132 DESTROY_DIR = not DEBUG
133 test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
135 # ==================================
136 gzip_gunzip(DATA_TUTORIAL, 1, 1)
137 # ==================================
139 if salome.sg.hasDesktop():
140 salome.sg.updateObjBrowser(1)
141 iparameters.getSession().restoreVisualState(1)