Skip to content

Commit

Permalink
edgerun workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
GBenedett committed Jan 19, 2024
1 parent 4360f77 commit 8168006
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
20 changes: 10 additions & 10 deletions ceasiompy/EdgeRun/edgerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ceasiompy.utils.ceasiompyutils import (
get_reasonable_nb_cpu,
get_results_directory,
# run_software,
# run_software,
)

# from ceasiompy.utils.commonnames import AINP_CFD_NAME, SU2_FORCES_BREAKDOWN_NAME
Expand All @@ -39,7 +39,6 @@
MODULE_NAME = MODULE_DIR.name



# =================================================================================================
# CLASSES
# =================================================================================================
Expand All @@ -50,7 +49,8 @@
# =================================================================================================
input_que_script_path = get_edge_queScript_template()

def run_edge_multi(wkdir, input_que_script_path , nb_proc=2):

def run_edge_multi(wkdir, input_que_script_path, nb_proc=2):
"""Function to run a multiple Edge calculation.
Function 'run_edge_multi' will run in the given working directory Edge calculations.
Expand All @@ -63,21 +63,20 @@ def run_edge_multi(wkdir, input_que_script_path , nb_proc=2):

if not wkdir.exists():
raise OSError(f"The working directory : {wkdir} does not exist!")

case_dir_name = (
f"Case{str(case_nb).zfill(2)}_alt{alt}_mach{round(mach, 2)}"
f"_aoa{round(aoa, 1)}_aos{round(aos, 1)}"
)
f"Case{str(case_nb).zfill(2)}_alt{alt}_mach{round(mach, 2)}"
f"_aoa{round(aoa, 1)}_aos{round(aos, 1)}"
)

case_dir_path = Path(wkdir, case_dir_name)
if not case_dir_path.exists():
case_dir_path.mkdir()
case_dir_path.mkdir()
output_path = Path(case_dir_path, AINP_CFD_NAME)

case_dir_list = [dir for dir in wkdir.iterdir() if "Case" in dir.name]
if not case_dir_list:
raise OSError(f"No Case directory has been found in the working directory: {wkdir}")


for config_dir in sorted(case_dir_list):
current_dir = Path(case_dir_path, config_dir)
Expand All @@ -89,12 +88,13 @@ def run_edge_multi(wkdir, input_que_script_path , nb_proc=2):

if len(config_cfd) > 1:
raise ValueError(f"More than one '{AINP_CFD_NAME}' file in this directory!")

# run / submit edge commands
edge_scripts_instance = EdgeScripts(current_dir, input_que_script_path, AINP_CFD_NAME)
edge_scripts_instance.submit_preprocessor_script()
edge_scripts_instance.submit_solver_script(nb_proc)


# =================================================================================================
# MAIN
# =================================================================================================
Expand Down
33 changes: 18 additions & 15 deletions ceasiompy/EdgeRun/func/edgeconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# IMPORTS
# =================================================================================================

import math,os
import math, os

from pathlib import Path
from shutil import copyfile
Expand All @@ -43,7 +43,6 @@
)
from ceasiompy.utils.commonxpath import (
GMSH_SYMMETRY_XPATH,
PROP_XPATH,
RANGE_XPATH,
EDGE_MESH_XPATH,
EDGE_AEROMAP_UID_XPATH,
Expand All @@ -66,13 +65,16 @@
from cpacspy.cpacspy import CPACS
from ceasiompy.EdgeRun.func.edgeutils import get_edge_queScript_template
from ceasiompy.EdgeRun.func.edge_queScript_gen import EdgeScripts

# import cpacs

log = get_logger()

MODULE_DIR = Path(__file__).parent

input_que_script_path = get_edge_queScript_template()


# =================================================================================================
# CLASSES
# =================================================================================================
Expand Down Expand Up @@ -108,7 +110,7 @@ def edge_cfd(cpacs_path, cpacs_out_path, wkdir):
if not edge_mesh.is_file():
raise FileNotFoundError(f"M-Edge mesh file {edge_mesh} not found")
# copy edge_mesh and edge_aboc file to the Working directory

grid_folder = Path(wkdir, "grid")
to_grid = grid_folder / edge_mesh.name
to_aboc = grid_folder / edge_aboc.name
Expand All @@ -118,7 +120,6 @@ def edge_cfd(cpacs_path, cpacs_out_path, wkdir):
copyfile(edge_mesh, to_grid)
copyfile(edge_aboc, to_aboc)


# Get the fixedCL value from CPACS
fixed_cl = get_value_or_default(cpacs.tixi, EDGE_FIXED_CL_XPATH, "NO")
if fixed_cl == "NO":
Expand Down Expand Up @@ -195,7 +196,7 @@ def edge_cfd(cpacs_path, cpacs_out_path, wkdir):
CFL = get_value_or_default(cpacs.tixi, EDGE_CFL_NB_XPATH, 1.5)
NGRID = int(get_value_or_default(cpacs.tixi, EDGE_MG_LEVEL_XPATH, 3))
NPART = int(get_value_or_default(cpacs.tixi, EDGE_NB_CPU_XPATH, 64))
INSEUL = int(get_value_or_default(cpacs.tixi, EDGE_SOLVER_XPATH, 0))
INSEUL = int(get_value_or_default(cpacs.tixi, EDGE_SOLVER_XPATH, 0))

# Parameters which will vary for the different cases (alt,mach,aoa,aos)
for case_nb in range(len(alt_list)):
Expand Down Expand Up @@ -289,26 +290,28 @@ def edge_cfd(cpacs_path, cpacs_out_path, wkdir):
# create and submit the edge-run scripts
# run / submit edge commands
jobname = case_dir_name
edge_scripts_instance = EdgeScripts(jobname,case_dir_path, input_que_script_path, AINP_CFD_NAME)

edge_scripts_instance = EdgeScripts(
jobname, case_dir_path, input_que_script_path, AINP_CFD_NAME
)

bedg_files_exist = True
for i in range(1, NPART+1):
bedg_file_path = Path(case_dir_path, grid_folder, f'Edge.bedg_p{i}')
for i in range(1, NPART + 1):
bedg_file_path = Path(case_dir_path, grid_folder, f"Edge.bedg_p{i}")
if not bedg_file_path.exists():
bedg_files_exist = False
break

if not bedg_files_exist:
#edge_scripts_instance.submit_preprocessor_script(case_dir_path)
# edge_scripts_instance.submit_preprocessor_script(case_dir_path)
edge_scripts_instance.run_preprocessor(case_dir_path)
print('bedg files are generated')
#else:
print("bedg files are generated")
# else:
# print('bedg files exist, not generated')
#edge_scripts_instance.submit_solver_script(case_dir_path,NPART)
edge_scripts_instance.run_edgesolver(case_dir_path,NPART)
# edge_scripts_instance.submit_solver_script(case_dir_path,NPART)
edge_scripts_instance.run_edgesolver(case_dir_path, NPART)

# postprocess for results
edge_scripts_instance.postprocess_script(case_dir_path,edge_mesh)
edge_scripts_instance.postprocess_script(case_dir_path, edge_mesh)
# wait until the results are generated
cpacs.save_cpacs(cpacs_out_path, overwrite=True)

Expand Down
4 changes: 1 addition & 3 deletions src/streamlit/pages/01_ ➡_Workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@


def section_predefined_workflow():

st.markdown("#### Predefined Workflows")

predefine_workflows = [
["PyTornado", "WeightConventional"],
["CPACS2GMSH", "SU2Run", "SkinFriction"],
["CPACS2SUMO", "SUMOAutoMesh", "SU2Run", "ExportCSV"],
["CPACS2SUMO", "SUMOAutoMesh", "EdgeRun"],
]

for workflow in predefine_workflows:
Expand All @@ -75,15 +75,13 @@ def section_predefined_workflow():


def section_add_module():

st.markdown("#### Your workflow")

if "workflow_modules" not in st.session_state:
st.session_state["workflow_modules"] = []

if len(st.session_state.workflow_modules):
for i, module in enumerate(st.session_state.workflow_modules):

col1, col2, col3, _ = st.columns([6, 1, 1, 5])

with col1:
Expand Down

0 comments on commit 8168006

Please sign in to comment.