#
# Copyright ANSYS. All Rights Reserved.
#
# This is a template script for the ANSYS, Inc. ICEM CFD Tetra meshing method.
#
#
# Set working directory and file names
#
set work [file dirname "${ICEMCFD_INPUT_MODEL}"]
ic_mess "\nWorking directory is \"$work\".\n"
ic_chdir "$work"
set prj [file rootname "${ICEMCFD_INPUT_MODEL}"].prj
ic_set_project_names "${ICEMCFD_INPUT_MODEL} ${ICEMCFD_OUTPUT_MESH} {$prj}"
#
# Write the ICEM CFD process information
#
# TO BE DONE : ic_write_process_info "${ICEMCFD_PROGRESS_PREFIX}FMICEMCFDProcessInfo.txt"
#
# Start by updating the progress
#
# TO BE DONE : ic_update_progress 15 "${ICEMCFD_PROGRESS_PREFIX}" "FMICEMCFDInteractiveProgress.lck" "FMICEMCFDInteractiveProgress.txt"
#
# Read in the model to be meshed
#
ic_mess "Loading geometry file ...\n"
ic_load_tetin [ic_win_shortname "${ICEMCFD_INPUT_MODEL}"]
ic_display_update all
ic_view home
#
# TO BE DONE : ic_update_progress 20 "${ICEMCFD_PROGRESS_PREFIX}" "FMICEMCFDInteractiveProgress.lck" "FMICEMCFDInteractiveProgress.txt"
#
# Set meshing options
#
ic_mess "Setting meshing options ...\n"
${ICEMCFD_MESH_ICTETRA_OPTIONS}
#
# Insert a custom replay
#
${ICEMCFD_CUSTOM_REPLAY}
#
# Run Tetra meshing
#
ic_mess "Meshing ...\n"
set tetparams [list wb_assembly_meshing 1 run_cutter 1 run_smoother 1 smoother_n_iter $volume_smoothing_steps  n_tri_smoothing_steps $surface_smoothing_steps  smoother_aspect $smoothing_limit fix_holes 1 in_process 1 n_processors $num_proc auto_vol 1 quiet 0]
if {[info exists additionaltetparams]} {set tetparams [concat $tetparams $additionaltetparams]}
${ICEMCFD_INTERACTIVE_CMD_PREFIX} eval ic_run_tetra 0 0 $tetparams
#
# TO BE DONE : ic_update_progress 80 "${ICEMCFD_PROGRESS_PREFIX}" "FMICEMCFDInteractiveProgress.lck" "FMICEMCFDInteractiveProgress.txt"
#
# Perform Tetra post smoothing
#
# TO BE DONE : ic_update_progress 85 "${ICEMCFD_PROGRESS_PREFIX}" "FMICEMCFDInteractiveProgress.lck" "FMICEMCFDInteractiveProgress.txt"
#
# Exit ICEM CFD and return to Workbench, i.e. write out the generated mesh and exit
#
ic_mess "Please save the mesh before exiting ICEM CFD for returning the mesh to Workbench ...\n"
#
${ICEMCFD_INTERACTIVE_CMD_PREFIX}ic_save_unstruct [ic_win_shortname "${ICEMCFD_OUTPUT_MESH}"]
#
${ICEMCFD_INTERACTIVE_MESSAGE}
