Salome HOME
Merge from V6_main 01/04/2013
[modules/homard.git] / doc / files / tutorial_3.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
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_3.00.med, tutorial_3.01.med
43 pathHomard = os.getenv('HOMARD_ROOT_DIR')
44 data_dir = os.path.join(pathHomard, "share/doc/salome/gui/HOMARD/_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_0vers1"
55 # ========================
56 Hypo_0vers1 = homard.CreateHypothesis('Hypo_0vers1')
57 Hypo_0vers1.SetAdapRefinUnRef(1, 1, 0)
58 # Characterization of the field
59 Hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
60 Hypo_0vers1.SetUseComp(0)
61 Hypo_0vers1.AddComp('ERREST          ')
62 Hypo_0vers1.SetRefinThr(3, 1.0)
63 Hypo_0vers1.SetTypeFieldInterp(2)
64 Hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________')
65 Hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
66 #
67 # Hypothesis "Hypo_1vers2"
68 # ========================
69 Hypo_1vers2 = homard.CreateHypothesis('Hypo_1vers2')
70 Hypo_1vers2.SetAdapRefinUnRef(1, 1, 1)
71 # Characterization of the field
72 Hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
73 Hypo_1vers2.SetUseComp(0)
74 Hypo_1vers2.AddComp('ERREST          ')
75 Hypo_1vers2.SetRefinThr(3, 1.5)
76 Hypo_1vers2.SetUnRefThr(3, 6.)
77 Hypo_1vers2.SetTypeFieldInterp(2)
78 Hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________')
79 Hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
80 #
81 # Hypothesis "Hypo_1vers2_bis"
82 # ============================
83 Hypo_1vers2_bis = homard.CreateHypothesis('Hypo_1vers2_bis')
84 Hypo_1vers2_bis.SetAdapRefinUnRef(1, 1, 1)
85 # Characterization of the field
86 Hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________')
87 Hypo_1vers2_bis.SetUseComp(1)
88 Hypo_1vers2_bis.AddComp('DX')
89 Hypo_1vers2_bis.AddComp('DY')
90 Hypo_1vers2_bis.AddComp('DZ')
91 Hypo_1vers2_bis.SetRefinThr(1, 0.0001)
92 Hypo_1vers2_bis.SetUnRefThr(1, 0.000001)
93 Hypo_1vers2_bis.SetTypeFieldInterp(0)
94 #
95 # Case "Case_1"
96 # =============
97 Case_1 = homard.CreateCase('Case_1', 'G_0', data_dir+'/tutorial_3.00.med')
98 Case_1.SetDirName(dircase)
99 #
100 # Iteration "Iter_1"
101 # ==================
102 Iter_1 = Case_1.NextIteration('Iter_1')
103 Iter_1.SetMeshName('H_1')
104 Iter_1.SetMeshFile(dircase+'/maill.01.med')
105 Iter_1.SetFieldFile(data_dir+'/tutorial_3.00.med')
106 Iter_1.SetTimeStepRank( 1, 1)
107 Iter_1.AssociateHypo('Hypo_0vers1')
108 codret = Iter_1.Compute(1)
109 #
110 # Iteration "Iter_2"
111 # ==================
112 Iter_2 = Iter_1.NextIteration('Iter_2')
113 Iter_2.SetMeshName('H_2')
114 Iter_2.SetMeshFile(dircase+'/maill.02.med')
115 Iter_2.SetFieldFile(data_dir+'/tutorial_3.01.med')
116 Iter_2.SetTimeStepRank(1, 1)
117 Iter_2.AssociateHypo('Hypo_1vers2')
118 codret = Iter_2.Compute(1)
119 #
120 # Iteration "Iter_2_bis"
121 # ======================
122 Iter_2_bis = Iter_1.NextIteration('Iter_2_bis')
123 Iter_2_bis.SetMeshName('H_2_bis')
124 Iter_2_bis.SetMeshFile(dircase+'/maill.02.bis.med')
125 Iter_2_bis.SetFieldFile(data_dir+'/tutorial_3.01.med')
126 Iter_2_bis.SetTimeStepRank(1, 1)
127 Iter_2_bis.AssociateHypo('Hypo_1vers2_bis')
128 codret = Iter_2_bis.Compute(1)
129 #
130 if salome.sg.hasDesktop():
131   salome.sg.updateObjBrowser(1)