]> SALOME platform Git repositories - modules/homard.git/blob - src/tests/Test/test_14.py
Salome HOME
Séparation entre les pythons et les données des tests
[modules/homard.git] / src / tests / Test / test_14.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2015  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 Test test_14 associe au tutorial 4
23 """
24 __revision__ = "V2.3"
25
26 #========================================================================
27 Test_Name = "test_14"
28 debug=False
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 remove_dir
44 from test_util import test_results
45 # Repertoire des resultats
46 if debug :
47   dircase = os.path.join("/tmp", Test_Name)
48   if ( os.path.isdir(dircase) ) :
49     remove_dir(dircase)
50   os.mkdir(dircase)
51 else :
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, 4, -1)
60 # ==================================
61
62 salome.salome_init()
63 import iparameters
64 ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
65 ipar.append("AP_MODULES_LIST", "Homard")
66 #
67 #========================================================================
68 #========================================================================
69 def homard_exec(theStudy):
70   """
71 Python script for HOMARD
72   """
73   #
74   homard.SetCurrentStudy(theStudy)
75 #
76   # Frontieres
77   # ==========
78   Boun_4_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', data_dir+'/tutorial_4.fr.med')
79   #
80   Boun_4_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
81   #
82   Boun_4_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
83   #
84   Boun_4_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
85   #
86   Boun_4_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
87   #
88   # Hypotheses
89   # ==========
90   # Creation of the hypothesis Hypo_4
91   Hypo_4 = homard.CreateHypothesis('Hypo_4')
92   Hypo_4.SetUnifRefinUnRef(1)
93   Hypo_4.AddGroup('T1_INT_I')
94   Hypo_4.AddGroup('T1_INT_O')
95   Hypo_4.AddGroup('T2_INT')
96   # Creation of the hypothesis Hypo_4_bis
97   Hypo_4_bis = homard.CreateHypothesis('Hypo_4_bis')
98   Hypo_4_bis.SetUnifRefinUnRef(1)
99   Hypo_4_bis.AddGroup('T1_EXT_I')
100   Hypo_4_bis.AddGroup('T1_EXT_O')
101   Hypo_4_bis.AddGroup('T2_EXT')
102   #
103   # Cas
104   # ===
105   Case_4 = homard.CreateCase('Case_4', 'PIQUAGE', data_dir+'/tutorial_4.00.med')
106   Case_4.SetDirName(dircase)
107   Case_4.AddBoundaryGroup( 'intersection', '' )
108   Case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
109   Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
110   Case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
111   Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
112   Case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
113   Case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
114   #
115   # Iterations
116   # ==========
117   # Iteration Iter_4_1 : raffinement selon les faces internes
118   Iter_4_1 = Case_4.NextIteration('Iter_4_1')
119   Iter_4_1.SetMeshName('PIQUAGE_1')
120   Iter_4_1.SetMeshFile(dircase+'/maill.01.med')
121   Iter_4_1.AssociateHypo('Hypo_4')
122   error = Iter_4_1.Compute(1, 2)
123   # Iteration Iter_4_2 : raffinement selon les faces externes
124   Iter_4_2 = Iter_4_1.NextIteration('Iter_4_2')
125   Iter_4_2.SetMeshName('PIQUAGE_2')
126   Iter_4_2.SetMeshFile(dircase+'/maill.02.med')
127   Iter_4_2.AssociateHypo('Hypo_4_bis')
128   error = Iter_4_2.Compute(1, 2)
129   # Iteration Iter_4_3 : second raffinement selon les faces externes
130   Iter_4_3 = Iter_4_2.NextIteration('Iter_4_3')
131   Iter_4_3.SetMeshName('PIQUAGE_3')
132   Iter_4_3.SetMeshFile(dircase+'/maill.03.med')
133   Iter_4_3.AssociateHypo('Hypo_4_bis')
134   error = Iter_4_3.Compute(1, 2)
135   #
136   return error
137
138 #========================================================================
139
140 homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
141 assert homard is not None, "Impossible to load homard engine"
142 homard.SetLanguageShort("fr")
143 #
144 # Exec of HOMARD-SALOME
145 #
146 try :
147   error_main = homard_exec(salome.myStudy)
148   if error_main :
149     raise Exception('Pb in homard_exec at iteration %d' %error_main )
150 except Exception, e:
151   raise Exception('Pb in homard_exec: '+e.message)
152 #
153 # Test of the results
154 #
155 n_rep_test_file = n_iter_test_file
156 destroy_dir = not debug
157 test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir)
158 #
159 # ==================================
160 gzip_gunzip(data_dir, 4, 1)
161 # ==================================
162 #
163 if salome.sg.hasDesktop():
164   salome.sg.updateObjBrowser(1)
165   iparameters.getSession().restoreVisualState(1)
166