Salome HOME
Nouvelles icones
[modules/homard.git] / doc / files / tutorial_1.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.5"
28 #
29 import os
30 #
31 # ==================================
32 # Repertoire a personnaliser
33 # Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med, maill.03.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 # ==================================
42 # Ce repertoire contient les fichiers de donnees : tutorial_1.00.med
43 pathHomard = os.getenv('HOMARD_ROOT_DIR')
44 data_dir = os.path.join(pathHomard, "share/doc/salome/gui/HOMARD/fr/_downloads")
45 #
46 import salome
47 salome.salome_init()
48 import HOMARD
49 #
50 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
51 study_main = salome.myStudyManager.NewStudy("HOMARD")
52 homard.SetCurrentStudy(salome.myStudy)
53 #
54 # Hypothesis "Hypo_0"
55 # ===================
56 Hypo_0 = homard.CreateHypothesis('Hypo_0')
57 Hypo_0.SetAdapRefinUnRef(-1, 1, 0)
58 #
59 # Case "Case_1"
60 # =============
61 Case_1 = homard.CreateCase('Case_1', 'MAILL', data_dir+'/tutorial_1.00.med')
62 Case_1.SetDirName(dircase)
63 Case_1.SetConfType(1)
64 #
65 # Iterations
66 # ==========
67 # Iteration "Iter_0"
68 Iter_0 = Case_1.NextIteration('Iter_0')
69 Iter_0.SetMeshName('MESH')
70 Iter_0.SetMeshFile(dircase+'/maill.01.med')
71 Iter_0.AssociateHypo('Hypo_0')
72 codret = Iter_0.Compute(1, 2)
73
74 # Iteration "Iter_1"
75 Iter_1 = Iter_0.NextIteration('Iter_1')
76 Iter_1.SetMeshName('MESH')
77 Iter_1.SetMeshFile(dircase+'/maill.02.med')
78 Iter_1.AssociateHypo('Hypo_0')
79 codret = Iter_1.Compute(1, 2)
80
81 # Iteration "Iter_2"
82 Iter_2 = Iter_1.NextIteration('Iter_2')
83 Iter_2.SetMeshName('MESH')
84 Iter_2.SetMeshFile(dircase+'/maill.03.med')
85 Iter_2.AssociateHypo('Hypo_0')
86 codret = Iter_2.Compute(1, 2)
87
88 if salome.sg.hasDesktop():
89   salome.sg.updateObjBrowser(1)