Skip to content

Commit

Permalink
black flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
GBenedett committed Nov 21, 2023
1 parent 3cfb8b6 commit 0cbb4d7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 43 deletions.
9 changes: 7 additions & 2 deletions ceasiompy/CPACS2GMSH/func/generategmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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)

Expand Down
40 changes: 18 additions & 22 deletions ceasiompy/CPACS2GMSH/func/mesh_sizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -115,54 +114,53 @@ 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
* elem_transf.scaling.z
* sec_transf.scaling.z
* fus_transf.scaling.z
)

body_frm_width = (
prof_size_y
* 2
* elem_transf.scaling.y
* sec_transf.scaling.y
* fus_transf.scaling.y
)

body_frm_height_values.append(body_frm_height)
body_frm_width_values.append(body_frm_width)

Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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)

Expand Down Expand Up @@ -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")
Expand All @@ -272,15 +268,15 @@ 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)

# Salva la corda di ogni sezione nella lista
chord_list.append(sec_transf.scaling.x)

refine_factor = 1
refine_level = 0
# refine_level = 0

ref_chord = sum(chord_list) / len(chord_list)

Expand All @@ -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
Expand Down
21 changes: 2 additions & 19 deletions src/streamlit/pages/02_⚙️_Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@


def update_value(xpath, key):

if key in st.session_state:
value = st.session_state[key]

Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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"],
)

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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"

Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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
Expand All @@ -387,7 +373,6 @@ def add_module_tab():
)

elif var_type == int:

with st.columns([1, 2])[0]:
st.number_input(
name,
Expand All @@ -401,7 +386,6 @@ def add_module_tab():
)

elif var_type == float:

with st.columns([1, 2])[0]:
st.number_input(
name,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0cbb4d7

Please sign in to comment.