Salome HOME
8560506a7088271ab652b11e406e38f182a1d0c4
[modules/homard.git] / doc / files / tutorial_2.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, 2010, 2013
26 """
27 __revision__ = "V1.4"
28 #
29 # ==================================
30 # Repertoire a personnaliser
31 # Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med
32 dircase = "/tmp"
33 # ==================================
34 import os
35 # Ce repertoire contient les fichiers de donnees : tutorial_2.00.med
36 pathHomard = os.getenv('HOMARD_ROOT_DIR')
37 data_dir = os.path.join(pathHomard, "share/doc/salome/gui/HOMARD/_downloads")
38 #
39 import salome
40 salome.salome_init()
41 import HOMARD
42 #
43 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
44 study_main = salome.myStudyManager.NewStudy("HOMARD")
45 homard.SetCurrentStudy(salome.myStudy)
46 #
47 # Creation of the zones
48 # =====================
49 # Box "Zone_0"
50 Zone_0 = homard.CreateZoneBox ('Zone_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
51 #
52 # Sphere "Zone_1"
53 Zone_1 = homard.CreateZoneSphere ('Zone_1', 0., 0., 0., 1.05)
54 #
55 # Box "Zone_2"
56 Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
57 #
58 # Hypothesis "Hypo_0"
59 # ===================
60 Hypo_0 = homard.CreateHypothesis('Hypo_0')
61 Hypo_0.SetAdapRefinUnRef(0, 1, 0)
62 Hypo_0.AddZone('Zone_1', 1)
63 Hypo_0.AddZone('Zone_0', 1)
64 #
65 # Hypothesis "Hypo_1"
66 # ===================
67 Hypo_1 = homard.CreateHypothesis('Hypo_1')
68 Hypo_1.SetAdapRefinUnRef(0, 1, 0)
69 Hypo_1.AddZone('Zone_0', 1)
70 Hypo_1.AddZone('Zone_2', 1)
71 #
72 # Case "Case_1"
73 # =============
74 Case_1 = homard.CreateCase('Case_1', 'MZERO', data_dir+'/tutorial_2.00.med')
75 Case_1.SetDirName(dircase)
76 #
77 # Iteration "Iter_0"
78 # ==================
79 Iter_0 = Case_1.NextIteration('Iter_0')
80 Iter_0.SetMeshName('M_1')
81 Iter_0.SetMeshFile(dircase+'/maill.01.med')
82 Iter_0.AssociateHypo('Hypo_0')
83 codret = Iter_0.Compute(1)
84 #
85 # Iteration "Iter_1"
86 # ==================
87 Iter_1 = Iter_0.NextIteration('Iter_1')
88 Iter_1.SetMeshName('M_2')
89 Iter_1.SetMeshFile(dircase+'/maill.02.med')
90 Iter_1.AssociateHypo('Hypo_1')
91 codret = Iter_1.Compute(1)
92
93 if salome.sg.hasDesktop():
94   salome.sg.updateObjBrowser(1)