Salome HOME
Update copyrights 2014.
[modules/homard.git] / doc / files / tutorial_5.py
1 #!/usr/bin/env python
2 # -*- coding: iso-8859-1 -*-
3
4 # Copyright (C) 2011-2014  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, or (at your option) any later version.
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, 2010, 2013
26 """
27 __revision__ = "V1.6"
28 #
29 import os
30 #
31 # ==================================
32 # Repertoire a personnaliser
33 # Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.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_5" )
42 if not os.path.isdir(dircase) :
43   os.mkdir (dircase)
44 # ==================================
45 # Ce repertoire contient les fichiers de donnees : tutorial_5.00.med, tutorial_5.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 # Frontiere
58 # =========
59 # Creation of the discrete boundary Boun_5_1
60 Boun_5_1 = homard.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', data_dir+'/tutorial_5.fr.med')
61 #
62 # Creation des zones
63 # ==================
64 # Creation of the disk with hole enveloppe
65 enveloppe = homard.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 )
66 # Creation of the rectangle quart_sup
67 quart_sup = homard.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 )
68 #
69 # Hypotheses
70 # ==========
71 # Creation of the hypothesis Hypo_5
72 Hypo_5 = homard.CreateHypothesis('Hypo_5')
73 Hypo_5.SetAdapRefinUnRef(0, 1, 0)
74 Hypo_5.AddZone('enveloppe', 1)
75 # Creation of the hypothesis Hypo_5_bis
76 Hypo_5_bis = homard.CreateHypothesis('Hypo_5_bis')
77 Hypo_5_bis.SetAdapRefinUnRef(0, 1, 0)
78 Hypo_5_bis.AddZone('quart_sup', 1)
79 #
80 # Cas
81 # ===
82 Case_5 = homard.CreateCase('Case_5', 'COEUR_2D', data_dir+'/tutorial_5.00.med')
83 Case_5.SetDirName(dircase)
84 Case_5.SetConfType(3)
85 Case_5.AddBoundaryGroup('Boun_5_1', '')
86 #
87 # Iteration "Iter_5_1"
88 # ====================
89 Iter_5_1 = Case_5.NextIteration('Iter_5_1')
90 Iter_5_1.SetMeshName('COEUR_2D_01')
91 Iter_5_1.SetMeshFile(dircase+'/maill.01.med')
92 Iter_5_1.AssociateHypo('Hypo_5')
93 codret = Iter_5_1.Compute(1, 2)
94 #
95 # Iteration "Iter_5_2"
96 # ====================
97 Iter_5_2 = Iter_5_1.NextIteration('Iter_5_2')
98 Iter_5_2.SetMeshName('COEUR_2D_02')
99 Iter_5_2.SetMeshFile(dircase+'/maill.02.med')
100 Iter_5_2.AssociateHypo('Hypo_5_bis')
101 codret = Iter_5_2.Compute(1, 2)
102
103
104 if salome.sg.hasDesktop():
105   salome.sg.updateObjBrowser(1)