Salome HOME
Merge remote branch 'origin/bsr/medmpi'
[modules/homard.git] / doc / files / tutorial_5.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (C) 2011-2015  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.8"
28 #
29 import os
30 import sys
31 #
32 # ==================================
33 pathHomard = os.getenv('HOMARD_ROOT_DIR')
34 # Repertoire des donnees du tutorial
35 data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
36 data_dir = os.path.normpath(data_dir)
37 sys.path.append(data_dir)
38 from tutorial_util import gzip_gunzip
39 from tutorial_util import creation_dircase
40 # ==================================
41 dircase = creation_dircase(5)
42 gzip_gunzip(data_dir, 5, -1)
43 # ==================================
44 #
45 import salome
46 salome.salome_init()
47 import HOMARD
48 #
49 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
50 study_main = salome.myStudyManager.NewStudy("HOMARD")
51 homard.SetCurrentStudy(salome.myStudy)
52 #
53 # Frontiere
54 # =========
55 # Creation of the discrete boundary Boun_5_1
56 Boun_5_1 = homard.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', data_dir+'/tutorial_5.fr.med')
57 #
58 # Creation des zones
59 # ==================
60 # Creation of the disk with hole enveloppe
61 enveloppe = homard.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 )
62 # Creation of the rectangle quart_sup
63 quart_sup = homard.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 )
64 #
65 # Hypotheses
66 # ==========
67 # Creation of the hypothesis Hypo_5
68 Hypo_5 = homard.CreateHypothesis('Hypo_5')
69 Hypo_5.AddZone('enveloppe', 1)
70 # Creation of the hypothesis Hypo_5_bis
71 Hypo_5_bis = homard.CreateHypothesis('Hypo_5_bis')
72 Hypo_5_bis.AddZone('quart_sup', 1)
73 #
74 # Cas
75 # ===
76 Case_5 = homard.CreateCase('Case_5', 'COEUR_2D', data_dir+'/tutorial_5.00.med')
77 Case_5.SetDirName(dircase)
78 Case_5.SetConfType(3)
79 Case_5.AddBoundaryGroup('Boun_5_1', '')
80 #
81 # Iteration "Iter_5_1"
82 # ====================
83 Iter_5_1 = Case_5.NextIteration('Iter_5_1')
84 Iter_5_1.SetMeshName('COEUR_2D_01')
85 Iter_5_1.SetMeshFile(dircase+'/maill.01.med')
86 Iter_5_1.AssociateHypo('Hypo_5')
87 error = Iter_5_1.Compute(1, 2)
88 #
89 # Iteration "Iter_5_2"
90 # ====================
91 Iter_5_2 = Iter_5_1.NextIteration('Iter_5_2')
92 Iter_5_2.SetMeshName('COEUR_2D_02')
93 Iter_5_2.SetMeshFile(dircase+'/maill.02.med')
94 Iter_5_2.AssociateHypo('Hypo_5_bis')
95 error = Iter_5_2.Compute(1, 2)
96
97 # ==================================
98 gzip_gunzip(data_dir, 5, 1)
99 # ==================================
100
101 if salome.sg.hasDesktop():
102   salome.sg.updateObjBrowser(1)