From 3e7e414ac824d36f113913d63ca3a4c1e2dfdc96 Mon Sep 17 00:00:00 2001 From: GBenedett Date: Tue, 5 Dec 2023 11:44:21 +0100 Subject: [PATCH] cleaning and small modification --- ceasiompy/CPACS2GMSH/__specs__.py | 44 +++++----------------- ceasiompy/CPACS2GMSH/func/generategmesh.py | 28 +++++++------- ceasiompy/CPACS2GMSH/func/mesh_sizing.py | 31 +++++---------- 3 files changed, 33 insertions(+), 70 deletions(-) diff --git a/ceasiompy/CPACS2GMSH/__specs__.py b/ceasiompy/CPACS2GMSH/__specs__.py index ca681d550..fab6560de 100644 --- a/ceasiompy/CPACS2GMSH/__specs__.py +++ b/ceasiompy/CPACS2GMSH/__specs__.py @@ -90,64 +90,39 @@ cpacs_inout.add_input( var_name="farfield_mesh_size_factor", var_type=float, - default_value=17, - unit="1", + default_value=10, + unit="[-]", descr="Value assigned for the farfield surface mesh size", xpath=GMSH_MESH_SIZE_FARFIELD_XPATH, gui=True, - gui_name="Farfield factor", + gui_name="Farfield mesh size factor", gui_group="Mesh size", ) -# cpacs_inout.add_input( -# var_name="fuselage_mesh_size", -# var_type=float, -# default_value=0.3, -# unit="[m]", -# descr="Value assigned for the fuselage surfaces mesh size", -# xpath=GMSH_MESH_SIZE_FUSELAGE_XPATH, -# gui=True, -# gui_name="Fuselage", -# gui_group="Mesh size", -# ) - cpacs_inout.add_input( var_name="fuselage_mesh_size_factor", var_type=float, default_value=1, - unit="1", + unit="[-]", descr="Value assigned for the fuselage surfaces mesh size", xpath=GMSH_MESH_SIZE_FACTOR_FUSELAGE_XPATH, gui=True, - gui_name="Fuselage factor", + gui_name="Fuselage mesh size factor", gui_group="Mesh size", ) -# cpacs_inout.add_input( -# var_name="wing_mesh_size", -# var_type=float, -# default_value=0.1, -# unit="[m]", -# descr="Value assigned for the wings surfaces mesh size", -# xpath=GMSH_MESH_SIZE_WINGS_XPATH, -# gui=True, -# gui_name="Wings", -# gui_group="Mesh size", -# ) - cpacs_inout.add_input( var_name="wing_mesh_size_factor", var_type=float, - default_value=1, - unit="1", + default_value=1.5, + unit="[-]", descr="Value assigned for the wings surfaces mesh size", xpath=GMSH_MESH_SIZE_FACTOR_WINGS_XPATH, gui=True, - gui_name="Wings factor", + gui_name="Wings mesh size factor", gui_group="Mesh size", ) - cpacs_inout.add_input( var_name="engine_mesh_size", var_type=float, @@ -159,6 +134,7 @@ gui_name="Engines", gui_group="Mesh size", ) + cpacs_inout.add_input( var_name="propeller_mesh_size", var_type=float, @@ -198,7 +174,7 @@ 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, diff --git a/ceasiompy/CPACS2GMSH/func/generategmesh.py b/ceasiompy/CPACS2GMSH/func/generategmesh.py index 3ef2c8022..a91eed03d 100644 --- a/ceasiompy/CPACS2GMSH/func/generategmesh.py +++ b/ceasiompy/CPACS2GMSH/func/generategmesh.py @@ -565,14 +565,14 @@ def generate_gmsh( open_gmsh=False, farfield_factor=6, symmetry=False, - farfield_size_factor=17, + farfield_size_factor=10, n_power_factor=2, n_power_field=0.9, fuselage_mesh_size_factor=1, - wing_mesh_size_factor=1, + wing_mesh_size_factor=1.5, mesh_size_engines=0.23, mesh_size_propellers=0.23, - refine_factor=7.0, + refine_factor=2.0, refine_truncated=False, auto_refine=True, testing_gmsh=False, @@ -927,13 +927,13 @@ def generate_gmsh( # Thus be sure to define mesh size in a certain order to control # the size of the points on boundaries. - _, fuselage_minlen = fuselage_size(cpacs_path) + fuselage_maxlen, fuselage_minlen = fuselage_size(cpacs_path) mesh_size_fuselage = fuselage_mesh_size_factor * fuselage_minlen - log.info(f"mesh_size_fuselage={mesh_size_fuselage}") + log.info(f"Mesh size fuselage={mesh_size_fuselage:.3f} m") - _, wing_minlen = wings_size(cpacs_path) + wing_maxlen, wing_minlen = wings_size(cpacs_path) mesh_size_wing = wing_mesh_size_factor * wing_minlen - log.info(f"mesh_size_wing={mesh_size_wing}") + log.info(f"Mesh size wing={mesh_size_wing:.3f} m") for part in aircraft_parts: if part.part_type == "fuselage": @@ -954,12 +954,11 @@ def generate_gmsh( gmsh.model.setColor(part.surfaces, *MESH_COLORS[part.part_type], recursive=False) # Set mesh size and color of the farfield - mesh_size_farfield = ( - max(wing_minlen, fuselage_minlen) - * farfield_size_factor - * max(model_dimensions) - * domain_length - ) + h_max_model = max(wing_maxlen, fuselage_maxlen) + mesh_size_farfield = h_max_model * farfield_size_factor + + log.info(f"Farfield mesh size={mesh_size_farfield:.3f} m") + gmsh.model.mesh.setSize(farfield_points, mesh_size_farfield) gmsh.model.setColor(farfield_surfaces, *MESH_COLORS["farfield"], recursive=False) @@ -971,7 +970,8 @@ def generate_gmsh( if part.part_type == "wing": classify_wing(part, aircraft_parts) log.info( - f"Classification of {part.uid} done" f"{len(part.wing_sections)} section(s) found " + f"Classification of {part.uid} done" + f" {len(part.wing_sections)} section(s) found " ) # Generate advance meshing features diff --git a/ceasiompy/CPACS2GMSH/func/mesh_sizing.py b/ceasiompy/CPACS2GMSH/func/mesh_sizing.py index ca628a616..e1c5a832c 100644 --- a/ceasiompy/CPACS2GMSH/func/mesh_sizing.py +++ b/ceasiompy/CPACS2GMSH/func/mesh_sizing.py @@ -171,7 +171,6 @@ def fuselage_size(cpacs_path): # Extrapolate mesh values circ_list = [] min_radius = 10e6 - refine_factor = 1 for height, width in zip(body_frm_height_values, body_frm_width_values): # Calculate the sum of squares for each element in the lists @@ -184,11 +183,11 @@ def fuselage_size(cpacs_path): # Calculate mesh parameters from inputs and geometry # In SUMO, fuselage_minlen is min_radius/2, but sometimes it leads to meshing errors - fuselage_maxlen = (0.08 * mean_circ) * refine_factor - fuselage_minlen = min(0.1 * fuselage_maxlen, min_radius / 2) * refine_factor + fuselage_maxlen = 0.08 * mean_circ + fuselage_minlen = min(0.1 * fuselage_maxlen, min_radius / 2) - log.info(f"fuselage_maxlen={fuselage_maxlen:.3f}") - log.info(f"fuselage_minlen={fuselage_minlen:.3f}") + log.info(f"Fuselage maxlen={fuselage_maxlen:.3f} m") + log.info(f"Fuselage minlen={fuselage_minlen:.3f} m") return fuselage_maxlen, fuselage_minlen @@ -276,27 +275,15 @@ def wings_size(cpacs_path): sec_transf = Transformation() sec_transf.get_cpacs_transf(tixi, sec_xpath) - # Salva la corda di ogni sezione nella lista chord_list.append(sec_transf.scaling.x) - refine_factor = 1 - # refine_level = 0 - ref_chord = sum(chord_list) / len(chord_list) # Calculate mesh parameter from inputs and geometry - wing_maxlen = (0.15 * ref_chord) * refine_factor - wing_minlen = (0.08 * wing_maxlen) * refine_factor - - log.info(f"wing_maxlen={wing_maxlen:.3f}") - log.info(f"wing_minlen={wing_minlen:.3f}") - - # in sumo it is 0.08*wing_maxlen or 0.7*min leading edge radius... - # Default value in SUMO - # lerfactor = 1 / 4.0 - # terfactor = 1 / 4. - # if refine_level > 1: - # lerfactor = 1 / (4.0 + 0.5 * (refine_level - 1)) - # terfactor = 1 / (4.0 + 0.5 * (refine_level - 1)) + wing_maxlen = 0.15 * ref_chord + wing_minlen = 0.08 * wing_maxlen + + log.info(f"Wing maxlen={wing_maxlen:.3f} m") + log.info(f"Wing minlen={wing_minlen:.3f} m") return wing_maxlen, wing_minlen