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_4 associe au tutorial 4
26 #========================================================================
27 TEST_NAME = "tutorial_4"
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()
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 # ==================================
67 IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
68 IPAR.append("AP_MODULES_LIST", "Homard")
70 #========================================================================
71 #========================================================================
72 def homard_exec(theStudy):
74 Python script for HOMARD
77 HOMARD.SetCurrentStudy(theStudy)
81 boun_4_1 = HOMARD.CreateBoundaryDi('intersection', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.fr.med')
83 boun_4_2 = HOMARD.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
85 boun_4_3 = HOMARD.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
87 boun_4_4 = HOMARD.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
89 boun_4_5 = HOMARD.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
93 # Creation of the hypothesis hypo_4
94 hypo_4 = HOMARD.CreateHypothesis('hypo_4')
95 hypo_4.SetUnifRefinUnRef(1)
96 hypo_4.AddGroup('T1_INT_I')
97 hypo_4.AddGroup('T1_INT_O')
98 hypo_4.AddGroup('T2_INT')
99 # Creation of the hypothesis hypo_4_bis
100 hypo_4_bis = HOMARD.CreateHypothesis('hypo_4_bis')
101 hypo_4_bis.SetUnifRefinUnRef(1)
102 hypo_4_bis.AddGroup('T1_EXT_I')
103 hypo_4_bis.AddGroup('T1_EXT_O')
104 hypo_4_bis.AddGroup('T2_EXT')
108 case_4 = HOMARD.CreateCase('case_4', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.00.med')
109 case_4.SetDirName(DIRCASE)
110 case_4.AddBoundaryGroup( 'intersection', '' )
111 case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
112 case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
113 case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
114 case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
115 case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
116 case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
120 # Iteration iter_4_1 : raffinement selon les faces internes
121 iter_4_1 = case_4.NextIteration('iter_4_1')
122 iter_4_1.SetMeshName('PIQUAGE_1')
123 iter_4_1.SetMeshFile(DIRCASE+'/maill.01.med')
124 iter_4_1.AssociateHypo('hypo_4')
125 error = iter_4_1.Compute(1, 2)
126 # Iteration iter_4_2 : raffinement selon les faces externes
127 iter_4_2 = iter_4_1.NextIteration('iter_4_2')
128 iter_4_2.SetMeshName('PIQUAGE_2')
129 iter_4_2.SetMeshFile(DIRCASE+'/maill.02.med')
130 iter_4_2.AssociateHypo('hypo_4_bis')
131 error = iter_4_2.Compute(1, 2)
132 # Iteration iter_4_3 : second raffinement selon les faces externes
133 iter_4_3 = iter_4_2.NextIteration('iter_4_3')
134 iter_4_3.SetMeshName('PIQUAGE_3')
135 iter_4_3.SetMeshFile(DIRCASE+'/maill.03.med')
136 iter_4_3.AssociateHypo('hypo_4_bis')
137 error = iter_4_3.Compute(1, 2)
141 #========================================================================
143 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
144 assert HOMARD is not None, "Impossible to load HOMARD engine"
145 HOMARD.SetLanguageShort("fr")
147 # Exec of HOMARD-SALOME
150 ERROR = homard_exec(salome.myStudy)
152 raise Exception('Pb in homard_exec at iteration %d' %ERROR )
153 except Exception, eee:
154 raise Exception('Pb in homard_exec: '+eee.message)
156 # Test of the results
158 N_REP_TEST_FILE = N_ITER_TEST_FILE
159 DESTROY_DIR = not DEBUG
160 test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
162 # ==================================
163 gzip_gunzip(DATA_TUTORIAL, 4, 1)
164 # ==================================
166 if salome.sg.hasDesktop():
167 salome.sg.updateObjBrowser(1)
168 iparameters.getSession().restoreVisualState(1)