]> SALOME platform Git repositories - modules/homard.git/blob - tests/test_11.py
Salome HOME
Ajout de 5 tests qui sont les clones des 5 tutorials
[modules/homard.git] / tests / test_11.py
1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2011-2014  CEA/DEN, EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """
21 Python script for HOMARD
22 Copyright EDF-R&D 2010, 2014
23 Test test_11 associe au tutorial 1
24 """
25 __revision__ = "V2.1"
26
27 #========================================================================
28 Test_Name = "test_11"
29 n_iter_test_file = 3
30 #========================================================================
31 import os
32 import tempfile
33 import sys
34 import HOMARD
35 import salome
36 #
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()
46 os.mkdir(dircase)
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, 1, -1)
54 # ==================================
55
56 salome.salome_init()
57 import iparameters
58 ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
59 ipar.append("AP_MODULES_LIST", "Homard")
60 #
61 #========================================================================
62 #========================================================================
63 def homard_exec(theStudy):
64   """
65 Python script for HOMARD
66   """
67   #
68   homard.SetCurrentStudy(theStudy)
69   #
70   # Hypotheses
71   # ==========
72   Hypo_1 = homard.CreateHypothesis('Hypo_1')
73   Hypo_1.SetUnifRefinUnRef(1)
74   #
75   # Cas
76   # ===
77   Case_1 = homard.CreateCase('Case_1', 'MAILL', data_dir+'/tutorial_1.00.med')
78   Case_1.SetDirName(dircase)
79   Case_1.SetConfType(1)
80   #
81   # Iterations
82   # ==========
83   # Iteration "Iter_1_1"
84   Iter_1_1 = Case_1.NextIteration('Iter_1_1')
85   Iter_1_1.SetMeshName('MESH')
86   Iter_1_1.SetMeshFile(dircase+'/maill.01.med')
87   Iter_1_1.AssociateHypo('Hypo_1')
88   error = Iter_1_1.Compute(1, 2)
89
90   # Iteration "Iter_1_2"
91   Iter_1_2 = Iter_1_1.NextIteration('Iter_1_2')
92   Iter_1_2.SetMeshName('MESH')
93   Iter_1_2.SetMeshFile(dircase+'/maill.02.med')
94   Iter_1_2.AssociateHypo('Hypo_1')
95   error = Iter_1_2.Compute(1, 2)
96
97   # Iteration "Iter_1_3"
98   Iter_1_3 = Iter_1_2.NextIteration('Iter_1_3')
99   Iter_1_3.SetMeshName('MESH')
100   Iter_1_3.SetMeshFile(dircase+'/maill.03.med')
101   Iter_1_3.AssociateHypo('Hypo_1')
102   error = Iter_1_3.Compute(1, 2)
103   #
104   return error
105
106 #========================================================================
107
108 homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
109 assert homard is not None, "Impossible to load homard engine"
110 homard.SetLanguageShort("fr")
111 #
112 # Exec of HOMARD-SALOME
113 #
114 try :
115   error_main = homard_exec(salome.myStudy)
116   if error_main :
117     raise Exception('Pb in homard_exec at iteration %d' %error_main )
118 except Exception, e:
119   raise Exception('Pb in homard_exec: '+e.message)
120 #
121 # Test of the results
122 #
123 n_rep_test_file = n_iter_test_file
124 test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file)
125 #
126 # ==================================
127 gzip_gunzip(data_dir, 1, 1)
128 # ==================================
129 #
130 if salome.sg.hasDesktop():
131   salome.sg.updateObjBrowser(1)
132   iparameters.getSession().restoreVisualState(1)
133