From 0cbb4d71c87e3829e9975a69a270dc4f0841f52d Mon Sep 17 00:00:00 2001 From: GBenedett Date: Tue, 21 Nov 2023 13:50:22 +0100 Subject: [PATCH] black flake8 --- ceasiompy/CPACS2GMSH/func/generategmesh.py | 9 ++++- ceasiompy/CPACS2GMSH/func/mesh_sizing.py | 40 +++++++++---------- .../02_\342\232\231\357\270\217_Settings.py" | 21 +--------- 3 files changed, 27 insertions(+), 43 deletions(-) diff --git a/ceasiompy/CPACS2GMSH/func/generategmesh.py b/ceasiompy/CPACS2GMSH/func/generategmesh.py index 87688a14b..2e6bcc0e9 100644 --- a/ceasiompy/CPACS2GMSH/func/generategmesh.py +++ b/ceasiompy/CPACS2GMSH/func/generategmesh.py @@ -933,7 +933,7 @@ def generate_gmsh( 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}") for part in aircraft_parts: if part.part_type == "fuselage": @@ -954,7 +954,12 @@ 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 + mesh_size_farfield = ( + max(wing_minlen, fuselage_minlen) + * farfield_size_factor + * max(model_dimensions) + * domain_length + ) gmsh.model.mesh.setSize(farfield_points, mesh_size_farfield) gmsh.model.setColor(farfield_surfaces, *MESH_COLORS["farfield"], recursive=False) diff --git a/ceasiompy/CPACS2GMSH/func/mesh_sizing.py b/ceasiompy/CPACS2GMSH/func/mesh_sizing.py index ae5c2b6e2..a115548c7 100644 --- a/ceasiompy/CPACS2GMSH/func/mesh_sizing.py +++ b/ceasiompy/CPACS2GMSH/func/mesh_sizing.py @@ -35,7 +35,6 @@ def fuselage_size(cpacs_path): - tixi = open_tixi(cpacs_path) if tixi.checkElement(FUSELAGES_XPATH): fus_cnt = tixi.getNamedChildrenCount(FUSELAGES_XPATH, "fuselage") @@ -103,7 +102,7 @@ def fuselage_size(cpacs_path): # Sections sec_cnt = tixi.getNamedChildrenCount(fus_xpath + "/sections", "section") - + if pos_cnt == 0: pos_x_list = [0.0] * sec_cnt pos_y_list = [0.0] * sec_cnt @@ -115,38 +114,37 @@ def fuselage_size(cpacs_path): for i_sec in range(sec_cnt): sec_xpath = fus_xpath + "/sections/section[" + str(i_sec + 1) + "]" - + sec_transf = Transformation() sec_transf.get_cpacs_transf(tixi, sec_xpath) - + # Elements elem_cnt = tixi.getNamedChildrenCount(sec_xpath + "/elements", "element") for i_elem in range(elem_cnt): elem_xpath = sec_xpath + "/elements/element[" + str(i_elem + 1) + "]" - elem_uid = tixi.getTextAttribute(elem_xpath, "uID") elem_transf = Transformation() elem_transf.get_cpacs_transf(tixi, elem_xpath) - + # Fuselage profiles prof_uid = tixi.getTextElement(elem_xpath + "/profileUID") prof_vect_x, prof_vect_y, prof_vect_z = get_profile_coord(tixi, prof_uid) - + prof_size_y = (max(prof_vect_y) - min(prof_vect_y)) / 2 prof_size_z = (max(prof_vect_z) - min(prof_vect_z)) / 2 - + prof_vect_y[:] = [y / prof_size_y for y in prof_vect_y] prof_vect_z[:] = [z / prof_size_z for z in prof_vect_z] - + prof_min_y = min(prof_vect_y) prof_min_z = min(prof_vect_z) - + prof_vect_y[:] = [y - 1 - prof_min_y for y in prof_vect_y] prof_vect_z[:] = [z - 1 - prof_min_z for z in prof_vect_z] - + pos_y_list[i_sec] += ((1 + prof_min_y) * prof_size_y) * elem_transf.scaling.y pos_z_list[i_sec] += ((1 + prof_min_z) * prof_size_z) * elem_transf.scaling.z - + body_frm_height = ( prof_size_z * 2 @@ -154,7 +152,7 @@ def fuselage_size(cpacs_path): * sec_transf.scaling.z * fus_transf.scaling.z ) - + body_frm_width = ( prof_size_y * 2 @@ -162,7 +160,7 @@ def fuselage_size(cpacs_path): * sec_transf.scaling.y * fus_transf.scaling.y ) - + body_frm_height_values.append(body_frm_height) body_frm_width_values.append(body_frm_width) @@ -177,7 +175,7 @@ def fuselage_size(cpacs_path): # Get overall minimum radius (semi-minor axis for ellipse) min_radius = min(min_radius, height, width) - + mean_circ = sum(circ_list) / len(circ_list) # Calculate mesh parameters from inputs and geometry @@ -192,7 +190,6 @@ def fuselage_size(cpacs_path): def wings_size(cpacs_path): - tixi = open_tixi(cpacs_path) if tixi.checkElement(WINGS_XPATH): wing_cnt = tixi.getNamedChildrenCount(WINGS_XPATH, "wing") @@ -201,7 +198,6 @@ def wings_size(cpacs_path): for i_wing in range(wing_cnt): wing_xpath = WINGS_XPATH + "/wing[" + str(i_wing + 1) + "]" - wing_uid = tixi.getTextAttribute(wing_xpath, "uID") wing_transf = Transformation() wing_transf.get_cpacs_transf(tixi, wing_xpath) @@ -259,8 +255,8 @@ def wings_size(cpacs_path): pos_z_list[j_pos] += prev_pos_z else: - log.error('No "positionings" have been found!') - pos_cnt = 0 + log.error('No "positionings" have been found!') + pos_cnt = 0 # Sections sec_cnt = tixi.getNamedChildrenCount(wing_xpath + "/sections", "section") @@ -272,7 +268,7 @@ def wings_size(cpacs_path): for i_sec in range(sec_cnt): sec_xpath = wing_xpath + "/sections/section[" + str(i_sec + 1) + "]" - + sec_transf = Transformation() sec_transf.get_cpacs_transf(tixi, sec_xpath) @@ -280,7 +276,7 @@ def wings_size(cpacs_path): chord_list.append(sec_transf.scaling.x) refine_factor = 1 - refine_level = 0 + # refine_level = 0 ref_chord = sum(chord_list) / len(chord_list) @@ -290,7 +286,7 @@ def wings_size(cpacs_path): 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 diff --git "a/src/streamlit/pages/02_\342\232\231\357\270\217_Settings.py" "b/src/streamlit/pages/02_\342\232\231\357\270\217_Settings.py" index b46acf19d..e9f74ed04 100644 --- "a/src/streamlit/pages/02_\342\232\231\357\270\217_Settings.py" +++ "b/src/streamlit/pages/02_\342\232\231\357\270\217_Settings.py" @@ -62,7 +62,6 @@ def update_value(xpath, key): - if key in st.session_state: value = st.session_state[key] @@ -77,13 +76,11 @@ def update_value(xpath, key): def update_all_modified_value(): - for xpath, key in st.session_state.xpath_to_update.items(): update_value(xpath, key) def save_cpacs_file(): - update_all_modified_value() saved_cpacs_file = Path(st.session_state.workflow.working_dir, "CPACS_selected_from_GUI.xml") st.session_state.cpacs.save_cpacs(saved_cpacs_file, overwrite=True) @@ -115,13 +112,11 @@ def save_cpacs_file(): def section_edit_aeromap(): - st.markdown("#### Available aeromaps") aeromap_uid_list = st.session_state.cpacs.get_aeromap_uid_list() for i, aeromap in enumerate(aeromap_uid_list): - col1, col2, col3, _ = st.columns([6, 1, 1, 5]) with col1: @@ -209,7 +204,6 @@ def section_edit_aeromap(): uploaded_aeromap_uid = uploaded_csv.name.split(".csv")[0] if st.button("Add this aeromap"): - if uploaded_aeromap_uid in aeromap_uid_list: st.error("There is already an aeromap with this name!") return @@ -225,8 +219,8 @@ def mesh_file_upload(): # Verifica se รจ stato caricato un file mesh uploaded_mesh = st.file_uploader( - "Select a mesh file", - key="00_mesh_upload", + "Select a mesh file", + key="00_mesh_upload", type=["su2", "cgns"], ) @@ -274,7 +268,6 @@ def mesh_file_upload(): def add_module_tab(): - if "cpacs" not in st.session_state: st.warning("No CPACS file has been selected!") return @@ -296,9 +289,7 @@ def add_module_tab(): for m, (tab, module) in enumerate( zip(st.session_state.tabs, st.session_state.workflow_modules) ): - with tab: - st.text("") specs = get_specs_for_module(module) inputs = specs.cpacs_inout.get_gui_dict() @@ -317,9 +308,7 @@ def add_module_tab(): st.markdown(f"**{group}**") for name, default_value, var_type, unit, xpath, description, group in inputs.values(): - with groups_container[group]: - if not group: group = "none" @@ -329,7 +318,6 @@ def add_module_tab(): name = f"{name} {unit}" if name == "__AEROMAP_SELECTION": - aeromap_uid_list = st.session_state.cpacs.get_aeromap_uid_list() if not len(aeromap_uid_list): @@ -352,7 +340,6 @@ def add_module_tab(): ) elif name == "__AEROMAP_CHECKBOX": - aeromap_uid_list = st.session_state.cpacs.get_aeromap_uid_list() if not len(aeromap_uid_list): @@ -372,7 +359,6 @@ def add_module_tab(): default=default_otp, help=description, ) - elif name == "pathtype": # Chiama la funzione mesh_file_upload() e ottieni il percorso del file mesh @@ -387,7 +373,6 @@ def add_module_tab(): ) elif var_type == int: - with st.columns([1, 2])[0]: st.number_input( name, @@ -401,7 +386,6 @@ def add_module_tab(): ) elif var_type == float: - with st.columns([1, 2])[0]: st.number_input( name, @@ -460,7 +444,6 @@ def add_module_tab(): def section_settings(): - if "workflow_modules" not in st.session_state: st.warning("No module selected!") return