@@ -114,12 +114,12 @@ def generate_2d_mesh_for_pentagrow(
114
114
Power of how much refinement on the le and te (and for now in the
115
115
"refine acute angle" as well)
116
116
n_power_field: float
117
- Coefficient ?? (Idk but not used here)
117
+ Coefficient ?? (Idk but not used here)
118
118
fuselage_mesh_size_factor : float
119
- Factor of the fuselage mesh size : the mesh size will be the mean
119
+ Factor of the fuselage mesh size : the mesh size will be the mean
120
120
fuselage width divided by this factor
121
121
wing_mesh_size_factor : float
122
- Factor of the wing mesh size : the mesh size will be the mean
122
+ Factor of the wing mesh size : the mesh size will be the mean
123
123
fuselage width divided by this factor
124
124
mesh_size_engines : float
125
125
Size of the engines mesh
@@ -241,7 +241,8 @@ def generate_2d_mesh_for_pentagrow(
241
241
mesh_size_by_group ["vort" ] = mesh_size_by_group ["fuselage" ] / 8
242
242
243
243
log .info (
244
- f"Mesh size fuselage={ ((fuselage_maxlen + fuselage_minlen ) / 2 ) / fuselage_mesh_size_factor :.3f} m" )
244
+ f"Mesh size fuselage={ ((fuselage_maxlen + fuselage_minlen ) / 2 ) / \
245
+ fuselage_mesh_size_factor :.3f} m" )
245
246
log .info (
246
247
f"Mesh size wing={ ((wing_maxlen * 0.8 + wing_minlen ) / 2 ) / wing_mesh_size_factor :.3f} m" )
247
248
log .info (f"Mesh size engine={ mesh_size_engines :.3f} m" )
@@ -260,7 +261,8 @@ def generate_2d_mesh_for_pentagrow(
260
261
261
262
model_part .mesh_size = lc
262
263
mesh_fields ["nbfields" ] += 1
263
- # To choose the size, we create a field with constant value containing only our list of surfaces, and give it the size
264
+ # To choose the size, we create a field with constant value containing only our list
265
+ # of surfaces, and give it the size
264
266
gmsh .model .mesh .field .add ("Constant" , mesh_fields ["nbfields" ])
265
267
gmsh .model .mesh .field .setNumbers (
266
268
mesh_fields ["nbfields" ], "SurfacesList" , model_part .surfaces_tags )
@@ -275,7 +277,8 @@ def generate_2d_mesh_for_pentagrow(
275
277
log .info ("Start refinement of leading and trailing edge" )
276
278
# We want the lines already refined so we don't refined them again in the second function
277
279
mesh_fields , te_le_already_refined = refine_le_te (
278
- aircraft_parts , mesh_size_by_group ["wing" ], mesh_fields , refine_factor , refine_truncated = refine_truncated , n_power_factor = n_power_factor )
280
+ aircraft_parts , mesh_size_by_group ["wing" ], mesh_fields , refine_factor ,
281
+ refine_truncated = refine_truncated , n_power_factor = n_power_factor )
279
282
log .info ("Finished refinement of leading and trailing edge" )
280
283
else :
281
284
te_le_already_refined = []
@@ -285,7 +288,8 @@ def generate_2d_mesh_for_pentagrow(
285
288
if auto_refine and refine_factor != 1 or yes :
286
289
mesh_fields = refine_lines_with_acute_angles (
287
290
te_le_already_refined , refine = refine_factor_sharp_edges ,
288
- aircraft_parts = aircraft_parts , mesh_fields = mesh_fields , mesh_size_by_part = mesh_size_by_group , n_power = n_power_factor )
291
+ aircraft_parts = aircraft_parts , mesh_fields = mesh_fields ,
292
+ mesh_size_by_part = mesh_size_by_group , n_power = n_power_factor )
289
293
mesh_fields = min_fields (mesh_fields )
290
294
log .info ("Refining process finished" )
291
295
gmsh .model .occ .synchronize ()
@@ -452,7 +456,8 @@ def fusing_parts(
452
456
# or the order was wrong and we took a non connected piece
453
457
counter += 1
454
458
log .info (
455
- "Warning : the fusion did not give only one piece (will still try to see if it's a question of order)" )
459
+ "Warning : the fusion did not give only one piece (will still try to see\
460
+ if it's a question of order)" )
456
461
names = ["errorwhen" + names [i ] + "+" + names [j ]] + [
457
462
names [k ]
458
463
for k in range (len (names ))
@@ -468,7 +473,8 @@ def fusing_parts(
468
473
parts_dimtag [k ]
469
474
for k in range (len (parts_dimtag ))
470
475
if k != j and k != i
471
- ] + fused_entities [1 :] # end should be empty but if there is a problem we let it stay
476
+ ] + fused_entities [1 :] # end should be empty but if there is a
477
+ # problem we let it stay
472
478
names = [names [i ] + "+" + names [j ]] + [
473
479
names [k ]
474
480
for k in range (len (names ))
@@ -481,10 +487,10 @@ def fusing_parts(
481
487
r = random .sample (range (0 , len (parts_dimtag )), min (4 , len (parts_dimtag )))
482
488
while len (r ) < 4 :
483
489
r .append (0 )
484
- parts_dimtag [r [0 ]], parts_dimtag [r [1 ]], parts_dimtag [r [2 ]], parts_dimtag [r [3 ]
485
- ] = parts_dimtag [r [1 ]], parts_dimtag [r [2 ]], parts_dimtag [r [3 ]], parts_dimtag [r [0 ]]
486
- names [r [0 ]], names [r [1 ]], names [r [2 ]], names [r [3 ]
487
- ] = names [r [1 ]], names [r [2 ]], names [r [3 ]], names [r [0 ]]
490
+ parts_dimtag [r [0 ]], parts_dimtag [r [1 ]], parts_dimtag [r [2 ]], parts_dimtag [r [3 ]] = \
491
+ parts_dimtag [r [1 ]], parts_dimtag [r [2 ]], parts_dimtag [r [3 ]], parts_dimtag [r [0 ]]
492
+ names [r [0 ]], names [r [1 ]], names [r [2 ]], names [r [3 ]] = \
493
+ names [r [1 ]], names [r [2 ]], names [r [3 ]], names [r [0 ]]
488
494
if counter > 20 :
489
495
# If here we have multiples times had problems with fusion and won't give one piece
490
496
log .info (f"Warning : the end result is not in one piece. Parts by group : { names } " )
@@ -561,7 +567,8 @@ def sort_surfaces_and_create_physical_groups(
561
567
for j in range (len (newaircraft_parts )):
562
568
new_part = newaircraft_parts [j ]
563
569
if old_part .uid == new_part .uid :
564
- newaircraft_parts [i ], newaircraft_parts [j ] = newaircraft_parts [j ], newaircraft_parts [i ]
570
+ newaircraft_parts [i ], newaircraft_parts [j ] = newaircraft_parts [j ], \
571
+ newaircraft_parts [i ]
565
572
break
566
573
567
574
# Now for each surface count in how many different part it is
@@ -587,14 +594,16 @@ def sort_surfaces_and_create_physical_groups(
587
594
# We only get intersection if the surface is really along/inside the volume,
588
595
# which only happens if it is the volume it comes from.)
589
596
intersection = gmsh .model .occ .intersect (
590
- [(2 , surf )], [newaircraft_parts [i ].volume ], removeObject = False , removeTool = False )[0 ]
597
+ [(2 , surf )], [newaircraft_parts [i ].volume ],
598
+ removeObject = False , removeTool = False )[0 ]
591
599
# Remove intersection to have a clean result
592
600
gmsh .model .occ .remove (intersection , recursive = True )
593
601
if len (intersection ) > 0 :
594
602
# If found, remove the tag from the others parts, and we have finished
595
603
# for this surface
596
604
log .info (
597
- f"Surface { surf } was in multiple volumes and is classified into part { aircraft_parts [i ].uid } " )
605
+ f"Surface { surf } was in multiple volumes and is classified into part\
606
+ { aircraft_parts [i ].uid } " )
598
607
for j in parts_in :
599
608
if j != i :
600
609
aircraft_parts [j ].surfaces .remove ((2 , surf ))
@@ -604,7 +613,8 @@ def sort_surfaces_and_create_physical_groups(
604
613
# If we are here, we have found no part st the part is in, so there
605
614
# is a problem. We choose a part and hope for the best
606
615
log .info (
607
- f"Surface { surf } still in parts { [aircraft_parts [i ].uid for i in parts_in ]} , take off randomly" )
616
+ f"Surface { surf } still in parts { [aircraft_parts [i ].uid for i in \
617
+ parts_in ]} , take off randomly" )
608
618
for k in range (len (parts_in ) - 1 ):
609
619
aircraft_parts [parts_in [k ]].surfaces .remove ((2 , surf ))
610
620
aircraft_parts [parts_in [k ]].surfaces_tags .remove (surf )
@@ -651,12 +661,14 @@ def refine_le_te(
651
661
Returns:
652
662
----------
653
663
mesh_fields : set
654
- Contains the updated number of used fields and the tag of the fields already used (under name "nbfields" and "restrict_fields")
664
+ Contains the updated number of used fields and the tag of the fields already used
665
+ (under name "nbfields" and "restrict_fields")
655
666
"""
656
667
aircraft = ModelPart ("aircraft" )
657
668
lines_refined = []
658
669
659
- # For all the wing, we call the function classify that will detect the le and te between all the lines and compute the mean chord length
670
+ # For all the wing, we call the function classify that will detect the le and te between all
671
+ # the lines and compute the mean chord length
660
672
for model_part in aircraft_parts :
661
673
if model_part .part_type == "wing" :
662
674
classify_wing (model_part , aircraft_parts )
0 commit comments