1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2016 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_6 associe au tutorial 6
24 __revision__ = "V4.02"
26 #========================================================================
27 TEST_NAME = "tutorial_6"
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(prefix=TEST_NAME)
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, 4, -1)
63 gzip_gunzip(DATA_TUTORIAL, 6, -1)
64 # ==================================
68 IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
69 IPAR.append("AP_MODULES_LIST", "Homard")
72 #========================= Debut de la fonction ==================================
74 def homard_exec(nom, ficmed, nomfr, ficfrmed, verbose=False):
76 Python script for HOMARD
83 HOMARD.SetCurrentStudy(salome.myStudy)
89 boun_6_1 = HOMARD.CreateBoundaryDi('intersection', nomfr, ficfrmed)
91 boun_6_2 = HOMARD.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
93 boun_6_3 = HOMARD.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
95 boun_6_6 = HOMARD.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
97 boun_6_5 = HOMARD.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
102 print(". Hypothèses")
103 # Creation of the hypothesis hypo_0_1
104 l_hypothese_0_1 = HOMARD.CreateHypothesis('hypo_6_0_1')
105 l_hypothese_0_1.SetUnifRefinUnRef(1)
106 l_hypothese_0_1.AddGroup('IN1')
107 l_hypothese_0_1.AddGroup('IN2')
108 l_hypothese_0_1.AddGroup('T1_INT_I')
109 l_hypothese_0_1.AddGroup('T1_INT_O')
110 l_hypothese_0_1.AddGroup('T2_INT')
111 # Creation of the hypothesis hypo_1_2
112 l_hypothese_1_2 = HOMARD.CreateHypothesis('hypo_6_1_2')
113 l_hypothese_1_2.SetUnifRefinUnRef(1)
114 l_hypothese_1_2.AddGroup('T1_EXT_I')
115 l_hypothese_1_2.AddGroup('T1_EXT_O')
116 l_hypothese_1_2.AddGroup('T2_EXT')
117 # Creation of the hypothesis hypo_2_3
118 l_hypothese_2_3 = HOMARD.CreateHypothesis('hypo_6_2_3')
119 l_hypothese_2_3.SetUnifRefinUnRef(1)
120 l_hypothese_2_3.AddGroup('INT_I')
121 l_hypothese_2_3.AddGroup('INT_E')
122 l_hypothese_2_3.AddGroup('IN1')
123 l_hypothese_2_3.AddGroup('IN2')
129 le_cas = HOMARD.CreateCase('case_'+nom, nom, ficmed)
130 le_cas.SetDirName(DIRCASE)
131 le_cas.AddBoundary( 'intersection' )
132 le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
133 le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
134 le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
135 le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
136 le_cas.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
137 le_cas.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
146 print(". Itérations")
147 # Iteration iter_6_1 : raffinement selon les faces internes
148 iter_6_1 = le_cas.NextIteration('iter_6_1')
149 iter_6_1.SetMeshName('PIQUAGE_1')
150 iter_6_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
151 iter_6_1.AssociateHypo('hypo_6_0_1')
152 erreur = iter_6_1.Compute(1, option)
153 print ("erreur = %d" % erreur)
156 # Iteration iter_6_2 : raffinement selon les faces externes
157 iter_6_2 = iter_6_1.NextIteration('iter_6_2')
158 iter_6_2.SetMeshName('PIQUAGE_2')
159 iter_6_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
160 iter_6_2.AssociateHypo('hypo_6_1_2')
161 erreur = iter_6_2.Compute(1, option)
164 # Iteration iter_6_3 : second raffinement selon les faces externes
165 iter_6_3 = iter_6_2.NextIteration('iter_6_3')
166 iter_6_3.SetMeshName('PIQUAGE_3')
167 iter_6_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med"))
168 iter_6_3.AssociateHypo('hypo_6_2_3')
169 erreur = iter_6_3.Compute(1, option)
176 message += "Erreur au calcul de l'itération %d" % erreur
178 return erreur, message
180 #========================== Fin de la fonction ==================================
186 # A. Exec of HOMARD-SALOME
188 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
189 assert HOMARD is not None, "Impossible to load homard engine"
190 HOMARD.SetLanguageShort("fr")
192 FICMED = os.path.join(DATA_TUTORIAL, "tutorial_4.00.med")
193 FICFRMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".fr.med")
195 ERREUR, MESSAGE = homard_exec("PIQUAGE", FICMED, "COURBES", FICFRMED, DEBUG)
196 except Exception, eee:
198 MESSAGE = eee.message
201 MESSAGE += "Pb in homard_exec"
204 # B. Test of the results
206 N_REP_TEST_FILE = N_ITER_TEST_FILE
207 DESTROY_DIR = not DEBUG
208 test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
213 raise Exception(MESSAGE)
215 # ==================================
216 gzip_gunzip(DATA_TUTORIAL, 4, 1)
217 gzip_gunzip(DATA_TUTORIAL, 6, 1)
218 # ==================================
220 if salome.sg.hasDesktop():
221 salome.sg.updateObjBrowser(True)
222 iparameters.getSession().restoreVisualState(1)