2 # -*- coding: iso-8859-1 -*-
4 # Copyright (C) 2011-2014 CEA/DEN, EDF R&D
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.
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.
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
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 Exemple de couplage HOMARD-Salome
25 Copyright EDF-R&D 1996, 2010, 2014
32 # ==================================
33 # Repertoire a personnaliser
34 # Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med
35 if os.environ.has_key("LOGNAME") :
36 user = os.environ ["LOGNAME"]
39 dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user)
40 if not os.path.isdir(dircase) :
42 dircase = os.path.join( dircase, "tutorial_3" )
43 if not os.path.isdir(dircase) :
45 # ==================================
46 # Ce repertoire contient les fichiers de donnees : tutorial_3.00.med, tutorial_3.01.med
47 pathHomard = os.getenv('HOMARD_ROOT_DIR')
48 data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
49 sys.path.append(data_dir)
50 from tutorial_util import gzip_gunzip
51 gzip_gunzip(data_dir, 3, -1)
52 # ==================================
58 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
59 study_main = salome.myStudyManager.NewStudy("HOMARD")
60 homard.SetCurrentStudy(salome.myStudy)
62 # Hypothese "Hypo_0vers1"
63 # =======================
64 Hypo_0vers1 = homard.CreateHypothesis('Hypo_0vers1')
65 # Characterization of the field
66 Hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
67 Hypo_0vers1.SetUseComp(0)
68 Hypo_0vers1.AddComp('ERREST ')
69 Hypo_0vers1.SetRefinThr(3, 1.0)
70 Hypo_0vers1.SetTypeFieldInterp(2)
71 Hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________')
72 Hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
74 # Hypothese "Hypo_1vers2"
75 # =======================
76 Hypo_1vers2 = homard.CreateHypothesis('Hypo_1vers2')
77 # Characterization of the field
78 Hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
79 Hypo_1vers2.SetUseComp(0)
80 Hypo_1vers2.AddComp('ERREST ')
81 Hypo_1vers2.SetRefinThr(3, 1.5)
82 Hypo_1vers2.SetUnRefThr(3, 6.)
83 Hypo_1vers2.SetTypeFieldInterp(2)
84 Hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________')
85 Hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
87 # Hypothese "Hypo_1vers2_bis"
88 # ===========================
89 Hypo_1vers2_bis = homard.CreateHypothesis('Hypo_1vers2_bis')
90 # Characterization of the field
91 Hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________')
92 Hypo_1vers2_bis.SetUseComp(1)
93 Hypo_1vers2_bis.AddComp('DX')
94 Hypo_1vers2_bis.AddComp('DY')
95 Hypo_1vers2_bis.AddComp('DZ')
96 Hypo_1vers2_bis.SetRefinThr(1, 0.0001)
97 Hypo_1vers2_bis.SetUnRefThr(1, 0.000001)
98 Hypo_1vers2_bis.SetTypeFieldInterp(0)
102 Case_3 = homard.CreateCase('Case_3', 'G_0', data_dir+'/tutorial_3.00.med')
103 Case_3.SetDirName(dircase)
105 # Iteration "Iter_3_1"
106 # ====================
107 Iter_3_1 = Case_3.NextIteration('Iter_3_1')
108 Iter_3_1.SetMeshName('H_1')
109 Iter_3_1.SetMeshFile(dircase+'/maill.01.med')
110 Iter_3_1.SetFieldFile(data_dir+'/tutorial_3.00.med')
111 Iter_3_1.SetTimeStepRank( 1, 1)
112 Iter_3_1.AssociateHypo('Hypo_0vers1')
113 codret = Iter_3_1.Compute(1, 2)
115 # Iteration "Iter_3_2"
116 # ====================
117 Iter_3_2 = Iter_3_1.NextIteration('Iter_3_2')
118 Iter_3_2.SetMeshName('H_2')
119 Iter_3_2.SetMeshFile(dircase+'/maill.02.med')
120 Iter_3_2.SetFieldFile(data_dir+'/tutorial_3.01.med')
121 Iter_3_2.SetTimeStepRank(1, 1)
122 Iter_3_2.AssociateHypo('Hypo_1vers2')
123 codret = Iter_3_2.Compute(1, 2)
125 # Iteration "Iter_3_2_bis"
126 # ========================
127 Iter_3_2_bis = Iter_3_1.NextIteration('Iter_3_2_bis')
128 Iter_3_2_bis.SetMeshName('H_2_bis')
129 Iter_3_2_bis.SetMeshFile(dircase+'/maill.02.bis.med')
130 Iter_3_2_bis.SetFieldFile(data_dir+'/tutorial_3.01.med')
131 Iter_3_2_bis.SetTimeStepRank(1, 1)
132 Iter_3_2_bis.AssociateHypo('Hypo_1vers2_bis')
133 codret = Iter_3_2_bis.Compute(1, 2)
135 # ==================================
136 gzip_gunzip(data_dir, 3, 1)
137 # ==================================
139 if salome.sg.hasDesktop():
140 salome.sg.updateObjBrowser(1)