Salome HOME
Merge branch 'gn/evol' into V9_dev
[modules/homard.git] / doc / files / tutorial_5.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (C) 2011-2016  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 1996, 2010, 2018
26 """
27 __revision__ = "V3.2"
28 #
29 import os
30 import sys
31 #
32 # ==================================
33 PATH_HOMARD = os.getenv("HOMARD_ROOT_DIR")
34 # Repertoire des donnees du tutorial
35 DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
36 DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
37 sys.path.append(DATA_TUTORIAL)
38 from tutorial_util import gzip_gunzip
39 from tutorial_util import creation_dircase
40 # ==================================
41 DIRCASE = creation_dircase(5)
42 gzip_gunzip(DATA_TUTORIAL, 5, -1)
43 # ==================================
44 #
45 import salome
46 salome.salome_init()
47 import HOMARD
48 #
49 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
50 homard.UpdateStudy()
51 #
52 #============================= Début des commandes =============================
53 #
54 # Frontière
55 # =========
56 # Creation of the discrete boundary boun_5_1
57 boun_5_1 = homard.CreateBoundaryDi('boun_5_1', 'MAIL_EXT', os.path.join(DATA_TUTORIAL, "tutorial_5.fr.med"))
58 #
59 # Creation des zones
60 # ==================
61 # Creation of the disk with hole enveloppe
62 enveloppe = homard.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 )
63 # Creation of the rectangle quart_sup
64 quart_sup = homard.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 )
65 #
66 # Hypotheses
67 # ==========
68 # Creation of the hypothesis hypo_5
69 l_hypothese = homard.CreateHypothesis('hypo_5')
70 l_hypothese.AddZone('enveloppe', 1)
71 # Creation of the hypothesis l_hypothese_bis
72 l_hypothese_bis = homard.CreateHypothesis('hypo_5_bis')
73 l_hypothese_bis.AddZone('quart_sup', 1)
74 #
75 # Cas
76 # ===
77 le_cas = homard.CreateCase('Case_5', 'COEUR_2D', os.path.join(DATA_TUTORIAL, "tutorial_5.00.med"))
78 le_cas.SetDirName(DIRCASE)
79 le_cas.SetConfType(1)
80 le_cas.AddBoundary('boun_5_1')
81 #
82 # Iteration "iter_5_1"
83 # ====================
84 iter_5_1 = le_cas.NextIteration('iter_5_1')
85 iter_5_1.SetMeshName('COEUR_2D_01')
86 iter_5_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
87 iter_5_1.AssociateHypo('hypo_5')
88 erreur = iter_5_1.Compute(1, 2)
89 #
90 # Iteration "iter_5_2"
91 # ====================
92 iter_5_2 = iter_5_1.NextIteration('iter_5_2')
93 iter_5_2.SetMeshName('COEUR_2D_02')
94 iter_5_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
95 iter_5_2.AssociateHypo('hypo_5_bis')
96 erreur = iter_5_2.Compute(1, 2)
97 #
98 #============================== Fin des commandes ==============================
99 #
100 # ==================================
101 gzip_gunzip(DATA_TUTORIAL, 5, 1)
102 # ==================================
103
104 if salome.sg.hasDesktop():
105   salome.sg.updateObjBrowser()