1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2015 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_5 associe au tutorial 5
26 #========================================================================
27 TEST_NAME = "tutorial_5"
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, 5, -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 # Creation of the discrete boundary Boun_5_1
82 boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', DATA_TUTORIAL+'/tutorial_5.fr.med')
86 # Creation of the disk with hole enveloppe
87 enveloppe = HOMARD.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 )
88 # Creation of the rectangle quart_sup
89 quart_sup = HOMARD.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 )
93 # Creation of the hypothesis hypo_5
94 hypo_5 = HOMARD.CreateHypothesis('hypo_5')
95 hypo_5.AddZone('enveloppe', 1)
96 # Creation of the hypothesis hypo_5_bis
97 hypo_5_bis = HOMARD.CreateHypothesis('hypo_5_bis')
98 hypo_5_bis.AddZone('quart_sup', 1)
102 case_5 = HOMARD.CreateCase('case_5', 'COEUR_2D', DATA_TUTORIAL+'/tutorial_5.00.med')
103 case_5.SetDirName(DIRCASE)
104 case_5.SetConfType(1)
105 case_5.AddBoundaryGroup('Boun_5_1', '')
107 # Iteration "iter_5_1"
108 # ====================
109 iter_5_1 = case_5.NextIteration('iter_5_1')
110 iter_5_1.SetMeshName('COEUR_2D_01')
111 iter_5_1.SetMeshFile(DIRCASE+'/maill.01.med')
112 iter_5_1.AssociateHypo('hypo_5')
113 error = iter_5_1.Compute(1, 2)
115 # Iteration "iter_5_2"
116 # ====================
117 iter_5_2 = iter_5_1.NextIteration('iter_5_2')
118 iter_5_2.SetMeshName('COEUR_2D_02')
119 iter_5_2.SetMeshFile(DIRCASE+'/maill.02.med')
120 iter_5_2.AssociateHypo('hypo_5_bis')
121 error = iter_5_2.Compute(1, 2)
125 #========================================================================
127 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
128 assert HOMARD is not None, "Impossible to load HOMARD engine"
129 HOMARD.SetLanguageShort("fr")
131 # Exec of HOMARD-SALOME
134 ERROR = homard_exec(salome.myStudy)
136 raise Exception('Pb in homard_exec at iteration %d' %ERROR )
137 except Exception, eee:
138 raise Exception('Pb in homard_exec: '+eee.message)
140 # Test of the results
142 N_REP_TEST_FILE = N_ITER_TEST_FILE
143 DESTROY_DIR = not DEBUG
144 test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
146 # ==================================
147 gzip_gunzip(DATA_TUTORIAL, 5, 1)
148 # ==================================
150 if salome.sg.hasDesktop():
151 salome.sg.updateObjBrowser(1)
152 iparameters.getSession().restoreVisualState(1)