Salome HOME
Merge branch 'V7_dev'
[modules/homard.git] / doc / files / tutorial_2.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-R&D 1996, 2010, 2014
26 """
27 __revision__ = "V2.10"
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(2)
42 gzip_gunzip(DATA_TUTORIAL, 2, -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 # Creation des zones
54 # ==================
55 # Box "Zone_0"
56 Zone_0 = homard.CreateZoneBox ('Zone_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
57 #
58 # Sphere "Zone_1"
59 Zone_1 = homard.CreateZoneSphere ('Zone_1', 0., 0., 0., 1.05)
60 #
61 # Box "Zone_2"
62 Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
63 #
64 # Hypothese "hypo_2"
65 # ==================
66 hypo_2 = homard.CreateHypothesis('hypo_2')
67 hypo_2.AddZone('Zone_1', 1)
68 hypo_2.AddZone('Zone_0', 1)
69 #
70 # Hypothese "hypo_2_bis"
71 # ======================
72 hypo_2_bis = homard.CreateHypothesis('hypo_2_bis')
73 hypo_2_bis.AddZone('Zone_0', -1)
74 hypo_2_bis.AddZone('Zone_2', 1)
75 #
76 # Cas
77 # ===
78 case_2 = homard.CreateCase('Case_2', 'MZERO', DATA_TUTORIAL+'/tutorial_2.00.med')
79 case_2.SetDirName(DIRCASE)
80 #
81 # Iteration "iter_2_1"
82 # ====================
83 iter_2_1 = case_2.NextIteration('iter_2_1')
84 iter_2_1.SetMeshName('M_1')
85 iter_2_1.SetMeshFile(DIRCASE+'/maill.01.med')
86 iter_2_1.AssociateHypo('hypo_2')
87 error = iter_2_1.Compute(1, 2)
88 #
89 # Iteration "iter_2_2"
90 # ====================
91 iter_2_2 = iter_2_1.NextIteration('iter_2_2')
92 iter_2_2.SetMeshName('M_2')
93 iter_2_2.SetMeshFile(DIRCASE+'/maill.02.med')
94 iter_2_2.AssociateHypo('hypo_2_bis')
95 error = iter_2_2.Compute(1, 2)
96
97 # ==================================
98 gzip_gunzip(DATA_TUTORIAL, 2, 1)
99 # ==================================
100
101 if salome.sg.hasDesktop():
102   salome.sg.updateObjBrowser(1)