Salome HOME
Python test scripts, first pass
[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()
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( "Pelouses et pâturages naturels", 1.0321 )
34 Strickler_table_1.SetAttrValue( "Pelouses et pâturages naturels", "321" )
35 Strickler_table_1.SetColor( "Pelouses et pâturages naturels", QColor( 204, 242, 77 ) )
36
37 Strickler_table_1.Set( "Aéroports", 1.0124 )
38 Strickler_table_1.SetAttrValue( "Aéroports", "124" )
39 Strickler_table_1.SetColor( "Aéroports", QColor( 230, 204, 230 ) )
40
41 Strickler_table_1.Set( "Systèmes culturaux et parcellaires complexes", 1.0242 )
42 Strickler_table_1.SetAttrValue( "Systèmes culturaux et parcellaires complexes", "242" )
43 Strickler_table_1.SetColor( "Systèmes culturaux et parcellaires complexes", QColor( 255, 230, 77 ) )
44
45 Strickler_table_1.Set( "Cultures annuelles associées à des cultures permanentes", 1.0241 )
46 Strickler_table_1.SetAttrValue( "Cultures annuelles associées à des cultures permanentes", "241" )
47 Strickler_table_1.SetColor( "Cultures annuelles associées à des cultures permanentes", QColor( 255, 230, 166 ) )
48
49 Strickler_table_1.Set( "Forêt et végétation arbustive en mutation", 1.0324 )
50 Strickler_table_1.SetAttrValue( "Forêt et végétation arbustive en mutation", "324" )
51 Strickler_table_1.SetColor( "Forêt et végétation arbustive en mutation", QColor( 166, 242, 0 ) )
52
53 Strickler_table_1.Set( "Décharges", 1.0132 )
54 Strickler_table_1.SetAttrValue( "Décharges", "132" )
55 Strickler_table_1.SetColor( "Décharges", QColor( 166, 77, 0 ) )
56
57 Strickler_table_1.Set( "Végétation clairsemée", 1.0333 )
58 Strickler_table_1.SetAttrValue( "Végétation clairsemée", "333" )
59 Strickler_table_1.SetColor( "Végétation clairsemée", QColor( 204, 255, 204 ) )
60
61 Strickler_table_1.Set( "Prairies et autres surfaces toujours en herbe à usage agricole", 1.0231 )
62 Strickler_table_1.SetAttrValue( "Prairies et autres surfaces toujours en herbe à usage agricole", "231" )
63 Strickler_table_1.SetColor( "Prairies et autres surfaces toujours en herbe à usage agricole", QColor( 230, 230, 77 ) )
64
65 Strickler_table_1.Set( "Périmètres irrigués en permanence", 1.0212 )
66 Strickler_table_1.SetAttrValue( "Périmètres irrigués en permanence", "212" )
67 Strickler_table_1.SetColor( "Périmètres irrigués en permanence", QColor( 255, 255, 0 ) )
68
69 Strickler_table_1.Set( "Plans d'eau", 1.0512 )
70 Strickler_table_1.SetAttrValue( "Plans d'eau", "512" )
71 Strickler_table_1.SetColor( "Plans d'eau", QColor( 128, 242, 230 ) )
72
73 Strickler_table_1.Set( "Territoires agroforestiers", 1.0244 )
74 Strickler_table_1.SetAttrValue( "Territoires agroforestiers", "244" )
75 Strickler_table_1.SetColor( "Territoires agroforestiers", QColor( 242, 204, 166 ) )
76
77 Strickler_table_1.Set( "Forêts mélangées", 1.0313 )
78 Strickler_table_1.SetAttrValue( "Forêts mélangées", "313" )
79 Strickler_table_1.SetColor( "Forêts mélangées", QColor( 77, 255, 0 ) )
80
81 Strickler_table_1.Set( "Glaciers et neiges éternelles", 1.0335 )
82 Strickler_table_1.SetAttrValue( "Glaciers et neiges éternelles", "335" )
83 Strickler_table_1.SetColor( "Glaciers et neiges éternelles", QColor( 166, 230, 204 ) )
84
85 Strickler_table_1.Set( "Plages, dunes et sable", 1.0331 )
86 Strickler_table_1.SetAttrValue( "Plages, dunes et sable", "331" )
87 Strickler_table_1.SetColor( "Plages, dunes et sable", QColor( 230, 230, 230 ) )
88
89 Strickler_table_1.Set( "Zones incendiées", 1.0334 )
90 Strickler_table_1.SetAttrValue( "Zones incendiées", "334" )
91 Strickler_table_1.SetColor( "Zones incendiées", QColor( 0, 0, 0 ) )
92
93 Strickler_table_1.Set( "Tissu urbain continu", 1.0111 )
94 Strickler_table_1.SetAttrValue( "Tissu urbain continu", "111" )
95 Strickler_table_1.SetColor( "Tissu urbain continu", QColor( 230, 0, 77 ) )
96
97 Strickler_table_1.Set( "Chantiers", 1.0133 )
98 Strickler_table_1.SetAttrValue( "Chantiers", "133" )
99 Strickler_table_1.SetColor( "Chantiers", QColor( 255, 77, 255 ) )
100
101 Strickler_table_1.Set( "Estuaires", 1.0522 )
102 Strickler_table_1.SetAttrValue( "Estuaires", "522" )
103 Strickler_table_1.SetColor( "Estuaires", QColor( 166, 255, 230 ) )
104
105 Strickler_table_1.Set( "Marais maritimes", 1.0421 )
106 Strickler_table_1.SetAttrValue( "Marais maritimes", "421" )
107 Strickler_table_1.SetColor( "Marais maritimes", QColor( 204, 204, 255 ) )
108
109 Strickler_table_1.Set( "Forêts de conifères", 1.0312 )
110 Strickler_table_1.SetAttrValue( "Forêts de conifères", "312" )
111 Strickler_table_1.SetColor( "Forêts de conifères", QColor( 0, 166, 0 ) )
112
113 Strickler_table_1.Set( "Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", 1.0243 )
114 Strickler_table_1.SetAttrValue( "Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", "243" )
115 Strickler_table_1.SetColor( "Surfaces essentiellement agricoles, interrompues par des espaces naturels importants", QColor( 230, 204, 77 ) )
116
117 Strickler_table_1.Set( "Tourbières", 1.0412 )
118 Strickler_table_1.SetAttrValue( "Tourbières", "412" )
119 Strickler_table_1.SetColor( "Tourbières", QColor( 77, 77, 255 ) )
120
121 Strickler_table_1.Set( "Extraction de matériaux", 1.0131 )
122 Strickler_table_1.SetAttrValue( "Extraction de matériaux", "131" )
123 Strickler_table_1.SetColor( "Extraction de matériaux", QColor( 166, 0, 204 ) )
124
125 Strickler_table_1.Set( "Réseaux routier et ferroviaire et espaces associés", 1.0122 )
126 Strickler_table_1.SetAttrValue( "Réseaux routier et ferroviaire et espaces associés", "122" )
127 Strickler_table_1.SetColor( "Réseaux routier et ferroviaire et espaces associés", QColor( 204, 0, 0 ) )
128
129 Strickler_table_1.Set( "Mers et océans", 1.0523 )
130 Strickler_table_1.SetAttrValue( "Mers et océans", "523" )
131 Strickler_table_1.SetColor( "Mers et océans", QColor( 230, 242, 255 ) )
132
133 Strickler_table_1.Set( "Equipements sportifs et de loisirs", 1.0142 )
134 Strickler_table_1.SetAttrValue( "Equipements sportifs et de loisirs", "142" )
135 Strickler_table_1.SetColor( "Equipements sportifs et de loisirs", QColor( 255, 230, 255 ) )
136
137 Strickler_table_1.Set( "Forêts de feuillus", 1.0311 )
138 Strickler_table_1.SetAttrValue( "Forêts de feuillus", "311" )
139 Strickler_table_1.SetColor( "Forêts de feuillus", QColor( 128, 255, 0 ) )
140
141 Strickler_table_1.Set( "Vergers et petits fruits", 1.0222 )
142 Strickler_table_1.SetAttrValue( "Vergers et petits fruits", "222" )
143 Strickler_table_1.SetColor( "Vergers et petits fruits", QColor( 242, 166, 77 ) )
144
145 Strickler_table_1.Set( "Végétation sclérophylle", 1.0323 )
146 Strickler_table_1.SetAttrValue( "Végétation sclérophylle", "323" )
147 Strickler_table_1.SetColor( "Végétation sclérophylle", QColor( 166, 230, 77 ) )
148
149 Strickler_table_1.Set( "Landes et broussailles", 1.0322 )
150 Strickler_table_1.SetAttrValue( "Landes et broussailles", "322" )
151 Strickler_table_1.SetColor( "Landes et broussailles", QColor( 166, 255, 128 ) )
152
153 Strickler_table_1.Set( "Tissu urbain discontinu", 1.0112 )
154 Strickler_table_1.SetAttrValue( "Tissu urbain discontinu", "112" )
155 Strickler_table_1.SetColor( "Tissu urbain discontinu", QColor( 255, 0, 0 ) )
156
157 Strickler_table_1.Set( "Cours et voies d'eau", 1.0511 )
158 Strickler_table_1.SetAttrValue( "Cours et voies d'eau", "511" )
159 Strickler_table_1.SetColor( "Cours et voies d'eau", QColor( 0, 204, 242 ) )
160
161 Strickler_table_1.Set( "Oliveraies", 1.0223 )
162 Strickler_table_1.SetAttrValue( "Oliveraies", "223" )
163 Strickler_table_1.SetColor( "Oliveraies", QColor( 230, 166, 0 ) )
164
165 Strickler_table_1.Set( "Vignobles", 1.0221 )
166 Strickler_table_1.SetAttrValue( "Vignobles", "221" )
167 Strickler_table_1.SetColor( "Vignobles", QColor( 230, 128, 0 ) )
168
169 Strickler_table_1.Set( "Rizières", 1.0213 )
170 Strickler_table_1.SetAttrValue( "Rizières", "213" )
171 Strickler_table_1.SetColor( "Rizières", QColor( 230, 230, 0 ) )
172
173 Strickler_table_1.Set( "Zones portuaires", 1.0123 )
174 Strickler_table_1.SetAttrValue( "Zones portuaires", "123" )
175 Strickler_table_1.SetColor( "Zones portuaires", QColor( 230, 204, 204 ) )
176
177 Strickler_table_1.Set( "Zones industrielles ou commerciales et installations publiques", 1.0121 )
178 Strickler_table_1.SetAttrValue( "Zones industrielles ou commerciales et installations publiques", "121" )
179 Strickler_table_1.SetColor( "Zones industrielles ou commerciales et installations publiques", QColor( 204, 77, 242 ) )
180
181 Strickler_table_1.Set( "Marais salants", 1.0422 )
182 Strickler_table_1.SetAttrValue( "Marais salants", "422" )
183 Strickler_table_1.SetColor( "Marais salants", QColor( 230, 230, 255 ) )
184
185 Strickler_table_1.Set( "Marais intérieurs", 1.0411 )
186 Strickler_table_1.SetAttrValue( "Marais intérieurs", "411" )
187 Strickler_table_1.SetColor( "Marais intérieurs", QColor( 166, 166, 255 ) )
188
189 Strickler_table_1.Set( "Espaces verts urbains", 1.0141 )
190 Strickler_table_1.SetAttrValue( "Espaces verts urbains", "141" )
191 Strickler_table_1.SetColor( "Espaces verts urbains", QColor( 255, 166, 255 ) )
192
193 Strickler_table_1.Set( "Lagunes littorales", 1.0521 )
194 Strickler_table_1.SetAttrValue( "Lagunes littorales", "521" )
195 Strickler_table_1.SetColor( "Lagunes littorales", QColor( 0, 255, 166 ) )
196
197 Strickler_table_1.Set( "Roches nues", 1.0332 )
198 Strickler_table_1.SetAttrValue( "Roches nues", "332" )
199 Strickler_table_1.SetColor( "Roches nues", QColor( 204, 204, 204 ) )
200
201 Strickler_table_1.Set( "Terres arables hors périmètres d'irrigation", 1.0211 )
202 Strickler_table_1.SetAttrValue( "Terres arables hors périmètres d'irrigation", "211" )
203 Strickler_table_1.SetColor( "Terres arables hors périmètres d'irrigation", QColor( 255, 255, 168 ) )
204
205 Strickler_table_1.Set( "Zones intertidales", 1.0423 )
206 Strickler_table_1.SetAttrValue( "Zones intertidales", "423" )
207 Strickler_table_1.SetColor( "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()
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()
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
362 # --- manual identification of all useful edge groups (boundary conditions)
363
364 allEdgesIds = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
365 print("allEdgesIds", allEdgesIds)
366
367 (isDone, ClosedFreeBoundary, OpenFreeBoundary) = geompy.GetFreeBoundary(HYDRO_Case_1)
368 geompy.addToStudyInFather(HYDRO_Case_1, ClosedFreeBoundary[0], "ClosedFreeBoundary")
369
370 freeBoundary = geompy.ExtractShapes(ClosedFreeBoundary[0], geompy.ShapeType["EDGE"], True)
371 freeBoundaryIds = [ geompy.GetSubShapeID(HYDRO_Case_1, freeBoundary[i]) for i in range(len(freeBoundary)) ]
372 print("freeBoundaryIds", freeBoundaryIds)
373
374 edges_litMineur = geompy.GetSharedShapesMulti([HYDRO_Case_1, litMineur], geompy.ShapeType["EDGE"], True)
375 edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_Case_1, edges_litMineur[i]) for i in range(len(edges_litMineur)) ]
376 sectionsIds = [Id for Id in edges_litMineurIds if Id in freeBoundaryIds]
377 print("sectionsIds", sectionsIds)
378 sections = geompy.CreateGroup(HYDRO_Case_1, geompy.ShapeType["EDGE"])
379 geompy.UnionIDs(sections, sectionsIds)
380
381 # --- publish in study
382 geompy.addToStudyInFather( HYDRO_Case_1, riveGauche, 'riveGauche' )
383 geompy.addToStudyInFather( HYDRO_Case_1, litMineur, 'litMineur' )
384 geompy.addToStudyInFather( HYDRO_Case_1, riveDroite, 'riveDroite' )
385 geompy.addToStudyInFather( HYDRO_Case_1, sections, 'sections' )
386
387 # --- basic properties control: edges length, surfaces
388
389 controlGeomProps(geompy, riveGauche, 355.239855, 7755.628676)
390 controlGeomProps(geompy, litMineur,  383.395884, 3432.296956)
391 controlGeomProps(geompy, riveDroite, 419.214176, 2537.363869)
392
393 #----------------------
394 # --- Meshing
395 #----------------------
396
397 med_file = r'/tmp/plaine.med'
398 try:
399   os.remove(med_file)
400 except OSError:
401   pass
402
403 import  SMESH, SALOMEDS
404 from salome.smesh import smeshBuilder
405 from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats
406
407 smesh = smeshBuilder.New()
408
409 # --- algorithms and hypothesis
410 plaine = smesh.Mesh(HYDRO_Case_1)
411
412 NETGEN_2D = plaine.Triangle(algo=smeshBuilder.NETGEN_1D2D)
413 NETGEN_2D_Parameters_1 = NETGEN_2D.Parameters()
414 NETGEN_2D_Parameters_1.SetMaxSize( 10 )
415 NETGEN_2D_Parameters_1.SetSecondOrder( 0 )
416 NETGEN_2D_Parameters_1.SetOptimize( 1 )
417 NETGEN_2D_Parameters_1.SetFineness( 3 )
418 NETGEN_2D_Parameters_1.SetMinSize( 1 )
419 NETGEN_2D_Parameters_1.SetUseSurfaceCurvature( 1 )
420 NETGEN_2D_Parameters_1.SetFuseEdges( 1 )
421 NETGEN_2D_Parameters_1.SetQuadAllowed( 0 )
422
423 algo2D_litMineur = plaine.Quadrangle(algo=smeshBuilder.QUADRANGLE,geom=litMineur)
424 algo1D_litMineur = plaine.Segment(geom=litMineur)
425 hypo1D_litMineur = algo1D_litMineur.NumberOfSegments(60)
426 subMesh_litMineur = algo1D_litMineur.GetSubMesh()
427 smesh.SetName(subMesh_litMineur, "litMineur")
428
429 algo1D_sections = plaine.Segment(geom=sections)
430 hypo1D_sections = algo1D_sections.NumberOfSegments(20)
431 hypo1D_sections.SetDistrType( 0 )
432 subMesh_sections = algo1D_sections.GetSubMesh()
433 smesh.SetName(subMesh_sections, "sections")
434
435 isDone = plaine.SetMeshOrder( [ [ subMesh_sections, subMesh_litMineur ] ])
436
437 # --- compute mesh
438 isDone = plaine.Compute()
439 isDone = plaine.SplitQuadObject( plaine, 1 )
440 isDone = plaine.ReorientObject( plaine )
441
442 # --- geometrical groups of faces
443 riveGauche_1 = plaine.GroupOnGeom(riveGauche,'riveGauche',SMESH.FACE)
444 litMineur_2 = plaine.GroupOnGeom(litMineur,'litMineur',SMESH.FACE)
445 riveDroite_1 = plaine.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE)
446
447 # --- geometrical groups of edges
448 Case_1_plaine_Outer_1 = plaine.GroupOnGeom(Case_1_plaine_Outer,'Case_1_plaine_Outer',SMESH.EDGE)
449 sections_2 = plaine.GroupOnGeom(sections,'sections',SMESH.EDGE)
450
451 # --- geometrical groups of nodes
452 riveGauche_2 = plaine.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE)
453 litMineur_3 = plaine.GroupOnGeom(litMineur,'litMineur',SMESH.NODE)
454 riveDroite_2 = plaine.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE)
455 Case_1_plaine_Outer_2 = plaine.GroupOnGeom(Case_1_plaine_Outer,'Case_1_plaine_Outer',SMESH.NODE)
456 sections_3 = plaine.GroupOnGeom(sections,'sections',SMESH.NODE)
457
458 smesh.SetName(plaine, 'plaine')
459
460 plaine.SetAutoColor( 1 )
461 try:
462   plaine.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1)
463 except:
464   print('ExportToMEDX() failed. Invalid file name?')
465
466 controlMeshStats(plaine, 1680, 227, 3251)
467 controlSubMeshStats(litMineur_2, 2400)
468 controlSubMeshStats(riveDroite_1, 257)
469 controlSubMeshStats(riveGauche_1, 580)
470
471 #----------------------
472 # --- Z interpolation with HYDRO
473 #----------------------
474
475 from salome.hydrotools.interpolZ import interpolZ
476 from salome.hydrotools.controls import controlStatZ
477
478 # --- case name in HYDRO
479 nomCas = 'Case_1'
480
481 # --- med file 2D(x,y) of the case produced by SMESH
482 fichierMaillage = med_file
483
484 # --- dictionary [med group name] = region name
485 dicoGroupeRegion= dict(litMineur  = 'Reg_litMineur',
486                        riveDroite = 'Reg_riveDroite',
487                        riveGauche = 'Reg_riveGauche',
488                        )
489 # --- value to use for Z when the node is not in a region (used to detect problems)
490 zUndef = 110
491 # --- interpolation Method: 0 = nearest point on bathymetry (default), 1 = linear interpolation
492 interpolMethod = 0
493 # --- produce a 3D mesh (Z set to its value instead of 0
494 m3d = True
495
496 # --- Z interpolation on the bathymety/altimetry on the mesh nodes
497 statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod, m3d)
498 #print statz
499 refstatz = {'riveDroite': (100.0, 100.0, 100.0, 0.0, 100.0, 100.0),
500             'riveGauche': (100.0, 100.0, 100.0, 0.0, 100.0, 100.0),
501             'litMineur': (80.35, 100.0, 92.88, 4.82, 84.44, 100.0)}
502 controlStatZ(statz, refstatz)
503
504 # --- add a field on nodes of type double with z values, named "BOTTOM"
505 #createZfield2(fichierMaillage)
506
507
508
509 if salome.sg.hasDesktop():
510   salome.sg.updateObjBrowser()