Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement of the mesh generation and control pt. 1 #280

Merged
merged 50 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
42299b9
power value in domain mesh changed
GBenedett May 4, 2023
2f0f087
Change the bouncing from the GUI
GBenedett May 5, 2023
d674918
factor to refine cells near surfaces
GBenedett May 8, 2023
00abe7e
add disk to marker_monitoring
GBenedett May 10, 2023
aa671c2
cfl adapt False as default + flake 8 error
GBenedett May 10, 2023
6260795
problem with sumo
GBenedett Sep 28, 2023
110860f
sumo profile detection and LE, TE mesh improved
GBenedett Oct 3, 2023
94079e5
improved formatting
GBenedett Oct 3, 2023
76df30c
improved formatting
GBenedett Oct 3, 2023
567f57e
setup info
GBenedett Oct 4, 2023
08550cd
add first point of airfoil cpacs2sumo
GBenedett Oct 4, 2023
336e719
formatting
GBenedett Oct 4, 2023
cadd77e
formatting
GBenedett Oct 4, 2023
b211b33
formatting
GBenedett Oct 4, 2023
e9da9ee
automatic aeromap added
GBenedett Oct 12, 2023
9f179dd
flake8 error
GBenedett Oct 12, 2023
6729586
aeromap generation improved
GBenedett Oct 12, 2023
c2b8260
formatting
GBenedett Oct 12, 2023
5e802bf
formatting
GBenedett Oct 12, 2023
52642d4
prova
GBenedett Oct 12, 2023
ef234ba
exportcsv re added in test
GBenedett Oct 12, 2023
9cfd7aa
automatic aeromap and less verbosity
GBenedett Oct 17, 2023
d101008
formatting
GBenedett Oct 17, 2023
becfec5
flake8
GBenedett Oct 17, 2023
4daf2ba
flake8
GBenedett Oct 17, 2023
7fef674
automatic aeromap in skin friction
GBenedett Oct 17, 2023
18b77ca
flake
GBenedett Oct 17, 2023
8cd4cf6
flake8
GBenedett Oct 17, 2023
c05f411
mesh size value changes
GBenedett Nov 14, 2023
e645a63
sumo geometry size constrain removed
GBenedett Nov 14, 2023
5168312
max size streamlit changed
GBenedett Nov 14, 2023
ac2d0b7
pathtype V1 implemented
GBenedett Nov 15, 2023
cac70fb
mesh size factor from geometry evaluation
GBenedett Nov 20, 2023
3cfb8b6
FF mesh factor and flake8
GBenedett Nov 21, 2023
0cbb4d7
black flake8
GBenedett Nov 21, 2023
b8ff3bb
flake8
GBenedett Nov 21, 2023
0baa673
codacy
GBenedett Nov 21, 2023
1ad541f
mesh_sizing test
GBenedett Nov 23, 2023
4994432
Test added
GBenedett Nov 30, 2023
866f9be
test
GBenedett Nov 30, 2023
4629133
test_mesh
GBenedett Nov 30, 2023
ff4b516
integration_test
GBenedett Dec 1, 2023
542f968
integration test
GBenedett Dec 1, 2023
f28ff7f
first part of the vector in sumo
GBenedett Dec 4, 2023
c4a264f
remove rounding <0.01
GBenedett Dec 4, 2023
3d7a708
<0.005
GBenedett Dec 4, 2023
3e7e414
cleaning and small modification
GBenedett Dec 5, 2023
c10f2b6
add mesh values to cpacsfile
GBenedett Dec 5, 2023
183d540
integration test
GBenedett Dec 5, 2023
cf7dce6
gui info
GBenedett Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 49 additions & 19 deletions ceasiompy/CPACS2GMSH/__specs__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
GMSH_EXHAUST_PERCENT_XPATH,
GMSH_EXPORT_PROP_XPATH,
GMSH_FARFIELD_FACTOR_XPATH,
GMSH_N_POWER_FACTOR_XPATH,
GMSH_N_POWER_FIELD_XPATH,
GMSH_INTAKE_PERCENT_XPATH,
GMSH_MESH_SIZE_FARFIELD_XPATH,
GMSH_MESH_SIZE_FUSELAGE_XPATH,
Expand All @@ -16,6 +18,8 @@
GMSH_REFINE_FACTOR_XPATH,
GMSH_SYMMETRY_XPATH,
SU2MESH_XPATH,
GMSH_MESH_SIZE_FACTOR_FUSELAGE_XPATH,
GMSH_MESH_SIZE_FACTOR_WINGS_XPATH,
)
from ceasiompy.utils.moduleinterfaces import CPACSInOut

