1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2011-2014 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 Copyright EDF-R&D 2010, 2014
23 Test test_11 associe au tutorial 4
27 #========================================================================
30 #========================================================================
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()
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, 4, -1)
54 # ==================================
58 ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
59 ipar.append("AP_MODULES_LIST", "Homard")
61 #========================================================================
62 #========================================================================
63 def homard_exec(theStudy):
65 Python script for HOMARD
68 homard.SetCurrentStudy(theStudy)
72 Boun_4_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', data_dir+'/tutorial_4.fr.med')
74 Boun_4_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
76 Boun_4_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
78 Boun_4_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
80 Boun_4_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
84 # Creation of the hypothesis Hypo_4
85 Hypo_4 = homard.CreateHypothesis('Hypo_4')
86 Hypo_4.SetUnifRefinUnRef(1)
87 Hypo_4.AddGroup('T1_INT_I')
88 Hypo_4.AddGroup('T1_INT_O')
89 Hypo_4.AddGroup('T2_INT')
90 # Creation of the hypothesis Hypo_4_bis
91 Hypo_4_bis = homard.CreateHypothesis('Hypo_4_bis')
92 Hypo_4_bis.SetUnifRefinUnRef(1)
93 Hypo_4_bis.AddGroup('T1_EXT_I')
94 Hypo_4_bis.AddGroup('T1_EXT_O')
95 Hypo_4_bis.AddGroup('T2_EXT')
99 Case_4 = homard.CreateCase('Case_4', 'PIQUAGE', data_dir+'/tutorial_4.00.med')
100 Case_4.SetDirName(dircase)
101 Case_4.AddBoundaryGroup( 'intersection', '' )
102 Case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
103 Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
104 Case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
105 Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
106 Case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
107 Case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
111 # Iteration Iter_4_1 : raffinement selon les faces internes
112 Iter_4_1 = Case_4.NextIteration('Iter_4_1')
113 Iter_4_1.SetMeshName('PIQUAGE_1')
114 Iter_4_1.SetMeshFile(dircase+'/maill.01.med')
115 Iter_4_1.AssociateHypo('Hypo_4')
116 error = Iter_4_1.Compute(1, 2)
117 # Iteration Iter_4_2 : raffinement selon les faces externes
118 Iter_4_2 = Iter_4_1.NextIteration('Iter_4_2')
119 Iter_4_2.SetMeshName('PIQUAGE_2')
120 Iter_4_2.SetMeshFile(dircase+'/maill.02.med')
121 Iter_4_2.AssociateHypo('Hypo_4_bis')
122 error = Iter_4_2.Compute(1, 2)
123 # Iteration Iter_4_3 : second raffinement selon les faces externes
124 Iter_4_3 = Iter_4_2.NextIteration('Iter_4_3')
125 Iter_4_3.SetMeshName('PIQUAGE_3')
126 Iter_4_3.SetMeshFile(dircase+'/maill.03.med')
127 Iter_4_3.AssociateHypo('Hypo_4_bis')
128 error = Iter_4_3.Compute(1, 2)
132 #========================================================================
134 homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
135 assert homard is not None, "Impossible to load homard engine"
136 homard.SetLanguageShort("fr")
138 # Exec of HOMARD-SALOME
141 error_main = homard_exec(salome.myStudy)
143 raise Exception('Pb in homard_exec at iteration %d' %error_main )
145 raise Exception('Pb in homard_exec: '+e.message)
147 # Test of the results
149 n_rep_test_file = n_iter_test_file
150 test_results(Rep_Test, Test_Name, dircase, n_iter_test_file, n_rep_test_file)
152 # ==================================
153 gzip_gunzip(data_dir, 4, 1)
154 # ==================================
156 if salome.sg.hasDesktop():
157 salome.sg.updateObjBrowser(1)
158 iparameters.getSession().restoreVisualState(1)