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