Skip to content

Commit 1529765

Browse files
committed
fix RANS tests2
1 parent 6723299 commit 1529765

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

ceasiompy/CPACS2GMSH/func/advancemeshing.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def refine_small_surfaces(
433433
- if the surface area is very small compare to the mesh size of the part mesh
434434
the surface is remeshed with a smaller mesh size
435435
--> With parameters by default, if with mesh size we have less than 150 triangles
436-
in the surface, we set the mesh size to have 150 triangles
436+
in the surface, we set the mesh size to have 150 triangles
437437
438438
Args:
439439
----------
@@ -519,7 +519,7 @@ def refine_lines_with_acute_angles(
519519
te_le_already_refined, refine, aircraft_parts, mesh_fields, mesh_size_by_part, n_power
520520
):
521521
"""
522-
Function to refine the mesh along edges with really small angles
522+
Function to refine the mesh along edges with really small angles
523523
(as done for the leading and trailing edges, but for others)
524524
WARNING : this function does not work for now. I feel like there is a problem
525525
when retrieving normals (often get (1,0,0) even when does not make sense)
@@ -528,7 +528,7 @@ def refine_lines_with_acute_angles(
528528
529529
- if the angle between the adjacent surfaces is smaller than 72 degrees,
530530
we refine along this line
531-
--> To compute the angle, we get the nodes along the line, then the normal
531+
--> To compute the angle, we get the nodes along the line, then the normal
532532
at these nodes for each surface and compute the scalar product which is the cosinus
533533
534534
@@ -607,7 +607,7 @@ def refine_lines_with_acute_angles(
607607
j, [params_i[2 * a], params_j[2 * a + 1]])
608608
# Compute cos of the angle between the normals
609609
# (their norms are 1, so is equal to scalar product)
610-
cosalpha = (normal_i[0] * normal_j[0] +
610+
cosalpha = (normal_i[0] * normal_j[0] +
611611
normal_i[1] * normal_j[1] + normal_i[2] * normal_j[2])
612612
if cosalpha < -0.3: # (more than 72 degrees from being flat)
613613
lines_with_angles_tag.append(line)

ceasiompy/CPACS2GMSH/func/rans_mesh_generator.py

+31-19
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ def generate_2d_mesh_for_pentagrow(
114114
Power of how much refinement on the le and te (and for now in the
115115
"refine acute angle" as well)
116116
n_power_field: float
117-
Coefficient ?? (Idk but not used here)
117+
Coefficient ?? (Idk but not used here)
118118
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
120120
fuselage width divided by this factor
121121
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
123123
fuselage width divided by this factor
124124
mesh_size_engines : float
125125
Size of the engines mesh
@@ -241,7 +241,8 @@ def generate_2d_mesh_for_pentagrow(
241241
mesh_size_by_group["vort"] = mesh_size_by_group["fuselage"] / 8
242242

243243
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")
245246
log.info(
246247
f"Mesh size wing={((wing_maxlen * 0.8 + wing_minlen) /2) / wing_mesh_size_factor:.3f} m")
247248
log.info(f"Mesh size engine={mesh_size_engines:.3f} m")
@@ -260,7 +261,8 @@ def generate_2d_mesh_for_pentagrow(
260261

261262
model_part.mesh_size = lc
262263
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
264266
gmsh.model.mesh.field.add("Constant", mesh_fields["nbfields"])
265267
gmsh.model.mesh.field.setNumbers(
266268
mesh_fields["nbfields"], "SurfacesList", model_part.surfaces_tags)
@@ -275,7 +277,8 @@ def generate_2d_mesh_for_pentagrow(
275277
log.info("Start refinement of leading and trailing edge")
276278
# We want the lines already refined so we don't refined them again in the second function
277279
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)
279282
log.info("Finished refinement of leading and trailing edge")
280283
else:
281284
te_le_already_refined = []
@@ -285,7 +288,8 @@ def generate_2d_mesh_for_pentagrow(
285288
if auto_refine and refine_factor != 1 or yes:
286289
mesh_fields = refine_lines_with_acute_angles(
287290
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)
289293
mesh_fields = min_fields(mesh_fields)
290294
log.info("Refining process finished")
291295
gmsh.model.occ.synchronize()
@@ -452,7 +456,8 @@ def fusing_parts(
452456
# or the order was wrong and we took a non connected piece
453457
counter += 1
454458
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)")
456461
names = ["errorwhen" + names[i] + "+" + names[j]] + [
457462
names[k]
458463
for k in range(len(names))
@@ -468,7 +473,8 @@ def fusing_parts(
468473
parts_dimtag[k]
469474
for k in range(len(parts_dimtag))
470475
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
472478
names = [names[i] + "+" + names[j]] + [
473479
names[k]
474480
for k in range(len(names))
@@ -481,10 +487,10 @@ def fusing_parts(
481487
r = random.sample(range(0, len(parts_dimtag)), min(4, len(parts_dimtag)))
482488
while len(r) < 4:
483489
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]]
488494
if counter > 20:
489495
# If here we have multiples times had problems with fusion and won't give one piece
490496
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(
561567
for j in range(len(newaircraft_parts)):
562568
new_part = newaircraft_parts[j]
563569
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]
565572
break
566573

567574
# Now for each surface count in how many different part it is
@@ -587,14 +594,16 @@ def sort_surfaces_and_create_physical_groups(
587594
# We only get intersection if the surface is really along/inside the volume,
588595
# which only happens if it is the volume it comes from.)
589596
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]
591599
# Remove intersection to have a clean result
592600
gmsh.model.occ.remove(intersection, recursive=True)
593601
if len(intersection) > 0:
594602
# If found, remove the tag from the others parts, and we have finished
595603
# for this surface
596604
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}")
598607
for j in parts_in:
599608
if j != i:
600609
aircraft_parts[j].surfaces.remove((2, surf))
@@ -604,7 +613,8 @@ def sort_surfaces_and_create_physical_groups(
604613
# If we are here, we have found no part st the part is in, so there
605614
# is a problem. We choose a part and hope for the best
606615
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")
608618
for k in range(len(parts_in) - 1):
609619
aircraft_parts[parts_in[k]].surfaces.remove((2, surf))
610620
aircraft_parts[parts_in[k]].surfaces_tags.remove(surf)
@@ -651,12 +661,14 @@ def refine_le_te(
651661
Returns:
652662
----------
653663
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")
655666
"""
656667
aircraft = ModelPart("aircraft")
657668
lines_refined = []
658669

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
660672
for model_part in aircraft_parts:
661673
if model_part.part_type == "wing":
662674
classify_wing(model_part, aircraft_parts)

0 commit comments

Comments
 (0)