1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2011-2019 CEA/DEN, EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 Python script for HOMARD
24 Test tutorial_5 associe au tutorial 5
26 __revision__ = "V4.06"
28 #========================================================================
29 TEST_NAME = "tutorial_5"
32 #========================================================================
36 # ==================================
37 PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
38 # Repertoire des scripts utilitaires
39 REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
40 REP_PYTHON = os.path.normpath(REP_PYTHON)
41 sys.path.append(REP_PYTHON)
42 from test_util import get_dir
43 from test_util import get_dir_tutorial
44 from test_util import test_results
45 # ==================================
46 # Répertoires pour ce test
47 REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
48 DATA_TUTORIAL = get_dir_tutorial(PATH_HOMARD)
49 # ==================================
56 IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
57 IPAR.append("AP_MODULES_LIST", "Homard")
60 #========================= Debut de la fonction ==================================
62 def homard_exec(nom, ficmed, nomfr, ficfrmed, verbose=False):
64 Python script for HOMARD
71 # HOMARD.UpdateStudy()
77 # Creation of the discrete boundary Boun_5_1
78 boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', nomfr, ficfrmed)
84 # Creation of the disk with hole enveloppe
85 enveloppe = HOMARD.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 )
86 # Creation of the rectangle quart_sup
87 quart_sup = HOMARD.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 )
93 # Creation of the hypothesis hypo_5
94 hypo_5 = HOMARD.CreateHypothesis('hypo_5')
95 hypo_5.AddZone('enveloppe', 1)
96 # Creation of the hypothesis hypo_5_bis
97 hypo_5_bis = HOMARD.CreateHypothesis('hypo_5_bis')
98 hypo_5_bis.AddZone('quart_sup', 1)
104 le_cas = HOMARD.CreateCase('case_5', nom, ficmed)
105 le_cas.SetDirName(DIRCASE)
106 le_cas.SetConfType(1)
107 le_cas.AddBoundary('Boun_5_1')
116 print(". Itérations")
118 # Iteration "iter_5_1"
119 # ====================
120 iter_5_1 = le_cas.NextIteration('iter_5_1')
121 iter_5_1.SetMeshName('COEUR_2D_01')
122 iter_5_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
123 iter_5_1.AssociateHypo('hypo_5')
124 erreur = iter_5_1.Compute(1, option)
128 # Iteration "iter_5_2"
129 # ====================
130 iter_5_2 = iter_5_1.NextIteration('iter_5_2')
131 iter_5_2.SetMeshName('COEUR_2D_02')
132 iter_5_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
133 iter_5_2.AssociateHypo('hypo_5_bis')
134 erreur = iter_5_2.Compute(1, option)
141 message += "Erreur au calcul de l'itération %d" % erreur
143 return erreur, message
145 #========================== Fin de la fonction ==================================
151 # A. Exec of HOMARD-SALOME
153 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
154 assert HOMARD is not None, "Impossible to load homard engine"
155 HOMARD.SetLanguageShort("fr")
157 FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med")
158 FICFRMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".fr.med")
160 ERREUR, MESSAGE = homard_exec("COEUR_2D", FICMED, "MAIL_EXT", FICFRMED, DEBUG)
161 except RuntimeError as eee:
163 MESSAGE = str(eee.message)
166 MESSAGE += "Pb in homard_exec"
169 # B. Test of the results
171 N_REP_TEST_FILE = N_ITER_TEST_FILE
172 DESTROY_DIR = not DEBUG
173 test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
178 raise Exception(MESSAGE)
181 if salome.sg.hasDesktop():
182 salome.sg.updateObjBrowser()
183 iparameters.getSession().restoreVisualState(1)