Skip to content

Commit

Permalink
mesh size factor from geometry evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
GBenedett committed Nov 20, 2023
1 parent ac2d0b7 commit cac70fb
Show file tree
Hide file tree
Showing 5 changed files with 387 additions and 20 deletions.
63 changes: 53 additions & 10 deletions ceasiompy/CPACS2GMSH/__specs__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,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 @@ -97,30 +99,55 @@
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",
var_name="fuselage_mesh_size_factor",
var_type=float,
default_value=0.3,
unit="[m]",
default_value=1,
unit="1",
descr="Value assigned for the fuselage surfaces mesh size",
xpath=GMSH_MESH_SIZE_FUSELAGE_XPATH,
xpath=GMSH_MESH_SIZE_FACTOR_FUSELAGE_XPATH,
gui=True,
gui_name="Fuselage",
gui_name="Fuselage 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",
var_name="wing_mesh_size_factor",
var_type=float,
default_value=0.123,
unit="[m]",
default_value=1,
unit="1",
descr="Value assigned for the wings surfaces mesh size",
xpath=GMSH_MESH_SIZE_WINGS_XPATH,
xpath=GMSH_MESH_SIZE_FACTOR_WINGS_XPATH,
gui=True,
gui_name="Wings",
gui_name="Wings factor",
gui_group="Mesh size",
)


cpacs_inout.add_input(
var_name="engine_mesh_size",
var_type=float,
Expand Down Expand Up @@ -240,3 +267,19 @@
descr="Absolute path of the SU2 mesh",
xpath=SU2MESH_XPATH,
)

cpacs_inout.add_output(
var_name="fuselage_mesh_size",
var_type=float,
default_value=None,
descr="Value assigned for the fuselage surfaces mesh size",
xpath=GMSH_MESH_SIZE_FUSELAGE_XPATH,
)

cpacs_inout.add_output(
var_name="wing_mesh_size",
var_type=float,
default_value=None,
descr="Value assigned for the wings surfaces mesh size",
xpath=GMSH_MESH_SIZE_WINGS_XPATH,
)
13 changes: 7 additions & 6 deletions ceasiompy/CPACS2GMSH/cpacs2gmsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
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 @@ -82,8 +82,8 @@ def cpacs2gmsh(cpacs_path, cpacs_out_path):
mesh_size_farfield = get_value_or_default(cpacs.tixi, GMSH_MESH_SIZE_FARFIELD_XPATH, 25)
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)
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)
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 @@ -96,6 +96,7 @@ 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,
Expand All @@ -104,8 +105,8 @@ def cpacs2gmsh(cpacs_path, cpacs_out_path):
mesh_size_farfield=mesh_size_farfield,
n_power_factor=n_power_factor,
n_power_field=n_power_field,
mesh_size_fuselage=mesh_size_fuselage,
mesh_size_wings=mesh_size_wings,
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 Down
21 changes: 17 additions & 4 deletions ceasiompy/CPACS2GMSH/func/generategmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
from ceasiompy.utils.ceasiomlogger import get_logger
from ceasiompy.utils.ceasiompyutils import get_part_type

from ceasiompy.CPACS2GMSH.func.mesh_sizing import fuselage_size, wings_size

log = get_logger()


Expand Down Expand Up @@ -557,6 +559,7 @@ def control_disk_actuator_normal():

def generate_gmsh(
cpacs,
cpacs_path,
brep_dir,
results_dir,
open_gmsh=False,
Expand All @@ -565,8 +568,8 @@ def generate_gmsh(
mesh_size_farfield=25,
n_power_factor=2,
n_power_field=0.9,
mesh_size_fuselage=0.4,
mesh_size_wings=0.23,
fuselage_mesh_size_factor=1,
wing_mesh_size_factor=1,
mesh_size_engines=0.23,
mesh_size_propellers=0.23,
refine_factor=7.0,
Expand Down Expand Up @@ -924,13 +927,23 @@ def generate_gmsh(
# Thus be sure to define mesh size in a certain order to control
# the size of the points on boundaries.

fuselage_maxlen, fuselage_minlen = fuselage_size(cpacs_path)
log.info(f"fuselage_minlen={fuselage_minlen}")
mesh_size_fuselage = fuselage_mesh_size_factor * fuselage_minlen
log.info(f"mesh_size_fuselage={mesh_size_fuselage}")

wing_maxlen, wing_minlen = wings_size(cpacs_path)
log.info(f"wing_minlen={wing_minlen}")
mesh_size_wing = wing_mesh_size_factor * wing_minlen
log.info(f"mesh_size_wing={mesh_size_wing}")

for part in aircraft_parts:
if part.part_type == "fuselage":
part.mesh_size = mesh_size_fuselage
gmsh.model.mesh.setSize(part.points, part.mesh_size)
gmsh.model.setColor(part.surfaces, *MESH_COLORS[part.part_type], recursive=False)
elif part.part_type in ["wing", "pylon"]:
part.mesh_size = mesh_size_wings
part.mesh_size = mesh_size_wing
gmsh.model.mesh.setSize(part.points, part.mesh_size)
gmsh.model.setColor(part.surfaces, *MESH_COLORS[part.part_type], recursive=False)
elif part.part_type == "engine":
Expand Down Expand Up @@ -967,7 +980,7 @@ def generate_gmsh(
final_domain.volume_tag,
aircraft,
part,
mesh_size_wings,
mesh_size_wing,
refine=refine_factor,
refine_truncated=refine_truncated,
)
Expand Down
Loading

0 comments on commit cac70fb

Please sign in to comment.