1 # Copyright (C) 2011-2013 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Nicolas REJNERI, Paul RASCLE
21 # Modified by : Alexander BORODIN (OCN) - autotools usage
32 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
38 study = salome.myStudyManager.NewStudy("HOMARD")
39 homard.SetCurrentStudy(study)
43 case_1 = homard.CreateCas("Case 1")
44 case_1.SetNomDir("/tmp/homard")
45 case_1.SetTypeConf(12)
46 case_1.SetBoiteEnglobante([1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.10,10.11])
50 hypo_1 = homard.CreateHypothese("Hypothesis 1")
51 hypo_1.SetTypeAdapRaffDera(2,3,4)
52 hypo_1.SetField("Field 1", 12, 3.45, 67, 23.343)
53 hypo_1.AjoutComposant("Comp 1")
54 hypo_1.AjoutComposant("Comp 2")
55 hypo_1.AjoutComposant("Comp 3")
59 hypo_2 = homard.CreateHypothese("Hypothesis 2")
60 hypo_2.SetTypeAdapRaffDera(20,30,40)
61 hypo_2.SetField("Field 2", 5, 12.67223, 900, 6.5434)
62 hypo_2.AjoutComposant("Comp 123")
66 iter_1 = homard.CreateIteration("Iteration 1")
69 iter_1.SetMeshFile("/aaaa/bbbb/AAAAA.med")
70 iter_1.SetNomMesh("My Mesh")
71 iter_1.SetField("Field 1", 42, 522)
75 iter_2 = homard.CreateIteration("Iteration 2")
78 iter_2.SetMeshFile("/cccc/cccc/asd.med")
79 iter_2.SetNomMesh("MeshXZY")
80 iter_2.SetField("Field 2", 22222, 50000)
82 # create iteration 3 (not published)
84 iter_3 = homard.CreateIteration("Iteration 3")
86 iter_3.SetNumIter(666)
87 iter_3.SetMeshFile("/not/assigned/iteration/file.med")
88 iter_3.SetNomMesh("NOT ASSIGNED")
89 iter_3.SetField("Field XXX", 999, -1)
93 zone_1 = homard.CreateZone("Zone 1")
94 zone_1.SetBox(1.,2.,3.,4.,5.,6.)
95 zone_1.SetTypeZone(5454)
99 zone_2 = homard.CreateZone("Zone 2")
100 zone_2.SetSphere(12.3, 3.4, .56, 6.5)
101 zone_2.SetTypeZone(6545)
105 homard.AssocieCasIteration("Case 1", "Iteration 1")
106 homard.AssocieCasIteration("Case 1", "Iteration 2")
107 homard.AssocieHypoIteration("Iteration 1", "Hypothesis 1")
108 homard.AssocieHypoZone("Zone 1", "Hypothesis 1")
109 homard.AssocieHypoIteration("Iteration 2", "Hypothesis 2")
110 homard.AssocieHypoZone("Zone 2", "Hypothesis 2")
111 homard.AssocieIterationIteration("Iteration 1", "Iteration 2")
115 salome.myStudyManager.SaveAs(fname, study, 0)
119 salome.myStudyManager.Close(study)
123 def test_load(fname):
127 study = salome.myStudyManager.Open(fname)
131 comp = study.FindComponent("HOMARD")
132 builder = study.NewBuilder()
133 builder.LoadWith(comp, homard)
137 print homard.GetCurrentStudy()._get_StudyId()
141 case_1 = homard.GetCas("Case 1")
142 print "Case: ", case_1.GetNomCas()
143 print "-> nom dir:", case_1.GetNomDir()
144 print "-> type conf:", case_1.GetTypeConf()
145 print "-> boite:", case_1.GetBoiteEnglobante()
150 hypo_1 = homard.GetHypothesis("Hypothesis 1")
151 print "Hypothesis: ", hypo_1.GetNomHypothesis()
152 print "-> type:", hypo_1.GetTypeAdapRaffDera()
153 print "-> field name:", hypo_1.GetFieldName()
154 print "-> composants:", hypo_1.GetComposants()
155 print "-> zones:", hypo_1.GetZones()
160 hypo_2 = homard.GetHypothesis("Hypothesis 2")
161 print "Hypothesis: ", hypo_2.GetNomHypothesis()
162 print "-> type:", hypo_2.GetTypeAdapRaffDera()
163 print "-> field name:", hypo_2.GetFieldName()
164 print "-> composants:", hypo_2.GetComposants()
165 print "-> zones:", hypo_2.GetZones()
170 zone_1 = homard.GetZone("Zone 1")
171 print "Zone: ", zone_1.GetNomZone()
172 print "-> type zone:", zone_1.GetTypeZone()
173 print "-> shere:", zone_1.GetSphere()
174 print "-> box:", zone_1.GetBox()
175 print "-> hypotheses:", zone_1.GetHypo()
180 zone_2 = homard.GetZone("Zone 2")
181 print "Zone: ", zone_2.GetNomZone()
182 print "-> type zone:", zone_2.GetTypeZone()
183 print "-> shere:", zone_2.GetSphere()
184 print "-> box:", zone_2.GetBox()
185 print "-> hypotheses:", zone_2.GetHypo()
190 iter_1 = homard.GetIteration("Iteration 1")
191 print "Iteration: ", iter_1.GetNomIter()
192 print "-> etat:", iter_1.GetEtat()
193 print "-> num iter:", iter_1.GetNumIter()
194 print "-> nom mesh:", iter_1.GetNomMesh()
195 print "-> mesh file:", iter_1.GetMeshFile()
196 print "-> field:", iter_1.GetFieldFileName()
197 print "-> time step:", iter_1.GetTimeStep()
198 print "-> rank:", iter_1.GetRank()
199 print "-> parent iter:", iter_1.GetIterParent()
200 print "-> hypothesis:", iter_1.GetNomHypo()
201 print "-> case:", iter_1.GetNomCas()
206 iter_2 = homard.GetIteration("Iteration 2")
207 print "Iteration: ", iter_2.GetNomIter()
208 print "-> etat:", iter_2.GetEtat()
209 print "-> num iter:", iter_2.GetNumIter()
210 print "-> nom mesh:", iter_2.GetNomMesh()
211 print "-> mesh file:", iter_2.GetMeshFile()
212 print "-> field:", iter_2.GetFieldFileName()
213 print "-> time step:", iter_2.GetTimeStep()
214 print "-> rank:", iter_2.GetRank()
215 print "-> parent iter:", iter_2.GetIterParent()
216 print "-> hypothesis:", iter_2.GetNomHypo()
217 print "-> case:", iter_2.GetNomCas()
222 iter_3 = homard.GetIteration("Iteration 3")
223 print "Iteration: ", iter_3.GetNomIter()
224 print "-> etat:", iter_3.GetEtat()
225 print "-> num iter:", iter_3.GetNumIter()
226 print "-> nom mesh:", iter_3.GetNomMesh()
227 print "-> mesh file:", iter_3.GetMeshFile()
228 print "-> field:", iter_3.GetFieldFileName()
229 print "-> time step:", iter_3.GetTimeStep()
230 print "-> rank:", iter_3.GetRank()
231 print "-> parent iter:", iter_3.GetIterParent()
232 print "-> hypothesis:", iter_3.GetNomHypo()
233 print "-> case:", iter_3.GetNomCas()
237 filename = "/tmp/save_homard.hdf"