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