Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/homard.git] / doc / files / tutorial_4.py
1 #!/usr/bin/env python
2 # -*- coding: iso-8859-1 -*-
3
4 # Copyright (C) 2011-2012  CEA/DEN, EDF R&D
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 """
24 Exemple de couplage HOMARD-Salome
25 Copyright EDF-R&D 1996, 2011
26 """
27 __revision__ = "V1.3"
28 #
29 # ==================================
30 # Repertoire a personnaliser
31 # Ce repertoire contient les fichiers de donnees : tutorial_4.00.med, tutorial_4.fr.med
32 # Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med
33 dircase = "/tmp"
34 # ==================================
35 #
36 import salome
37 salome.salome_init()
38 import HOMARD
39 #
40 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
41 study_main = salome.myStudyManager.NewStudy("HOMARD")
42 homard.SetCurrentStudy(salome.myStudy)
43 #
44 # Creation of the boundaries
45 # ==========================
46 Boundary_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', dircase+'/tutorial_4.fr.med')
47 #
48 Boundary_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
49 #
50 Boundary_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
51 #
52 Boundary_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
53 #
54 Boundary_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
55 #
56 # Hypothesis
57 # ==========
58 # Creation of the hypothesis Hypo_1
59 Hypo_1 = homard.CreateHypothesis('Hypo_1')
60 Hypo_1.SetAdapRefinUnRef(-1, 1, 0)
61 Hypo_1.AddGroup('T1_INT_I')
62 Hypo_1.AddGroup('T1_INT_O')
63 Hypo_1.AddGroup('T2_INT')
64 # Creation of the hypothesis Hypo_2
65 Hypo_2 = homard.CreateHypothesis('Hypo_2')
66 Hypo_2.SetAdapRefinUnRef(-1, 1, 0)
67 Hypo_2.AddGroup('T1_EXT_I')
68 Hypo_2.AddGroup('T1_EXT_O')
69 Hypo_2.AddGroup('T2_EXT')
70 #
71 # Case "Case"
72 # =============
73 Case = homard.CreateCase('Case', 'PIQUAGE', dircase+'/tutorial_4.00.med')
74 Case.SetDirName(dircase)
75 Case.AddBoundaryGroup( 'intersection', '' )
76 Case.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
77 Case.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
78 Case.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
79 Case.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
80 Case.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
81 Case.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
82 #
83 # Creation of the iterations
84 # ==========================
85 # Creation of the iteration Iter_1
86 Iter_1 = homard.CreateIteration('Iter_1', Case.GetIter0Name() )
87 Iter_1.SetMeshName('PIQUAGE_1')
88 Iter_1.SetMeshFile(dircase+'/maill.01.med')
89 homard.AssociateIterHypo('Iter_1', 'Hypo_1')
90 codret = Iter_1.Compute(1)
91 # Creation of the iteration Iter_2
92 Iter_2 = homard.CreateIteration('Iter_2', 'Iter_1' )
93 Iter_2.SetMeshName('PIQUAGE_2')
94 Iter_2.SetMeshFile(dircase+'/maill.02.med')
95 homard.AssociateIterHypo('Iter_2', 'Hypo_2')
96 codret = Iter_2.Compute(1)
97
98 if salome.sg.hasDesktop():
99   salome.sg.updateObjBrowser(1)