Salome HOME
Schémas YACS - suite
[modules/homard.git] / doc / files / tutorial_2.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, 2010, 2013
26 """
27 __revision__ = "V1.7"
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_2" )
42 if not os.path.isdir(dircase) :
43   os.mkdir (dircase)
44 # ==================================
45 # Ce repertoire contient les fichiers de donnees : tutorial_2.00.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 # Creation of the zones
58 # =====================
59 # Box "Zone_0"
60 Zone_0 = homard.CreateZoneBox ('Zone_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
61 #
62 # Sphere "Zone_1"
63 Zone_1 = homard.CreateZoneSphere ('Zone_1', 0., 0., 0., 1.05)
64 #
65 # Box "Zone_2"
66 Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
67 #
68 # Hypothesis "Hypo_2"
69 # ===================
70 Hypo_2 = homard.CreateHypothesis('Hypo_2')
71 Hypo_2.SetAdapRefinUnRef(0, 1, 0)
72 Hypo_2.AddZone('Zone_1', 1)
73 Hypo_2.AddZone('Zone_0', 1)
74 #
75 # Hypothesis "Hypo_2_bis"
76 # ===================
77 Hypo_2_bis = homard.CreateHypothesis('Hypo_2_bis')
78 Hypo_2_bis.SetAdapRefinUnRef(0, 1, 0)
79 Hypo_2_bis.AddZone('Zone_0', 1)
80 Hypo_2_bis.AddZone('Zone_2', 1)
81 #
82 # Case "Case_2"
83 # =============
84 Case_2 = homard.CreateCase('Case_2', 'MZERO', data_dir+'/tutorial_2.00.med')
85 Case_2.SetDirName(dircase)
86 #
87 # Iteration "Iter_2_0"
88 # ==================
89 Iter_2_0 = Case_2.NextIteration('Iter_2_0')
90 Iter_2_0.SetMeshName('M_1')
91 Iter_2_0.SetMeshFile(dircase+'/maill.01.med')
92 Iter_2_0.AssociateHypo('Hypo_2')
93 codret = Iter_2_0.Compute(1, 2)
94 #
95 # Iteration "Iter_2_1"
96 # ==================
97 Iter_2_1 = Iter_2_0.NextIteration('Iter_2_1')
98 Iter_2_1.SetMeshName('M_2')
99 Iter_2_1.SetMeshFile(dircase+'/maill.02.med')
100 Iter_2_1.AssociateHypo('Hypo_2_bis')
101 codret = Iter_2_1.Compute(1, 2)
102
103 if salome.sg.hasDesktop():
104   salome.sg.updateObjBrowser(1)