Skip to content

Commit

Permalink
improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
GBenedett committed Dec 6, 2023
1 parent f8eb3bf commit c5f97cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ceasiompy/SUMOAutoMesh/__specs__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
cpacs_inout.add_input(
var_name="output_format",
var_type=list,
default_value=["SU2", "M-Edge"],
default_value=["su2", "edge"],
unit="1",
descr="chose the output mesh format",
xpath=SUMO_OUTPUT_MESH_FORMAT_XPATH,
Expand Down
17 changes: 13 additions & 4 deletions ceasiompy/SUMOAutoMesh/sumoautomesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@

from ceasiompy.utils.ceasiomlogger import get_logger
from ceasiompy.utils.ceasiompyutils import aircraft_name, get_results_directory, run_software
from ceasiompy.utils.commonxpath import SU2MESH_XPATH, SUMO_REFINE_LEVEL_XPATH, SUMOFILE_XPATH
from ceasiompy.utils.commonxpath import (
SU2MESH_XPATH,
SUMO_REFINE_LEVEL_XPATH,
SUMOFILE_XPATH,
SUMO_OUTPUT_MESH_FORMAT_XPATH,
)
from ceasiompy.utils.moduleinterfaces import get_toolinput_file_path, get_tooloutput_file_path
from cpacspy.cpacsfunctions import create_branch, get_value_or_default, open_tixi

Expand Down Expand Up @@ -209,7 +214,7 @@ def add_mesh_parameters(sumo_file_path, refine_level=0.0):
sumo.save(str(sumo_file_path))


def create_mesh(cpacs_path, cpacs_out_path, output):
def create_mesh(cpacs_path, cpacs_out_path):
"""Function to create a simple SU2 mesh form an SUMO file (.smx)
Function 'create_mesh' is used to generate an unstructured mesh with SUMO
Expand All @@ -228,13 +233,17 @@ def create_mesh(cpacs_path, cpacs_out_path, output):

tixi = open_tixi(cpacs_path)

output = get_value_or_default(tixi, SUMO_OUTPUT_MESH_FORMAT_XPATH, "su2")

if output == "su2":
file_extension = "su2"
elif output == "edge":
file_extension = "bmsh"
else:
raise ValueError("Unsupported output format. Use 'su2' or 'edge'")

log.info(f"The output mesh format is {file_extension}")

sumo_results_dir = get_results_directory("SUMOAutoMesh")
mesh_path = Path(sumo_results_dir, f"ToolOutput.{file_extension}")

Expand Down Expand Up @@ -311,11 +320,11 @@ def create_mesh(cpacs_path, cpacs_out_path, output):
# =================================================================================================


def main(cpacs_path, cpacs_out_path, output_format="edge"):
def main(cpacs_path, cpacs_out_path):
log.info("----- Start of " + MODULE_NAME + " -----")

# Call create_mesh with the desired output format
create_mesh(cpacs_path, cpacs_out_path, output=output_format)
create_mesh(cpacs_path, cpacs_out_path)

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

Expand Down

0 comments on commit c5f97cf

Please sign in to comment.