Salome HOME
test on stream works
[modules/hydro.git] / doc / salome / examples / h018_streamInterpolation.py
1 # -*- coding: utf-8 -*-
2
3 import os
4 HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO")
5
6 import sys
7 import salome
8
9 salome.salome_init()
10 theStudy = salome.myStudy
11
12 #----------------------
13 # --- HYDRO
14 #----------------------
15
16 from HYDROPy import *
17 from PyQt4.QtCore import *
18 from PyQt4.QtGui import *
19
20 hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() )
21
22 hydro_doc.SetLocalCS( 0.000, 0.000 )
23
24 Strickler_table_1 = hydro_doc.CreateObject( KIND_STRICKLER_TABLE )
25 Strickler_table_1.SetName( "Strickler table_1" )
26
27 Strickler_table_1.SetAttrName( "CODE_06" )
28
29 Strickler_table_1.Set( u"Pelouses et pâturages naturels", 1.0321 )
30 Strickler_table_1.SetAttrValue( u"Pelouses et pâturages naturels", "321" )
31 Strickler_table_1.SetColor( u"Pelouses et pâturages naturels", QColor( 204, 242, 77 ) )
32
33 Strickler_table_1.Set( u"Aéroports", 1.0124 )
34 Strickler_table_1.SetAttrValue( u"Aéroports", "124" )
35 Strickler_table_1.SetColor( u"Aéroports", QColor( 230, 204, 230 ) )
36
37 Strickler_table_1.Set( u"Systèmes culturaux et parcellaires complexes", 1.0242 )
38 Strickler_table_1.SetAttrValue( u"Systèmes culturaux et parcellaires complexes", "242" )
39 Strickler_table_1.SetColor( u"Systèmes culturaux et parcellaires complexes", QColor( 255, 230, 77 ) )
40
41 Strickler_table_1.Set( u"Cultures annuelles associées à des cultures permanentes", 1.0241 )
42 Strickler_table_1.SetAttrValue( u"Cultures annuelles associées à des cultures permanentes", "241" )
43 Strickler_table_1.SetColor( u"Cultures annuelles associées à des cultures permanentes", QColor( 255, 230, 166 ) )
44
45 Strickler_table_1.Set( u"Forêt et végétation arbustive en mutation", 1.0324 )
46 Strickler_table_1.SetAttrValue( u"Forêt et végétation arbustive en mutation", "324" )
47 Strickler_table_1.SetColor( u"Forêt et végétation arbustive en mutation", QColor( 166, 242, 0 ) )
48
49 Strickler_table_1.Set( u"Décharges", 1.0132 )
50 Strickler_table_1.SetAttrValue( u"Décharges", "132" )
51 Strickler_table_1.SetColor( u"Décharges", QColor( 166, 77, 0 ) )
52
53 Strickler_table_1.Set( u"Végétation clairsemée", 1.0333 )
54 Strickler_table_1.SetAttrValue( u"Végétation clairsemée", "333" )
55 Strickler_table_1.SetColor( u"Végétation clairsemée", QColor( 204, 255, 204 ) )
56
57 Strickler_table_1.Set( u"Prairies et autres surfaces toujours en herbe à usage agricole", 1.0231 )
58 Strickler_table_1.SetAttrValue( u"Prairies et autres surfaces toujours en herbe à usage agricole", "231" )
59 Strickler_table_1.SetColor( u"Prairies et autres surfaces toujours en herbe à usage agricole", QColor( 230, 230, 77 ) )
60
61 Strickler_table_1.Set( u"Périmètres irrigués en permanence", 1.0212 )
62 Strickler_table_1.SetAttrValue( u"Périmètres irrigués en permanence", "212" )
63 Strickler_table_1.SetColor( u"Périmètres irrigués en permanence", QColor( 255, 255, 0 ) )
64
65 Strickler_table_1.Set( u"Plans d'eau", 1.0512 )
66 Strickler_table_1.SetAttrValue( u"Plans d'eau", "512" )
67 Strickler_table_1.SetColor( u"Plans d'eau", QColor( 128, 242, 230 ) )
68
69 Strickler_table_1.Set( u"Territoires agroforestiers", 1.0244 )
70 Strickler_table_1.SetAttrValue( u"Territoires agroforestiers", "244" )
71 Strickler_table_1.SetColor( u"Territoires agroforestiers", QColor( 242, 204, 166 ) )
72
73 Strickler_table_1.Set( u"Forêts mélangées", 1.0313 )
74 Strickler_table_1.SetAttrValue( u"Forêts mélangées", "313" )
75 Strickler_table_1.SetColor( u"Forêts mélangées", QColor( 77, 255, 0 ) )
76
77 Strickler_table_1.Set( u"Glaciers et neiges éternelles", 1.0335 )
78 Strickler_table_1.SetAttrValue( u"Glaciers et neiges éternelles", "335" )
79 Strickler_table_1.SetColor( u"Glaciers et neiges éternelles", QColor( 166, 230, 204 ) )
80
81 Strickler_table_1.Set( u"Plages, dunes et sable", 1.0331 )
82 Strickler_table_1.SetAttrValue( u"Plages, dunes et sable", "331" )
83 Strickler_table_1.SetColor( u"Plages, dunes et sable", QColor( 230, 230, 230 ) )
84
85 Strickler_table_1.Set( u"Zones incendiées", 1.0334 )
86 Strickler_table_1.SetAttrValue( u"Zones incendiées", "334" )
87 Strickler_table_1.SetColor( u"Zones incendiées", QColor( 0, 0, 0 ) )
88
89 Strickler_table_1.Set( u"Tissu urbain continu", 1.0111 )
90 Strickler_table_1.SetAttrValue( u"Tissu urbain continu", "111" )
91 Strickler_table_1.SetColor( u"Tissu urbain continu", QColor( 230, 0, 77 ) )
92
93 Strickler_table_1.Set( u"Chantiers", 1.0133 )
94 Strickler_table_1.SetAttrValue( u"Chantiers", "133" )
95 Strickler_table_1.SetColor( u"Chantiers", QColor( 255, 77, 255 ) )
96
97 Strickler_table_1.Set( u"Estuaires", 1.0522 )
98 Strickler_table_1.SetAttrValue( u"Estuaires", "522" )
99 Strickler_table_1.SetColor( u"Estuaires", QColor( 166, 255, 230 ) )
100
101 Strickler_table_1.Set( u"Marais maritimes", 1.0421 )
102 Strickler_table_1.SetAttrValue( u"Marais maritimes", "421" )
103 Strickler_table_1.SetColor( u"Marais maritimes", QColor( 204, 204, 255 ) )
104
105 Strickler_table_1.Set( u"Forêts de conifères", 1.0312 )
106 Strickler_table_1.SetAttrValue( u"Forêts de conifères", "312" )
107 Strickler_table_1.SetColor( u"Forêts de conifères", QColor( 0, 166, 0 ) )
108
109 Strickler_table_1.Set( u"Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", 1.0243 )
110 Strickler_table_1.SetAttrValue( u"Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", "243" )
111 Strickler_table_1.SetColor( u"Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", QColor( 230, 204, 77 ) )
112
113 Strickler_table_1.Set( u"Tourbières", 1.0412 )
114 Strickler_table_1.SetAttrValue( u"Tourbières", "412" )
115 Strickler_table_1.SetColor( u"Tourbières", QColor( 77, 77, 255 ) )
116
117 Strickler_table_1.Set( u"Extraction de matériaux", 1.0131 )
118 Strickler_table_1.SetAttrValue( u"Extraction de matériaux", "131" )
119 Strickler_table_1.SetColor( u"Extraction de matériaux", QColor( 166, 0, 204 ) )
120
121 Strickler_table_1.Set( u"Réseaux routier et ferroviaire et espaces associés", 1.0122 )
122 Strickler_table_1.SetAttrValue( u"Réseaux routier et ferroviaire et espaces associés", "122" )
123 Strickler_table_1.SetColor( u"Réseaux routier et ferroviaire et espaces associés", QColor( 204, 0, 0 ) )
124
125 Strickler_table_1.Set( u"Mers et océans", 1.0523 )
126 Strickler_table_1.SetAttrValue( u"Mers et océans", "523" )
127 Strickler_table_1.SetColor( u"Mers et océans", QColor( 230, 242, 255 ) )
128
129 Strickler_table_1.Set( u"Equipements sportifs et de loisirs", 1.0142 )
130 Strickler_table_1.SetAttrValue( u"Equipements sportifs et de loisirs", "142" )
131 Strickler_table_1.SetColor( u"Equipements sportifs et de loisirs", QColor( 255, 230, 255 ) )
132
133 Strickler_table_1.Set( u"Forêts de feuillus", 1.0311 )
134 Strickler_table_1.SetAttrValue( u"Forêts de feuillus", "311" )
135 Strickler_table_1.SetColor( u"Forêts de feuillus", QColor( 128, 255, 0 ) )
136
137 Strickler_table_1.Set( u"Vergers et petits fruits", 1.0222 )
138 Strickler_table_1.SetAttrValue( u"Vergers et petits fruits", "222" )
139 Strickler_table_1.SetColor( u"Vergers et petits fruits", QColor( 242, 166, 77 ) )
140
141 Strickler_table_1.Set( u"Végétation sclérophylle", 1.0323 )
142 Strickler_table_1.SetAttrValue( u"Végétation sclérophylle", "323" )
143 Strickler_table_1.SetColor( u"Végétation sclérophylle", QColor( 166, 230, 77 ) )
144
145 Strickler_table_1.Set( u"Landes et broussailles", 1.0322 )
146 Strickler_table_1.SetAttrValue( u"Landes et broussailles", "322" )
147 Strickler_table_1.SetColor( u"Landes et broussailles", QColor( 166, 255, 128 ) )
148
149 Strickler_table_1.Set( u"Tissu urbain discontinu", 1.0112 )
150 Strickler_table_1.SetAttrValue( u"Tissu urbain discontinu", "112" )
151 Strickler_table_1.SetColor( u"Tissu urbain discontinu", QColor( 255, 0, 0 ) )
152
153 Strickler_table_1.Set( u"Cours et voies d'eau", 1.0511 )
154 Strickler_table_1.SetAttrValue( u"Cours et voies d'eau", "511" )
155 Strickler_table_1.SetColor( u"Cours et voies d'eau", QColor( 0, 204, 242 ) )
156
157 Strickler_table_1.Set( u"Oliveraies", 1.0223 )
158 Strickler_table_1.SetAttrValue( u"Oliveraies", "223" )
159 Strickler_table_1.SetColor( u"Oliveraies", QColor( 230, 166, 0 ) )
160
161 Strickler_table_1.Set( u"Vignobles", 1.0221 )
162 Strickler_table_1.SetAttrValue( u"Vignobles", "221" )
163 Strickler_table_1.SetColor( u"Vignobles", QColor( 230, 128, 0 ) )
164
165 Strickler_table_1.Set( u"Rizières", 1.0213 )
166 Strickler_table_1.SetAttrValue( u"Rizières", "213" )
167 Strickler_table_1.SetColor( u"Rizières", QColor( 230, 230, 0 ) )
168
169 Strickler_table_1.Set( u"Zones portuaires", 1.0123 )
170 Strickler_table_1.SetAttrValue( u"Zones portuaires", "123" )
171 Strickler_table_1.SetColor( u"Zones portuaires", QColor( 230, 204, 204 ) )
172
173 Strickler_table_1.Set( u"Zones industrielles ou commerciales et installations publiques", 1.0121 )
174 Strickler_table_1.SetAttrValue( u"Zones industrielles ou commerciales et installations publiques", "121" )
175 Strickler_table_1.SetColor( u"Zones industrielles ou commerciales et installations publiques", QColor( 204, 77, 242 ) )
176
177 Strickler_table_1.Set( u"Marais salants", 1.0422 )
178 Strickler_table_1.SetAttrValue( u"Marais salants", "422" )
179 Strickler_table_1.SetColor( u"Marais salants", QColor( 230, 230, 255 ) )
180
181 Strickler_table_1.Set( u"Marais intérieurs", 1.0411 )
182 Strickler_table_1.SetAttrValue( u"Marais intérieurs", "411" )
183 Strickler_table_1.SetColor( u"Marais intérieurs", QColor( 166, 166, 255 ) )
184
185 Strickler_table_1.Set( u"Espaces verts urbains", 1.0141 )
186 Strickler_table_1.SetAttrValue( u"Espaces verts urbains", "141" )
187 Strickler_table_1.SetColor( u"Espaces verts urbains", QColor( 255, 166, 255 ) )
188
189 Strickler_table_1.Set( u"Lagunes littorales", 1.0521 )
190 Strickler_table_1.SetAttrValue( u"Lagunes littorales", "521" )
191 Strickler_table_1.SetColor( u"Lagunes littorales", QColor( 0, 255, 166 ) )
192
193 Strickler_table_1.Set( u"Roches nues", 1.0332 )
194 Strickler_table_1.SetAttrValue( u"Roches nues", "332" )
195 Strickler_table_1.SetColor( u"Roches nues", QColor( 204, 204, 204 ) )
196
197 Strickler_table_1.Set( u"Terres arables hors périmètres d'irrigation", 1.0211 )
198 Strickler_table_1.SetAttrValue( u"Terres arables hors périmètres d'irrigation", "211" )
199 Strickler_table_1.SetColor( u"Terres arables hors périmètres d'irrigation", QColor( 255, 255, 168 ) )
200
201 Strickler_table_1.Set( u"Zones intertidales", 1.0423 )
202 Strickler_table_1.SetAttrValue( u"Zones intertidales", "423" )
203 Strickler_table_1.SetColor( u"Zones intertidales", QColor( 166, 166, 230 ) )
204
205
206 Strickler_table_1.Update()
207
208 axe = hydro_doc.CreateObject( KIND_POLYLINEXY )
209 axe.SetName( "axe" )
210
211 axe.SetZLevel( 0 )
212
213 axe.AddSection( "Section_1", 1, 0 )
214 axe.AddPoint( 0, gp_XY( 107.09, -10.91 ) )
215 axe.AddPoint( 0, gp_XY( 102.60, 39.37 ) )
216 axe.AddPoint( 0, gp_XY( 70.28, 83.06 ) )
217 axe.AddPoint( 0, gp_XY( 28.39, 106.10 ) )
218 axe.AddPoint( 0, gp_XY( -14.11, 109.99 ) )
219
220 axe.Update()
221
222
223 domain = hydro_doc.CreateObject( KIND_POLYLINEXY )
224 domain.SetName( "domain" )
225
226 domain.SetZLevel( 3 )
227
228 domain.AddSection( "Section_1", 0, 1 )
229 domain.AddPoint( 0, gp_XY( 0.46, 0.37 ) )
230 domain.AddPoint( 0, gp_XY( 125.71, 0.18 ) )
231 domain.AddPoint( 0, gp_XY( 109.60, 112.58 ) )
232 domain.AddPoint( 0, gp_XY( 1.03, 123.51 ) )
233
234 domain.Update()
235
236
237 bathyFlat = hydro_doc.CreateObject( KIND_BATHYMETRY )
238 bathyFlat.SetName( "bathyFlat" )
239
240 bathyFlat.SetAltitudesInverted( 0 )
241 if not(bathyFlat.ImportFromFile( os.path.join(HYDRO_SAMPLES, "bathyFlat.xyz" ))):
242   raise ValueError('problem while loading bathymetry')
243
244 bathyFlat.Update()
245
246 profiles = hydro_doc.CreateObject( KIND_PROFILE )
247 profiles.SetName( "profiles" )
248 badProfilesIds=[]
249 isToProject=True
250 nbp = profiles.ImportFromFile(hydro_doc, os.path.join(HYDRO_SAMPLES, "profilsStream.xyz"), badProfilesIds, isToProject)
251 print "nombre profils: " , nbp
252 if not(nbp):
253   raise ValueError('problem while loading profiles')
254 #profiles.Update()
255
256 nomsprofs = ["Profile_%d"%i for i in range(1,nbp+1)]
257 seqProfs = hydro_doc.FindObjectsByNames(nomsprofs)
258
259
260 plaine = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
261 plaine.SetName( "plaine" )
262
263 plaine.SetZLevel( 1 )
264
265 plaine.SetFillingColor( QColor( 185, 171, 101, 255 ) )
266
267 plaine.SetAltitudeObject( bathyFlat )
268 plaine.SetPolyline( domain )
269
270 plaine.Update()
271
272
273 Stream_1 = hydro_doc.CreateObject( KIND_STREAM )
274 Stream_1.SetName( "Stream_1" )
275
276 Stream_1.SetZLevel( 2 )
277
278 Stream_1.SetHydraulicAxis( axe )
279 for profil in seqProfs:
280   Stream_1.AddProfile(profil)
281
282 Stream_1.SetDDZ( 0.200 )
283 Stream_1.SetSpatialStep( 0.5 )
284
285 Stream_1.Update()
286
287
288 # Calculation case
289 Case_1 = hydro_doc.CreateObject( KIND_CALCULATION )
290 Case_1.SetName( "Case_1" )
291
292 Case_1.SetAssignmentMode( HYDROData_CalculationCase.MANUAL )
293 Case_1.AddGeometryObject( plaine )
294 Case_1.AddGeometryObject( Stream_1 )
295
296 case_geom_group = plaine.GetGroup( 0 )
297 Case_1.AddGeometryGroup( case_geom_group )
298 case_geom_group = Stream_1.GetGroup( 2 )
299 Case_1.AddGeometryGroup( case_geom_group )
300 case_geom_group = Stream_1.GetGroup( 0 )
301 Case_1.AddGeometryGroup( case_geom_group )
302 case_geom_group = Stream_1.GetGroup( 3 )
303 Case_1.AddGeometryGroup( case_geom_group )
304 case_geom_group = Stream_1.GetGroup( 1 )
305 Case_1.AddGeometryGroup( case_geom_group )
306 Case_1.SetBoundaryPolyline( domain )
307 Case_1.SetStricklerTable( Strickler_table_1 )
308
309 # Start the algorithm of the partition and assignment
310 Case_1.Update()
311 Reg_riveGauche = hydro_doc.FindObjectByName( "Case_1_Reg_1" )
312 Case_1_Zone_1 = hydro_doc.FindObjectByName( "Case_1_Zone_1" )
313 Case_1_Zone_1.SetColor( QColor( 156, 192, 64 ))
314 Reg_riveGauche.AddZone( Case_1_Zone_1 )
315 Reg_litMineur = hydro_doc.FindObjectByName( "Case_1_Reg_2" )
316 Case_1_Zone_2 = hydro_doc.FindObjectByName( "Case_1_Zone_2" )
317 Case_1_Zone_2.SetMergeType( HYDROData_Zone.Merge_Object )
318 Stream_1_Altitude_1 = hydro_doc.FindObjectByName( "Stream_1_Altitude_1" )
319 Case_1_Zone_2.SetMergeObject( Stream_1_Altitude_1 )
320 Case_1_Zone_2.SetColor( QColor( 64, 75, 192 ))
321 Reg_litMineur.AddZone( Case_1_Zone_2 )
322 Reg_riveDroite = hydro_doc.FindObjectByName( "Case_1_Reg_3" )
323 Case_1_Zone_3 = hydro_doc.FindObjectByName( "Case_1_Zone_3" )
324 Case_1_Zone_3.SetColor( QColor( 192, 109, 64 ))
325 Reg_riveDroite.AddZone( Case_1_Zone_3 )
326 Reg_riveGauche.SetName( "Reg_riveGauche" )
327 Reg_litMineur.SetName( "Reg_litMineur" )
328 Reg_riveDroite.SetName( "Reg_riveDroite" )
329
330 # Export of the calculation case
331 Case_1_entry = Case_1.Export( theStudy._get_StudyId() )
332
333 #----------------------
334 # --- Geometry
335 #----------------------
336
337 import GEOM
338 from salome.geom import geomBuilder
339 import math
340 import SALOMEDS
341 from salome.hydrotools.controls import controlGeomProps
342
343 # Get geometry shape and print debug information
344 print "Entry:", Case_1_entry
345 HYDRO_Case_1 = salome.IDToObject( str( Case_1_entry ) )
346 print "Geom shape:", HYDRO_Case_1
347 print "Geom shape name:", HYDRO_Case_1.GetName()
348
349 geompy = geomBuilder.New(theStudy)
350
351 # --- manual definition: geometrical faces
352 [riveGauche,litMineur,riveDroite] = geompy.SubShapeAll(HYDRO_Case_1, geompy.ShapeType["FACE"])
353
354 # --- manual definition: useful groups of edges
355 Case_1_plaine_Outer = geompy.CreateGroup(HYDRO_Case_1, geompy.ShapeType["EDGE"])
356 geompy.UnionIDs(Case_1_plaine_Outer, [4, 12, 19, 23, 25, 21, 14, 9])
357 sections = geompy.CreateGroup(HYDRO_Case_1, geompy.ShapeType["EDGE"])
358 geompy.UnionIDs(sections, [14, 12])
359
360 # --- publish in study
361 geompy.addToStudyInFather( HYDRO_Case_1, riveGauche, 'riveGauche' )
362 geompy.addToStudyInFather( HYDRO_Case_1, litMineur, 'litMineur' )
363 geompy.addToStudyInFather( HYDRO_Case_1, riveDroite, 'riveDroite' )
364 geompy.addToStudyInFather( HYDRO_Case_1, sections, 'sections' )
365
366 # --- basic properties control: edges length, surfaces
367
368 controlGeomProps(geompy, riveGauche, 355.795218, 7765.650632)
369 controlGeomProps(geompy, litMineur,  383.674511, 3410.00875 )
370 controlGeomProps(geompy, riveDroite, 419.322218, 2549.630118)
371
372 #----------------------
373 # --- Meshing
374 #----------------------
375
376 med_file = r'/tmp/plaine.med'
377 try:
378   os.remove(med_file)
379 except OSError:
380   pass
381
382 import  SMESH, SALOMEDS
383 from salome.smesh import smeshBuilder
384 from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats
385
386 smesh = smeshBuilder.New(theStudy)
387
388 # --- algorithms and hypothesis
389 plaine = smesh.Mesh(HYDRO_Case_1)
390
391 NETGEN_2D = plaine.Triangle(algo=smeshBuilder.NETGEN_1D2D)
392 NETGEN_2D_Parameters_1 = NETGEN_2D.Parameters()
393 NETGEN_2D_Parameters_1.SetMaxSize( 10 )
394 NETGEN_2D_Parameters_1.SetSecondOrder( 0 )
395 NETGEN_2D_Parameters_1.SetOptimize( 1 )
396 NETGEN_2D_Parameters_1.SetFineness( 3 )
397 NETGEN_2D_Parameters_1.SetMinSize( 1 )
398 NETGEN_2D_Parameters_1.SetUseSurfaceCurvature( 1 )
399 NETGEN_2D_Parameters_1.SetFuseEdges( 1 )
400 NETGEN_2D_Parameters_1.SetQuadAllowed( 0 )
401
402 algo2D_litMineur = plaine.Quadrangle(algo=smeshBuilder.QUADRANGLE,geom=litMineur)
403 algo1D_litMineur = plaine.Segment(geom=litMineur)
404 hypo1D_litMineur = algo1D_litMineur.NumberOfSegments(60)
405 subMesh_litMineur = algo1D_litMineur.GetSubMesh()
406 smesh.SetName(subMesh_litMineur, "litMineur")
407
408 algo1D_sections = plaine.Segment(geom=sections)
409 hypo1D_sections = algo1D_sections.NumberOfSegments(20)
410 hypo1D_sections.SetDistrType( 0 )
411 subMesh_sections = algo1D_sections.GetSubMesh()
412 smesh.SetName(subMesh_sections, "sections")
413
414 isDone = plaine.SetMeshOrder( [ [ subMesh_sections, subMesh_litMineur ] ])
415
416 # --- compute mesh
417 isDone = plaine.Compute()
418 isDone = plaine.SplitQuadObject( plaine, 1 )
419 isDone = plaine.ReorientObject( plaine )
420
421 # --- geometrical groups of faces
422 riveGauche_1 = plaine.GroupOnGeom(riveGauche,'riveGauche',SMESH.FACE)
423 litMineur_2 = plaine.GroupOnGeom(litMineur,'litMineur',SMESH.FACE)
424 riveDroite_1 = plaine.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE)
425
426 # --- geometrical groups of edges
427 Case_1_plaine_Outer_1 = plaine.GroupOnGeom(Case_1_plaine_Outer,'Case_1_plaine_Outer',SMESH.EDGE)
428 sections_2 = plaine.GroupOnGeom(sections,'sections',SMESH.EDGE)
429
430 # --- geometrical groups of nodes
431 riveGauche_2 = plaine.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE)
432 litMineur_3 = plaine.GroupOnGeom(litMineur,'litMineur',SMESH.NODE)
433 riveDroite_2 = plaine.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE)
434 Case_1_plaine_Outer_2 = plaine.GroupOnGeom(Case_1_plaine_Outer,'Case_1_plaine_Outer',SMESH.NODE)
435 sections_3 = plaine.GroupOnGeom(sections,'sections',SMESH.NODE)
436
437 smesh.SetName(plaine, 'plaine')
438
439 plaine.SetAutoColor( 1 )
440 try:
441   plaine.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1)
442 except:
443   print 'ExportToMEDX() failed. Invalid file name?'
444
445 controlMeshStats(plaine, 1680, 227, 3251)
446 controlSubMeshStats(litMineur_2, 2400)
447 controlSubMeshStats(riveDroite_1, 271)
448 controlSubMeshStats(riveGauche_1, 580)
449
450 #----------------------
451 # --- Z interpolation with HYDRO
452 #----------------------
453
454 from salome.hydrotools.interpolZ import interpolZ, createZfield2
455 from salome.hydrotools.controls import controlStatZ
456
457 # --- case name in HYDRO
458 nomCas = 'Case_1'
459
460 # --- med file 2D(x,y) of the case produced by SMESH
461 fichierMaillage = med_file
462
463 # --- dictionary [med group name] = region name
464 dicoGroupeRegion= dict(litMineur  = 'Reg_litMineur',
465                        riveDroite = 'Reg_riveDroite',
466                        riveGauche = 'Reg_riveGauche',
467                        )
468 # --- value to use for Z when the node is not in a region (used to detect problems)
469 zUndef = 110
470
471 # --- Z interpolation on the bathymety/altimetry on the mesh nodes
472 statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef)
473 refstatz = {'riveDroite': (99.8278, 100.8), 'riveGauche': (100.0, 100.0), 'litMineur': (80.4541, 100.8)}
474 controlStatZ(statz, refstatz)
475
476 # --- add a field on nodes of type double with z values, named "BOTTOM"
477 createZfield2(fichierMaillage)
478
479
480
481 if salome.sg.hasDesktop():
482   salome.sg.updateObjBrowser(1)