1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2011-2014 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 Copyright EDF-R&D 2010, 2014
23 Test test_11 associe au tutorial 2
27 #========================================================================
30 #========================================================================
37 # ==================================
38 pathHomard = os.getenv('HOMARD_ROOT_DIR')
39 # Repertoire des donnees du test
40 Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard")
41 Rep_Test = os.path.normpath(Rep_Test)
42 sys.path.append(Rep_Test)
43 from test_util import test_results
44 # Repertoire des resultats
45 dircase = tempfile.mktemp()
47 # Repertoire des donnees du tutorial
48 data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
49 data_dir = os.path.normpath(data_dir)
50 sys.path.append(data_dir)
51 from tutorial_util import gzip_gunzip
52 # ==================================
53 gzip_gunzip(data_dir, 2, -1)
54 # ==================================
58 ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
59 ipar.append("AP_MODULES_LIST", "Homard")
61 #========================================================================
62 #========================================================================
63 def homard_exec(theStudy):
65 Python script for HOMARD
68 homard.SetCurrentStudy(theStudy)
73 Zone_0 = homard.CreateZoneBox ('Zone_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
76 Zone_1 = homard.CreateZoneSphere ('Zone_1', 0., 0., 0., 1.05)
79 Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
83 Hypo_2 = homard.CreateHypothesis('Hypo_2')
84 Hypo_2.AddZone('Zone_1', 1)
85 Hypo_2.AddZone('Zone_0', 1)
87 # Hypothese "Hypo_2_bis"
88 # ======================
89 Hypo_2_bis = homard.CreateHypothesis('Hypo_2_bis')
90 Hypo_2_bis.AddZone('Zone_0', -1)
91 Hypo_2_bis.AddZone('Zone_2', 1)
95 Case_2 = homard.CreateCase('Case_2', 'MZERO', data_dir+'/tutorial_2.00.med')
96 Case_2.SetDirName(dircase)
98 # Iteration "Iter_2_1"
99 # ====================
100 Iter_2_1 = Case_2.NextIteration('Iter_2_1')
101 Iter_2_1.SetMeshName('M_1')
102 Iter_2_1.SetMeshFile(dircase+'/maill.01.med')
103 Iter_2_1.AssociateHypo('Hypo_2')
104 error = Iter_2_1.Compute(1, 2)
106 # Iteration "Iter_2_2"
107 # ====================
108 Iter_2_2 = Iter_2_1.NextIteration('Iter_2_2')
109 Iter_2_2.SetMeshName('M_2')
110 Iter_2_2.SetMeshFile(dircase+'/maill.02.med')
111 Iter_2_2.AssociateHypo('Hypo_2_bis')
112 error = Iter_2_2.Compute(1, 2)
116 #========================================================================
118 homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
119 assert homard is not None, "Impossible to load homard engine"
120 homard.SetLanguageShort("fr")
122 # Exec of HOMARD-SALOME
125 error_main = homard_exec(salome.myStudy)
127 raise Exception('Pb in homard_exec at iteration %d' %error_main )
129 raise Exception('Pb in homard_exec: '+e.message)
131 # Test of the results
133 n_rep_test_file = n_iter_test_file
134 test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file)
136 # ==================================
137 gzip_gunzip(data_dir, 2, 1)
138 # ==================================
140 if salome.sg.hasDesktop():
141 salome.sg.updateObjBrowser(1)
142 iparameters.getSession().restoreVisualState(1)