Expand Down Expand Up @@ -84,38 +88,39 @@
)

cpacs_inout.add_input(
var_name="farfield_mesh_size",
var_name="farfield_mesh_size_factor",
var_type=float,
default_value=25,
unit="[m]",
descr="Value assigned for the farfield surface mesh size",
default_value=10,
unit="[-]",
descr="""Factor proportional to the biggest cell on the plane
to obtain cell size on the farfield""",
xpath=GMSH_MESH_SIZE_FARFIELD_XPATH,
gui=True,
gui_name="Farfield",
gui_name="Farfield mesh size factor",
gui_group="Mesh size",
)

cpacs_inout.add_input(
var_name="fuselage_mesh_size",
var_name="fuselage_mesh_size_factor",
var_type=float,
default_value=0.4,
unit="[m]",
descr="Value assigned for the fuselage surfaces mesh size",
xpath=GMSH_MESH_SIZE_FUSELAGE_XPATH,
default_value=1,
unit="[-]",
descr="Factor proportional to fuselage radius of curvature to obtain cell size on it",
xpath=GMSH_MESH_SIZE_FACTOR_FUSELAGE_XPATH,
gui=True,
gui_name="Fuselage",
gui_name="Fuselage mesh size factor",
gui_group="Mesh size",
)

cpacs_inout.add_input(
var_name="wing_mesh_size",
var_name="wing_mesh_size_factor",
var_type=float,
default_value=0.23,
unit="[m]",
descr="Value assigned for the wings surfaces mesh size",
xpath=GMSH_MESH_SIZE_WINGS_XPATH,
default_value=1.5,
unit="[-]",
descr="Factor proportional to wing radius of curvature to obtain cell size on it",
xpath=GMSH_MESH_SIZE_FACTOR_WINGS_XPATH,
gui=True,
gui_name="Wings",
gui_name="Wings mesh size factor",
gui_group="Mesh size",
)

Expand All @@ -130,6 +135,7 @@
gui_name="Engines",
gui_group="Mesh size",
)

cpacs_inout.add_input(
var_name="propeller_mesh_size",
var_type=float,
Expand All @@ -142,10 +148,34 @@
gui_group="Mesh size",
)

cpacs_inout.add_input(
var_name="n_power_factor",
var_type=float,
default_value=2,
unit="1",
descr="Value that changes the number of cells near the aircraft parts",
xpath=GMSH_N_POWER_FACTOR_XPATH,
gui=True,
gui_name="n power factor",
gui_group="Advanced mesh parameters",
)

cpacs_inout.add_input(
var_name="n_power_field",
var_type=float,
default_value=0.9,
unit="1",
descr="Value that changes the measure of fist cells near aircraft parts",
xpath=GMSH_N_POWER_FIELD_XPATH,
gui=True,
gui_name="n power field",
gui_group="Advanced mesh parameters",
)

