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 test_11 associe au tutorial 1
26 #========================================================================
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 remove_dir
44 from test_util import test_results
45 # Repertoire des resultats
47 dircase = os.path.join("/tmp", Test_Name)
48 if ( os.path.isdir(dircase) ) :
52 dircase = tempfile.mkdtemp()
53 # Repertoire des donnees du tutorial
54 data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
55 data_dir = os.path.normpath(data_dir)
56 sys.path.append(data_dir)
57 from tutorial_util import gzip_gunzip
58 # ==================================
59 gzip_gunzip(data_dir, 1, -1)
60 # ==================================
64 ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
65 ipar.append("AP_MODULES_LIST", "Homard")
67 #========================================================================
68 #========================================================================
69 def homard_exec(theStudy):
71 Python script for HOMARD
74 homard.SetCurrentStudy(theStudy)
78 Hypo_1 = homard.CreateHypothesis('Hypo_1')
79 Hypo_1.SetUnifRefinUnRef(1)
83 Case_1 = homard.CreateCase('Case_1', 'MAILL', data_dir+'/tutorial_1.00.med')
84 Case_1.SetDirName(dircase)
88 # Iteration "Iter_1_1"
89 Iter_1_1 = Case_1.NextIteration('Iter_1_1')
90 Iter_1_1.SetMeshName('MESH')
91 Iter_1_1.SetMeshFile(dircase+'/maill.01.med')
92 Iter_1_1.AssociateHypo('Hypo_1')
93 error = Iter_1_1.Compute(1, 2)
95 # Iteration "Iter_1_2"
96 Iter_1_2 = Iter_1_1.NextIteration('Iter_1_2')
97 Iter_1_2.SetMeshName('MESH')
98 Iter_1_2.SetMeshFile(dircase+'/maill.02.med')
99 Iter_1_2.AssociateHypo('Hypo_1')
100 error = Iter_1_2.Compute(1, 2)
102 # Iteration "Iter_1_3"
103 Iter_1_3 = Iter_1_2.NextIteration('Iter_1_3')
104 Iter_1_3.SetMeshName('MESH')
105 Iter_1_3.SetMeshFile(dircase+'/maill.03.med')
106 Iter_1_3.AssociateHypo('Hypo_1')
107 error = Iter_1_3.Compute(1, 2)
111 #========================================================================
113 homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
114 assert homard is not None, "Impossible to load homard engine"
115 homard.SetLanguageShort("fr")
117 # Exec of HOMARD-SALOME
120 error_main = homard_exec(salome.myStudy)
122 raise Exception('Pb in homard_exec at iteration %d' %error_main )
124 raise Exception('Pb in homard_exec: '+e.message)
126 # Test of the results
128 n_rep_test_file = n_iter_test_file
129 destroy_dir = not debug
130 test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir)
132 # ==================================
133 gzip_gunzip(data_dir, 1, 1)
134 # ==================================
136 if salome.sg.hasDesktop():
137 salome.sg.updateObjBrowser(1)
138 iparameters.getSession().restoreVisualState(1)