1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2011-2022 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_6 associe au tutorial 6
26 __revision__ = "V4.07"
28 #========================================================================
29 TEST_NAME = "tutorial_6"
32 #========================================================================
38 # ==================================
39 PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
40 # Repertoire des scripts utilitaires
41 REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
42 REP_PYTHON = os.path.normpath(REP_PYTHON)
43 sys.path.append(REP_PYTHON)
44 from test_util import get_dir
45 from test_util import test_results
46 # ==================================
47 # Répertoires pour ce test
48 REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
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 boun_6_1 = HOMARD.CreateBoundaryDi('intersection', nomfr, ficfrmed)
79 boun_6_2 = HOMARD.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
81 boun_6_3 = HOMARD.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
83 boun_6_6 = HOMARD.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
85 boun_6_5 = HOMARD.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
91 # Creation of the hypothesis hypo_0_1
92 l_hypothese_0_1 = HOMARD.CreateHypothesis('hypo_6_0_1')
93 l_hypothese_0_1.SetUnifRefinUnRef(1)
94 l_hypothese_0_1.AddGroup('IN1')
95 l_hypothese_0_1.AddGroup('IN2')
96 l_hypothese_0_1.AddGroup('T1_INT_I')
97 l_hypothese_0_1.AddGroup('T1_INT_O')
98 l_hypothese_0_1.AddGroup('T2_INT')
99 # Creation of the hypothesis hypo_1_2
100 l_hypothese_1_2 = HOMARD.CreateHypothesis('hypo_6_1_2')
101 l_hypothese_1_2.SetUnifRefinUnRef(1)
102 l_hypothese_1_2.AddGroup('T1_EXT_I')
103 l_hypothese_1_2.AddGroup('T1_EXT_O')
104 l_hypothese_1_2.AddGroup('T2_EXT')
105 # Creation of the hypothesis hypo_2_3
106 l_hypothese_2_3 = HOMARD.CreateHypothesis('hypo_6_2_3')
107 l_hypothese_2_3.SetUnifRefinUnRef(1)
108 l_hypothese_2_3.AddGroup('INT_I')
109 l_hypothese_2_3.AddGroup('INT_E')
110 l_hypothese_2_3.AddGroup('IN1')
111 l_hypothese_2_3.AddGroup('IN2')
117 le_cas = HOMARD.CreateCase('case_'+nom, nom, ficmed)
118 le_cas.SetDirName(DIRCASE)
119 le_cas.AddBoundary( 'intersection' )
120 le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
121 le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
122 le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
123 le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
124 le_cas.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
125 le_cas.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
134 print(". Itérations")
135 # Iteration iter_6_1 : raffinement selon les faces internes
136 iter_6_1 = le_cas.NextIteration('iter_6_1')
137 iter_6_1.SetMeshName('PIQUAGE_1')
138 iter_6_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
139 iter_6_1.AssociateHypo('hypo_6_0_1')
140 erreur = iter_6_1.Compute(1, option)
141 print ("erreur = %d" % erreur)
144 # Iteration iter_6_2 : raffinement selon les faces externes
145 iter_6_2 = iter_6_1.NextIteration('iter_6_2')
146 iter_6_2.SetMeshName('PIQUAGE_2')
147 iter_6_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
148 iter_6_2.AssociateHypo('hypo_6_1_2')
149 erreur = iter_6_2.Compute(1, option)
152 # Iteration iter_6_3 : second raffinement selon les faces externes
153 iter_6_3 = iter_6_2.NextIteration('iter_6_3')
154 iter_6_3.SetMeshName('PIQUAGE_3')
155 iter_6_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med"))
156 iter_6_3.AssociateHypo('hypo_6_2_3')
157 erreur = iter_6_3.Compute(1, option)
164 message += "Erreur au calcul de l'itération %d" % erreur
166 return erreur, message
168 #========================== Fin de la fonction ==================================
174 # A. Exec of HOMARD-SALOME
176 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
177 assert HOMARD is not None, "Impossible to load homard engine"
178 HOMARD.SetLanguageShort("fr")
180 FICMED = os.path.join(REP_DATA, "tutorial_4.00.med")
181 FICFRMED = os.path.join(REP_DATA, TEST_NAME+".fr.med")
183 ERREUR, MESSAGE = homard_exec("PIQUAGE", FICMED, "COURBES", FICFRMED, DEBUG)
184 except RuntimeError as eee:
186 MESSAGE = str(eee.message)
189 MESSAGE += "Pb in homard_exec"
192 # B. Test of the results
194 N_REP_TEST_FILE = N_ITER_TEST_FILE
195 DESTROY_DIR = not DEBUG
196 test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
201 raise Exception(MESSAGE)
203 if salome.sg.hasDesktop():
204 salome.sg.updateObjBrowser()
205 iparameters.getSession().restoreVisualState(1)