Salome HOME
Mise à jour de la documentation
[modules/homard.git] / doc / files / tutorial_4.py
1 #!/usr/bin/env python
2 # -*- coding: iso-8859-1 -*-
3
4 # Copyright (C) 2011-2013  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, 2013
26 """
27 __revision__ = "V2.3"
28 #
29 import os
30 #
31 # ==================================
32 # Repertoire a personnaliser
33 # Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med, maill.03.med
34 if os.environ.has_key("LOGNAME") :
35   user = os.environ ["LOGNAME"]
36 else :
37   user = "anonymous"
38 dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user)
39 if not os.path.isdir(dircase) :
40     os.mkdir (dircase)
41 dircase = os.path.join( dircase, "tutorial_4" )
42 if not os.path.isdir(dircase) :
43   os.mkdir (dircase)
44 # ==================================
45 # Ce repertoire contient les fichiers de donnees : tutorial_4.00.med, tutorial_4.fr.med
46 pathHomard = os.getenv('HOMARD_ROOT_DIR')
47 data_dir = os.path.join(pathHomard, "share/doc/salome/gui/HOMARD/fr/_downloads")
48 #
49 import salome
50 salome.salome_init()
51 import HOMARD
52 #
53 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
54 study_main = salome.myStudyManager.NewStudy("HOMARD")
55 homard.SetCurrentStudy(salome.myStudy)
56 #
57 # Frontieres
58 # ==========
59 Boun_4_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', data_dir+'/tutorial_4.fr.med')
60 #
61 Boun_4_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
62 #
63 Boun_4_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
64 #
65 Boun_4_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
66 #
67 Boun_4_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
68 #
69 # Hypotheses
70 # ==========
71 # Creation of the hypothesis Hypo_4
72 Hypo_4 = homard.CreateHypothesis('Hypo_4')
73 Hypo_4.SetAdapRefinUnRef(-1, 1, 0)
74 Hypo_4.AddGroup('T1_INT_I')
75 Hypo_4.AddGroup('T1_INT_O')
76 Hypo_4.AddGroup('T2_INT')
77 # Creation of the hypothesis Hypo_4_bis
78 Hypo_4_bis = homard.CreateHypothesis('Hypo_4_bis')
79 Hypo_4_bis.SetAdapRefinUnRef(-1, 1, 0)
80 Hypo_4_bis.AddGroup('T1_EXT_I')
81 Hypo_4_bis.AddGroup('T1_EXT_O')
82 Hypo_4_bis.AddGroup('T2_EXT')
83 #
84 # Cas
85 # ===
86 Case_4 = homard.CreateCase('Case_4', 'PIQUAGE', data_dir+'/tutorial_4.00.med')
87 Case_4.SetDirName(dircase)
88 Case_4.AddBoundaryGroup( 'intersection', '' )
89 Case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
90 Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
91 Case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
92 Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
93 Case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
94 Case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
95 #
96 # Iterations
97 # ==========
98 # Iteration Iter_4_1 : raffinement selon les faces internes
99 Iter_4_1 = Case_4.NextIteration('Iter_4_1')
100 Iter_4_1.SetMeshName('PIQUAGE_1')
101 Iter_4_1.SetMeshFile(dircase+'/maill.01.med')
102 Iter_4_1.AssociateHypo('Hypo_4')
103 codret = Iter_4_1.Compute(1, 2)
104 # Iteration Iter_4_2 : raffinement selon les faces externes
105 Iter_4_2 = Iter_4_1.NextIteration('Iter_4_2')
106 Iter_4_2.SetMeshName('PIQUAGE_2')
107 Iter_4_2.SetMeshFile(dircase+'/maill.02.med')
108 Iter_4_2.AssociateHypo('Hypo_4_bis')
109 codret = Iter_4_2.Compute(1, 2)
110 # Iteration Iter_4_3 : second raffinement selon les faces externes
111 Iter_4_3 = Iter_4_2.NextIteration('Iter_4_3')
112 Iter_4_3.SetMeshName('PIQUAGE_3')
113 Iter_4_3.SetMeshFile(dircase+'/maill.03.med')
114 Iter_4_3.AssociateHypo('Hypo_4_bis')
115 codret = Iter_4_3.Compute(1, 2)
116
117 if salome.sg.hasDesktop():
118   salome.sg.updateObjBrowser(1)