@@ -106,17 +106,21 @@ def generate_2d_mesh_for_pentagrow(
106
106
refine_factor : float
107
107
Factor of refinement along le and te of wings
108
108
refine_truncated : bool
109
- If set to true, the refinement can change to match the truncated te thickness
109
+ If set to true, the refinement can change to match the truncated
110
+ te thickness
110
111
refine_factor_sharp_edges :float
111
112
Factor of refinement along the edges that are sharp but not le and te
112
113
n_power_factor : float
113
- Power of how much refinement on the le and te (and for now in the "refine acute angle" as well)
114
+ Power of how much refinement on the le and te (and for now in the
115
+ "refine acute angle" as well)
114
116
n_power_field: float
115
117
Coefficient ?? (Idk but not used here)
116
118
fuselage_mesh_size_factor : float
117
- Factor of the fuselage mesh size : the mesh size will be the mean fuselage width divided by this factor
119
+ Factor of the fuselage mesh size : the mesh size will be the mean
120
+ fuselage width divided by this factor
118
121
wing_mesh_size_factor : float
119
- Factor of the wing mesh size : the mesh size will be the mean fuselage width divided by this factor
122
+ Factor of the wing mesh size : the mesh size will be the mean
123
+ fuselage width divided by this factor
120
124
mesh_size_engines : float
121
125
Size of the engines mesh
122
126
mesh_size_propellers : float
@@ -246,8 +250,10 @@ def generate_2d_mesh_for_pentagrow(
246
250
mesh_fields = {"nbfields" : 0 , "restrict_fields" : []}
247
251
# Now fix the mesh size for every part
248
252
for model_part in aircraft_parts :
249
- # Take the right mesh size (name physical group should be wing or fuselage or engine or propeller or rotor or pylon or vort)
250
- if "vort" in model_part .uid : # TODO, has been here bc of one airplane where it needs to be smaller
253
+ # Take the right mesh size (name physical group should be wing or fuselage
254
+ # or engine or propeller or rotor or pylon or vort)
255
+ if "vort" in model_part .uid : # TODO, has been here bc of one airplane
256
+ # where it needs to be smaller
251
257
lc = mesh_size_by_group ["vort" ]
252
258
else :
253
259
lc = mesh_size_by_group [model_part .part_type ]
@@ -267,7 +273,7 @@ def generate_2d_mesh_for_pentagrow(
267
273
# Now do the refinement on the le and te
268
274
if refine_factor != 1 :
269
275
log .info ("Start refinement of leading and trailing edge" )
270
- # We want the lines already refined so we don't refined them afgain in the second function
276
+ # We want the lines already refined so we don't refined them again in the second function
271
277
mesh_fields , te_le_already_refined = refine_le_te (
272
278
aircraft_parts , mesh_size_by_group ["wing" ], mesh_fields , refine_factor , refine_truncated = refine_truncated , n_power_factor = n_power_factor )
273
279
log .info ("Finished refinement of leading and trailing edge" )
@@ -386,7 +392,8 @@ def intersecting_entities_for_fusing(
386
392
intersect = gmsh .model .occ .intersect (
387
393
entities1 , entities2 , removeObject = False , removeTool = False )[0 ]
388
394
gmsh .model .occ .synchronize ()
389
- # What's missing is that he sadly doesn't recognize the intersection by a face (only volume) (but rarely a problem)
395
+ # What's missing is that he sadly doesn't recognize the intersection by a face (only
396
+ # volume) (but rarely a problem)
390
397
391
398
# Check if there is an intersection (i.e. there will be a dimtag in intersect)
392
399
if len (intersect ):
@@ -426,7 +433,8 @@ def fusing_parts(
426
433
427
434
# Secondly we take care of the fusion to create the airfoil
428
435
429
- # Keep count of how many times it didn't work (if error or some seperate part, could loop forever)
436
+ # Keep count of how many times it didn't work (if error or some seperate part,
437
+ # could loop forever)
430
438
counter = 0
431
439
while len (parts_dimtag ) > 1 :
432
440
# Choose two entities to fuse
@@ -507,7 +515,8 @@ def sort_surfaces_and_create_physical_groups(
507
515
"""
508
516
# Now we sort the surfaces by part (to name them & set mesh size)
509
517
510
- # Get all the surfaces, classified by part with bounding boxes (might take too many, will be dealt with after)
518
+ # Get all the surfaces, classified by part with bounding boxes (might take too many,
519
+ # will be dealt with after)
511
520
512
521
log .info ("Start the classification of surfaces by parts" )
513
522
for model_part in aircraft_parts :
@@ -526,7 +535,8 @@ def sort_surfaces_and_create_physical_groups(
526
535
# First reimport all the shapes, get their new tags and names
527
536
newaircraft_parts = []
528
537
for brep_file in brep_files :
529
- # Import the part and create the aircraft part object (and translate them as the original were translated)
538
+ # Import the part and create the aircraft part object (and translate them as the
539
+ # original were translated)
530
540
part_entities = gmsh .model .occ .importShapes (
531
541
str (brep_file ), highestDimOnly = False )
532
542
gmsh .model .occ .translate (
@@ -544,7 +554,8 @@ def sort_surfaces_and_create_physical_groups(
544
554
545
555
newaircraft_parts .append (part_obj )
546
556
547
- # Reorder the imported shape so that it is in same order than our previous ones (i.e. vectors surfaces by part and newpart name tag type have save brep name at same index)
557
+ # Reorder the imported shape so that it is in same order than our previous ones
558
+ # (i.e. vectors surfaces by part and newpart name tag type have save brep name at same index)
548
559
for i in range (len (aircraft_parts )):
549
560
old_part = aircraft_parts [i ]
550
561
for j in range (len (newaircraft_parts )):
@@ -566,16 +577,22 @@ def sort_surfaces_and_create_physical_groups(
566
577
# Now deal with it if in more than one part
567
578
if len (parts_in ) > 1 :
568
579
for i in parts_in :
569
- # This is maybe overcomplicated, but gmsh doesn't keep the tags of surfaces when fused so we have to find a way to rematch them to their original part
570
- # Compute intersection (which is a surface) of surface with the original shape/part. If there is an intersection, it means that it is the shape that the surface was on.
571
- # (Precision : gmsh doesn't compute curves (or in general entity of smaller dim) at intersection for some reason, which is why it works.
572
- # We only get intersection if the surface is really along/inside the volume, which only happens if it is the volume it comes from.)
580
+ # This is maybe overcomplicated, but gmsh doesn't keep the tags of surfaces when
581
+ # fused so we have to find a way to rematch them to their original part
582
+ # Compute intersection (which is a surface) of surface with the original
583
+ # shape/part. If there is an intersection, it means that it is the shape
584
+ # that the surface was on.
585
+ # (Precision : gmsh doesn't compute curves (or in general entity of smaller dim)
586
+ # at intersection for some reason, which is why it works.
587
+ # We only get intersection if the surface is really along/inside the volume,
588
+ # which only happens if it is the volume it comes from.)
573
589
intersection = gmsh .model .occ .intersect (
574
590
[(2 , surf )], [newaircraft_parts [i ].volume ], removeObject = False , removeTool = False )[0 ]
575
591
# Remove intersection to have a clean result
576
592
gmsh .model .occ .remove (intersection , recursive = True )
577
593
if len (intersection ) > 0 :
578
- # If found, remove the tag from the others parts, and we have finished for this surface
594
+ # If found, remove the tag from the others parts, and we have finished
595
+ # for this surface
579
596
log .info (
580
597
f"Surface { surf } was in multiple volumes and is classified into part { aircraft_parts [i ].uid } " )
581
598
for j in parts_in :
@@ -584,7 +601,8 @@ def sort_surfaces_and_create_physical_groups(
584
601
aircraft_parts [j ].surfaces_tags .remove (surf )
585
602
break
586
603
elif i == parts_in [- 1 ]:
587
- # If we are here, we have found no part st the part is in, so there is a problem. We choose a part and hope for the best
604
+ # If we are here, we have found no part st the part is in, so there
605
+ # is a problem. We choose a part and hope for the best
588
606
log .info (
589
607
f"Surface { surf } still in parts { [aircraft_parts [i ].uid for i in parts_in ]} , take off randomly" )
590
608
for k in range (len (parts_in ) - 1 ):
@@ -597,12 +615,14 @@ def sort_surfaces_and_create_physical_groups(
597
615
598
616
# Now add the physical group to each part and the surfaces that are now sorted
599
617
for model_part in aircraft_parts :
600
- # Just add group and name (which is the brep file without ".brep") to the surfaces of the part computed before
618
+ # Just add group and name (which is the brep file without ".brep") to the surfaces
619
+ # of the part computed before
601
620
part_group = gmsh .model .addPhysicalGroup (2 , model_part .surfaces_tags )
602
621
name_group = model_part .uid
603
622
gmsh .model .setPhysicalName (2 , part_group , name_group )
604
623
605
- # Compute the lines in each part by taking the boundary of surfaces (need them later for wing refinement)
624
+ # Compute the lines in each part by taking the boundary of surfaces (need them later
625
+ # for wing refinement)
606
626
model_part .lines = gmsh .model .getBoundary (
607
627
model_part .surfaces , combined = False , oriented = False )
608
628
model_part .lines_tags = [li [1 ] for li in model_part .lines ]
0 commit comments