Salome HOME
Correction d'une erreur sur le tri entre raffinement et déraffinement.
[modules/homard.git] / doc / files / tutorial_2.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, 2014
26 """
27 __revision__ = "V1.9"
28 #
29 import os
30 import sys
31 #
32 # ==================================
33 # Repertoire a personnaliser
34 # Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med
35 if os.environ.has_key("LOGNAME") :
36   user = os.environ ["LOGNAME"]
37 else :
38   user = "anonymous"
39 dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user)
40 if not os.path.isdir(dircase) :
41   os.mkdir (dircase)
42 dircase = os.path.join( dircase, "tutorial_2" )
43 if not os.path.isdir(dircase) :
44   os.mkdir (dircase)
45 # ==================================
46 # Ce repertoire contient les fichiers de donnees : tutorial_2.00.med
47 pathHomard = os.getenv('HOMARD_ROOT_DIR')
48 data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
49 sys.path.append(data_dir)
50 from tutorial_util import gzip_gunzip
51 gzip_gunzip(data_dir, 2, -1)
52 # ==================================
53 #
54 import salome
55 salome.salome_init()
56 import HOMARD
57 #
58 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
59 study_main = salome.myStudyManager.NewStudy("HOMARD")
60 homard.SetCurrentStudy(salome.myStudy)
61 #
62 # Creation des zones
63 # ==================
64 # Box "Zone_0"
65 Zone_0 = homard.CreateZoneBox ('Zone_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
66 #
67 # Sphere "Zone_1"
68 Zone_1 = homard.CreateZoneSphere ('Zone_1', 0., 0., 0., 1.05)
69 #
70 # Box "Zone_2"
71 Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
72 #
73 # Hypothese "Hypo_2"
74 # ==================
75 Hypo_2 = homard.CreateHypothesis('Hypo_2')
76 Hypo_2.AddZone('Zone_1', 1)
77 Hypo_2.AddZone('Zone_0', 1)
78 #
79 # Hypothese "Hypo_2_bis"
80 # ======================
81 Hypo_2_bis = homard.CreateHypothesis('Hypo_2_bis')
82 Hypo_2_bis.AddZone('Zone_0', -1)
83 Hypo_2_bis.AddZone('Zone_2', 1)
84 #
85 # Cas
86 # ===
87 Case_2 = homard.CreateCase('Case_2', 'MZERO', data_dir+'/tutorial_2.00.med')
88 Case_2.SetDirName(dircase)
89 #
90 # Iteration "Iter_2_1"
91 # ====================
92 Iter_2_1 = Case_2.NextIteration('Iter_2_1')
93 Iter_2_1.SetMeshName('M_1')
94 Iter_2_1.SetMeshFile(dircase+'/maill.01.med')
95 Iter_2_1.AssociateHypo('Hypo_2')
96 codret = Iter_2_1.Compute(1, 2)
97 #
98 # Iteration "Iter_2_2"
99 # ====================
100 Iter_2_2 = Iter_2_1.NextIteration('Iter_2_2')
101 Iter_2_2.SetMeshName('M_2')
102 Iter_2_2.SetMeshFile(dircase+'/maill.02.med')
103 Iter_2_2.AssociateHypo('Hypo_2_bis')
104 codret = Iter_2_2.Compute(1, 2)
105
106 # ==================================
107 gzip_gunzip(data_dir, 2, 1)
108 # ==================================
109
110 if salome.sg.hasDesktop():
111   salome.sg.updateObjBrowser(1)