|
17 | 17 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR |
18 | 18 | # IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
19 | 19 | import os |
| 20 | +import sys |
| 21 | +import argparse |
20 | 22 | import json |
21 | 23 | import platform |
22 | 24 | import tkinter as tk |
|
42 | 44 | except ImportError: |
43 | 45 | vtkhdfenabled = False |
44 | 46 | import gui_def |
| 47 | +from runopenradioss import RunOpenRadioss |
45 | 48 |
|
46 | 49 |
|
47 | 50 | class openradioss_gui: |
48 | 51 |
|
49 | | - def __init__(self,debug): |
| 52 | + def __init__(self,debug,script_dir): |
50 | 53 | # Global Variables |
51 | 54 | self.debug=debug |
| 55 | + self.script_dir=script_dir |
52 | 56 | self.mpi_path = '' |
53 | 57 | self.current_platform = platform.system() |
54 | 58 |
|
55 | 59 | self.load_config() |
56 | 60 |
|
57 | 61 | self.job_holder = JobHolder(self.debug) |
58 | 62 | # Check if the user has selected a valid MPI path |
59 | | - self.Window = gui_def.window(vd3penabled, vtkhdfenabled,self.mpi_path,self.single_status,self.starter_status,self.vtk_status,self.csv_status,self.vtkhdf_status,self.d3plot_status) |
| 63 | + self.Window = gui_def.window(vd3penabled, vtkhdfenabled,self.mpi_path,self.single_status,self.starter_status,self.vtk_status,self.csv_status,self.vtkhdf_status,self.d3plot_status,script_dir) |
60 | 64 |
|
61 | 65 | self.job_file_entry=self.Window.file('Job file (.rad, .key, or .k, or .inp)', self.select_file, self.Window.icon_folder) |
62 | 66 |
|
@@ -172,7 +176,7 @@ def check_sp_exes(self): |
172 | 176 | pass |
173 | 177 |
|
174 | 178 | def check_install(self): |
175 | | - is_installed = "../hm_cfg_files" |
| 179 | + is_installed = self.script_dir +os.sep +".."+os.sep+"hm_cfg_files" |
176 | 180 | if not os.path.exists(is_installed): |
177 | 181 | messagebox.showinfo('INCORRECT INSTALL LOCATION', 'The guiscripts folder needs to be saved inside\n your OpenRadioss Folder\n (Same Folder Level as exec and hm_cfg_files)') |
178 | 182 |
|
@@ -282,4 +286,56 @@ def load_config(self): |
282 | 286 | if __name__ == "__main__": |
283 | 287 | #----------------------------- GUI Elements #-------------------------------- |
284 | 288 | # File Menu |
285 | | - gui= openradioss_gui(0) |
| 289 | + num_args = len(sys.argv) - 1 |
| 290 | + parser = argparse.ArgumentParser(description='OpenRadioss GUI') |
| 291 | + parser.add_argument('-gui', '--gui',action='store_true', default=False, help='Enable GUI mode') |
| 292 | + parser.add_argument('-i', '--input', type=str, help='The input file to process in form: filename<.k|.key>, filename_<runnumber 4 digits>.rad or filename.inp') |
| 293 | + parser.add_argument('-nt', '--nt', type=int, metavar='n', help='Number of threads') |
| 294 | + parser.add_argument('-np', '--np', type=int, metavar='p', help='Number of MPI process') |
| 295 | + parser.add_argument('-sp', '--sp', action='store_true', default=False, help='Enable Extended Single precision mode (default is double precision)') |
| 296 | + parser.add_argument('-starter', '--starter_only', action='store_true', default=False, help='Enable Starter Only mode') |
| 297 | + parser.add_argument('-th_to_csv', '--th_to_csv', action='store_true', default=False, help='Enable TH to CSV conversion') |
| 298 | + parser.add_argument('-anim_to_vtk', '--anim_to_vtk', action='store_true', default=False, help='Enable Animation to VTK conversion') |
| 299 | + parser.add_argument('-anim_to_d3plot', '--anim_to_d3plot', action='store_true', default=False, help='Enable Animation to D3plot conversion (need VortexRadioss installed)') |
| 300 | + parser.add_argument('-anim_to_vtkhdf', '--anim_to_vtkhdf', action='store_true', default=False, help='Enable Animation to VTKHDF conversion (need VTKHDF installed)') |
| 301 | + parser.add_argument('-mpi_path', '--mpi_path', type=str, help='Path to MPI installation') |
| 302 | + parser.add_argument('-d', '--debug',action='store_true', default=False, help='Enable debug mode') |
| 303 | + args = parser.parse_args() |
| 304 | + |
| 305 | + script_dir = os.path.abspath(__file__) |
| 306 | + script_dir = os.path.dirname(script_dir)+os.sep |
| 307 | + if num_args > 0: |
| 308 | + if args.gui: |
| 309 | + debug=1 if args.debug else 0 |
| 310 | + gui= openradioss_gui(debug,script_dir) |
| 311 | + exit(0) |
| 312 | + if not args.input: |
| 313 | + print(" ") |
| 314 | + print("Error: Input file is required in non-GUI mode.") |
| 315 | + print(" ") |
| 316 | + |
| 317 | + parser.print_help() |
| 318 | + exit(1) |
| 319 | + |
| 320 | + if not args.nt: args.nt=1 |
| 321 | + if not args.np: args.np=1 |
| 322 | + |
| 323 | + command = [] |
| 324 | + command.append(args.input) |
| 325 | + command.append(str(args.nt)) |
| 326 | + command.append(str(args.np)) |
| 327 | + command.append("sp" if args.sp else "dp") # precision |
| 328 | + command.append("yes" if args.anim_to_vtk else "no") # anim_to_vtk |
| 329 | + command.append("yes" if args.th_to_csv else "no") # th_to_csv |
| 330 | + command.append("yes" if args.starter_only else "no") # starter_only |
| 331 | + command.append("yes" if args.anim_to_d3plot else "no") # anim_to_d3plot |
| 332 | + command.append("yes" if args.anim_to_vtkhdf else "no") # anim_to_vtkhdf |
| 333 | + command.append(args.mpi_path if args.mpi_path else "") # mpi_path |
| 334 | + |
| 335 | + Run_OR= RunOpenRadioss(command, debug=1 if args.debug else 0) |
| 336 | + Run_OR.batch_run() |
| 337 | + |
| 338 | + else: |
| 339 | + script_dir = os.path.abspath(__file__) |
| 340 | + script_dir = os.path.dirname(script_dir)+os.sep |
| 341 | + gui= openradioss_gui(0,script_dir) |
0 commit comments