cpacs_inout.add_input(
var_name="refine_factor",
var_type=float,
default_value=7.0,
default_value=2.0,
unit="1",
descr="Refinement factor of wing leading/trailing edge mesh",
xpath=GMSH_REFINE_FACTOR_XPATH,
Expand All @@ -168,7 +198,7 @@
cpacs_inout.add_input(
var_name="auto_refine",
var_type=bool,
default_value=True,
default_value=False,
unit="1",
descr="Automatically refine the mesh on surfaces that are small compare to the chosen mesh"
"size, this option increase the mesh generation time",
Expand Down
30 changes: 19 additions & 11 deletions ceasiompy/CPACS2GMSH/cpacs2gmsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
GMSH_AUTO_REFINE_XPATH,
GMSH_EXHAUST_PERCENT_XPATH,
GMSH_FARFIELD_FACTOR_XPATH,
GMSH_N_POWER_FACTOR_XPATH,
GMSH_N_POWER_FIELD_XPATH,
GMSH_INTAKE_PERCENT_XPATH,
GMSH_MESH_SIZE_FARFIELD_XPATH,
GMSH_MESH_SIZE_FUSELAGE_XPATH,
GMSH_MESH_SIZE_WINGS_XPATH,
GMSH_MESH_SIZE_FACTOR_FUSELAGE_XPATH,
GMSH_MESH_SIZE_FACTOR_WINGS_XPATH,
GMSH_MESH_SIZE_ENGINES_XPATH,
GMSH_MESH_SIZE_PROPELLERS_XPATH,
GMSH_OPEN_GUI_XPATH,
Expand Down Expand Up @@ -65,7 +67,6 @@


def cpacs2gmsh(cpacs_path, cpacs_out_path):

# Get option from the CPACS file
cpacs = CPACS(cpacs_path)

Expand All @@ -78,9 +79,15 @@ def cpacs2gmsh(cpacs_path, cpacs_out_path):
open_gmsh = get_value_or_default(cpacs.tixi, GMSH_OPEN_GUI_XPATH, False)
farfield_factor = get_value_or_default(cpacs.tixi, GMSH_FARFIELD_FACTOR_XPATH, 6)
symmetry = get_value_or_default(cpacs.tixi, GMSH_SYMMETRY_XPATH, False)
mesh_size_farfield = get_value_or_default(cpacs.tixi, GMSH_MESH_SIZE_FARFIELD_XPATH, 25)
mesh_size_fuselage = get_value_or_default(cpacs.tixi, GMSH_MESH_SIZE_FUSELAGE_XPATH, 0.4)
mesh_size_wings = get_value_or_default(cpacs.tixi, GMSH_MESH_SIZE_WINGS_XPATH, 0.23)
farfield_size_factor = get_value_or_default(cpacs.tixi, GMSH_MESH_SIZE_FARFIELD_XPATH, 17)
n_power_factor = get_value_or_default(cpacs.tixi, GMSH_N_POWER_FACTOR_XPATH, 2)
n_power_field = get_value_or_default(cpacs.tixi, GMSH_N_POWER_FIELD_XPATH, 0.9)
fuselage_mesh_size_factor = get_value_or_default(
cpacs.tixi,
GMSH_MESH_SIZE_FACTOR_FUSELAGE_XPATH,
1,
)
wing_mesh_size_factor = get_value_or_default(cpacs.tixi, GMSH_MESH_SIZE_FACTOR_WINGS_XPATH, 1)
mesh_size_engines = get_value_or_default(cpacs.tixi, GMSH_MESH_SIZE_ENGINES_XPATH, 0.23)
mesh_size_propellers = get_value_or_default(cpacs.tixi, GMSH_MESH_SIZE_PROPELLERS_XPATH, 0.23)
refine_factor = get_value_or_default(cpacs.tixi, GMSH_REFINE_FACTOR_XPATH, 7.0)
Expand All @@ -93,14 +100,17 @@ def cpacs2gmsh(cpacs_path, cpacs_out_path):
export_brep(cpacs, brep_dir, (intake_percent, exhaust_percent))
mesh_path, _ = generate_gmsh(
cpacs,
cpacs_path,
brep_dir,
results_dir,
open_gmsh=open_gmsh,
farfield_factor=farfield_factor,
symmetry=symmetry,
mesh_size_farfield=mesh_size_farfield,
mesh_size_fuselage=mesh_size_fuselage,
mesh_size_wings=mesh_size_wings,
farfield_size_factor=farfield_size_factor,
n_power_factor=n_power_factor,
n_power_field=n_power_field,
fuselage_mesh_size_factor=fuselage_mesh_size_factor,
wing_mesh_size_factor=wing_mesh_size_factor,
mesh_size_engines=mesh_size_engines,
mesh_size_propellers=mesh_size_propellers,
refine_factor=refine_factor,
Expand All @@ -124,7 +134,6 @@ def cpacs2gmsh(cpacs_path, cpacs_out_path):


def main(cpacs_path, cpacs_out_path):

log.info("----- Start of " + MODULE_NAME + " -----")

check_cpacs_input_requirements(cpacs_path)
Expand All @@ -135,7 +144,6 @@ def main(cpacs_path, cpacs_out_path):


if __name__ == "__main__":

cpacs_path = get_toolinput_file_path(MODULE_NAME)
cpacs_out_path = get_tooloutput_file_path(MODULE_NAME)

Expand Down
17 changes: 7 additions & 10 deletions ceasiompy/CPACS2GMSH/func/advancemeshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

TODO:

-Add a parameter to let the user tune the powerlaw governing the mesh
in the fluid domaine and the powerlaw for the wing surface mesh
-Add a parameter to let the user tune the powerlaw for the wing surface mesh

"""

Expand Down Expand Up @@ -253,14 +252,12 @@ def refine_wing_section(

# For each wing section get the mean chord and le/te lines
for wing_section in wing_part.wing_sections:

chord_mean = wing_section["mean_chord"]
x_chord = chord_mean * chord_percent
lines_to_refine = wing_section["lines_tags"]

# If the wing is truncated:
if len(lines_to_refine) == 3:

# Find the trailing edge thickness
x1, y1, z1 = gmsh.model.occ.getCenterOfMass(1, lines_to_refine[0])
x2, y2, z2 = gmsh.model.occ.getCenterOfMass(1, lines_to_refine[1])
Expand All @@ -274,7 +271,6 @@ def refine_wing_section(

# Overwrite the trailing edge refinement
if (mesh_size_wings / te_thickness > refine) and refine_truncated:

refine = mesh_size_wings / te_thickness

# 1 : Math eval field
Expand Down Expand Up @@ -331,7 +327,8 @@ def set_domain_mesh(
mesh_size_farfield,
aircraft_charact_length,
final_domain_volume_tag,
n_power=1.5,
n_power_factor,
n_power_field,
):
"""
Function to define the domain mesh between the farfield and the aircraft
Expand Down Expand Up @@ -375,7 +372,6 @@ def set_domain_mesh(
log.info("Set mesh refinement of fluid domain")

for part in aircraft_parts:

# 1 : Math eval field between the part surface and the farfield

mesh_fields = distance_field(mesh_fields, 2, part.surfaces_tags)
Expand All @@ -388,7 +384,7 @@ def set_domain_mesh(
mesh_fields["nbfields"],
"F",
f"{part.mesh_size} + ({mesh_size_farfield} - {part.mesh_size})*"
f"(F{distance_field_tag}/{aircraft_charact_length})^{n_power}",
f"(F{distance_field_tag}/{aircraft_charact_length})^{n_power_factor}",
)
mesh_fields = restrict_fields(mesh_fields, 3, final_domain_volume_tag)

Expand All @@ -399,7 +395,9 @@ def set_domain_mesh(
gmsh.model.mesh.field.add("Threshold", mesh_fields["nbfields"])
gmsh.model.mesh.field.setNumber(mesh_fields["nbfields"], "InField", distance_field_tag)
gmsh.model.mesh.field.setNumber(mesh_fields["nbfields"], "SizeMax", part.mesh_size)
gmsh.model.mesh.field.setNumber(mesh_fields["nbfields"], "SizeMin", part.mesh_size * 0.9)
gmsh.model.mesh.field.setNumber(
mesh_fields["nbfields"], "SizeMin", part.mesh_size * n_power_field
)

mesh_fields = restrict_fields(mesh_fields, 2, part.surfaces_tags)

Expand Down Expand Up @@ -519,5 +517,4 @@ def refine_small_surfaces(
# =================================================================================================

if __name__ == "__main__":

print("Nothing to execute!")
Loading
Loading