Skip to content

Commit cfecace

Browse files
Create Config Menu & set MPI_ROOT in
OpenRadioss_GUI sets all variables for Linux (OpenMPI) / Linuxa64 (OpenMPI) or Windows (IntelMPI) Fix an issue : in the Run option box : Previous settings stored in json config file are no more taken into account when rerunning the GUI
1 parent dd91ea4 commit cfecace

File tree

8 files changed

+153
-65
lines changed

8 files changed

+153
-65
lines changed

openradioss_gui/OpenRadioss_gui.py

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,29 @@ class openradioss_gui:
4949
def __init__(self,debug):
5050
# Global Variables
5151
self.debug=debug
52-
self.current_platform = platform.system()
52+
self.mpi_path = ''
53+
self.current_platform = platform.system()
54+
55+
self.load_config()
56+
5357
self.job_holder = JobHolder(self.debug)
54-
self.Window = gui_def.window(vd3penabled, vtkhdfenabled)
58+
# 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)
5560

5661
self.job_file_entry=self.Window.file('Job file (.rad, .key, or .k, or .inp)', self.select_file, self.Window.icon_folder)
5762

5863
# Dropdown to set variables
5964
selected_flags = self.Window.get_selected_options()
6065

66+
print("single precision: ", self.single_status)
6167
# Assign tk.BooleanVar objects
6268
self.single_status = selected_flags['Single Precision']
6369
self.starter_status = selected_flags['Run Starter Only']
6470
self.vtk_status = selected_flags['Anim - vtk']
6571
self.vtkhdf_status = selected_flags['Anim - vtkhdf']
6672
self.d3plot_status = selected_flags['Anim - d3plot']
6773
self.csv_status = selected_flags['TH - csv']
68-
74+
6975
# Create checkboxes
7076
self.nt_entry = self.Window.thread_mpi('-nt', 5, 0, 2)
7177
self.np_entry = self.Window.thread_mpi('-np', 5, 5, 2)
@@ -77,11 +83,11 @@ def __init__(self,debug):
7783
self.Window.button('Close', self.close_window, (5, 0))
7884

7985
# Create a menu bar
80-
self.Window.menubar('Info')
86+
self.Window.menubar()
8187

82-
self.load_config()
8388
self.Window.root.protocol("WM_DELETE_WINDOW", self.close_window)
8489
self.Window.root.after(1000, self.run_job)
90+
8591
self.Window.root.mainloop()
8692

8793

@@ -100,6 +106,7 @@ def close_window(self):
100106
#----------------------------------------------------------------------------
101107
def add_job(self):
102108
self.check_install()
109+
103110

104111
if self.job_file_entry.is_placeholder_active() or not os.path.exists(self.job_file_entry.get_user_input()):
105112
messagebox.showerror('', 'Select job.')
@@ -122,7 +129,10 @@ def add_job(self):
122129
else:
123130
d3plot = 'no'
124131

125-
allcommand = [os.path.normpath(file), nt, np, precision, anim_to_vtk, th_to_csv, starter_only, d3plot, anim_to_vtkhdf]
132+
self.mpi_path = self.Window.mpi_path
133+
# print('mpi_path='+self.mpi_path)
134+
135+
allcommand = [os.path.normpath(file), nt, np, precision, anim_to_vtk, th_to_csv, starter_only, d3plot, anim_to_vtkhdf,self.mpi_path]
126136

127137
# Add Job in Queue
128138
if messagebox.askokcancel('Add job', 'Add job?'):
@@ -150,20 +160,6 @@ def select_file(self):
150160
self.job_file_entry.delete(0, tk.END)
151161
self.job_file_entry.insert(0, file_path)
152162

153-
def check_mpi_path(self):
154-
mpi_path_file = "path_to_intel-mpi.txt"
155-
if self.np_entry.get_user_input() > '1' and not os.path.exists(mpi_path_file):
156-
messagebox.showinfo('', 'Running MPI requires intel mpi installation. Please browse to an intel-mpi location. Or select np = 1')
157-
directory_path = filedialog.askdirectory(
158-
title='Select intel-mpi directory'
159-
)
160-
if directory_path:
161-
with open(mpi_path_file, 'w') as file:
162-
file.write('"' + directory_path + '"')
163-
else:
164-
# MPI path file exists or np <= 1, continue with the script
165-
pass
166-
167163
def check_sp_exes(self):
168164
if platform.system() == 'Windows':
169165
sp_executable = "../exec/starter_win64_sp.exe"
@@ -198,6 +194,7 @@ def save_config(self):
198194
config['d3plot'] = self.d3plot_status.get()
199195
config['np'] = self.np_entry.get_user_input()
200196
config['nt'] = self.nt_entry.get_user_input()
197+
config['mpi_path'] = self.mpi_path
201198

202199
# Open File & Write Json file
203200
if self.current_platform == 'Windows':
@@ -228,20 +225,46 @@ def load_config(self):
228225

229226

230227
json_file=os.path.join(directory, 'config.json')
231-
print('Json File:',json_file)
228+
# print('Json File:',json_file)
232229
try:
233230
with open(json_file, mode='r') as file:
234231
config_file=json.load(file)
235232
file.close()
236233

237-
self.starter_status.set(config_file['starter_only'])
238-
self.vtk_status.set(config_file['vtk'])
239-
self.single_status.set(config_file['sp'])
240-
self.csv_status.set(config_file['csv'])
234+
if "mpi_path" in config_file:
235+
self.mpi_path = config_file['mpi_path']
236+
else:
237+
self.mpi_path = ''
238+
#
239+
if "sp" in config_file:
240+
self.single_status=config_file['sp']
241+
else:
242+
self.single_status="false"
243+
#
244+
if 'starter_only' in config_file:
245+
self.starter_status=config_file['starter_only']
246+
else:
247+
self.starter_status=False
248+
#
249+
if 'vtk' in config_file:
250+
self.vtk_status=config_file['vtk']
251+
else:
252+
self.vtk_status=False
253+
#
254+
if 'csv' in config_file:
255+
self.csv_status=config_file['csv']
256+
else:
257+
self.csv_status=False
258+
#
259+
self.vtkhdf_status=False
241260
if vtkhdfenabled:
242-
self.vtkhdf_status.set(config_file['vtkhdf'])
261+
if 'vtkhdf' in config_file:
262+
self.vtkhdf_status=config_file['vtkhdf']
263+
264+
self.d3plot_status=False
243265
if vd3penabled:
244-
self.d3plot_status.set(config_file['d3plot'])
266+
if 'd3plot' in config_file:
267+
self.d3plot_status=config_file['d3plot']
245268

246269
except:
247270
config_file={}

openradioss_gui/README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The D3plot converter can be found at: [Vortex-CAE GitHub repository](https://git
3535
* Launch the **OpenRadioss_gui.vbs** on Windows
3636
* Launch the **OpenRadioss_gui.bash** on Linux
3737

38-
![image](./icon/OpenRadioss_gui.png)
38+
![image](./icon/OpenRadioss_gui.jpg)
3939

4040
### Launch a job
4141

@@ -49,15 +49,38 @@ The D3plot converter can be found at: [Vortex-CAE GitHub repository](https://git
4949
* **Enter the number of MPI Domains for the job** in the -np field
5050
* **Click "Add Job"** Run Window apprears.
5151

52-
### Notes
52+
### Menus
53+
54+
### Config
55+
56+
* ***MPI Path***: Set the ROOT directory to MPI installation. Leave it blank to use system default variables
57+
58+
* ***Windows (win64)***: ROOT directory to INTEL MPI. Usual IntelMPI installation is located at :
59+
60+
C:\Program Files (x86)\Intel\oneAPI\mpi\latest
61+
62+
* ***Linux X86-64 (linux64_gf)***: Path to OpenMPI. OpenRadioss guidelines for OpenMPI locates it in:
63+
64+
/opt/openmpi
65+
66+
* ***Linux ARM64 (linuxa64)***: Path to OpenMPI. OpenRadioss guidelines for OpenMPI locates it in:
67+
68+
/opt/openmpi
69+
70+
### Info
71+
72+
* Menu with usefull informations about OpenRadioss
73+
74+
#### Run Options
75+
76+
Set optional execution options
5377

5478
* **Single Precision** in Run Options dropdown enables the OpenRadioss single precision version
5579
* **Run Starter Only** in Run Options dropdown executes Starter only.
5680
* **Anim - vtk** in Run Options dropdown invokes the Animation to VTK converter at the end of OpenRadioss Engine simulation.
5781
* **TH - csv** in Run Options dropdown invokes the TH to CSV converter at the end of OpenRadioss Engine simulation.
5882
* **Show Queue** and **Clear Queue** buttons manage the run queue.
5983
* The **info** menu has links to the downloads section of github and an ‘About’ credit to the script creators
60-
* **In Windows version only**: On first attempt to submit an mpi run (-np > 1) you will be prompted to locate a suitable vars.bat file on your machine, once selected, this is remembered (to reset, delete the created ‘path_to_mpi_vars.txt’ file from the install directory, or edit its contents)
6184
* ***Anim - d3plot** in Run Options dropdown appears only if Vortex-CAE D3plot converter is detected.
6285
* ***Anim - vtkhdf** in Run Options dropdown appears only if Kitware animtovtkhdf converter is detected.
6386

openradioss_gui/gui_def.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1919

2020
import tkinter as tk
21-
from tkinter import messagebox
21+
from tkinter import messagebox, simpledialog
2222
import platform
2323
import webbrowser
2424
from button_with_highlight import ButtonWithHighlight
@@ -32,11 +32,13 @@
3232
button_width=8
3333

3434
class window:
35-
def __init__(self, vd3penabled, vtkhdfenabled):
35+
def __init__(self, vd3penabled, vtkhdfenabled,mpi_path,sp_status,starter_status,vtk_status,csv_status,vtkhdf_status,d3plot_status):
36+
3637
self.root = tk.Tk()
3738
self.root.title('OpenRadioss')
3839
self.vd3penabled = vd3penabled
3940
self.vtkhdfenabled = vtkhdfenabled
41+
self.mpi_path = mpi_path
4042

4143
if arch == 'Windows':
4244
self.root.geometry('700x105')
@@ -57,12 +59,12 @@ def __init__(self, vd3penabled, vtkhdfenabled):
5759

5860
# Dropdown Variables
5961
self.variables = {
60-
'Single Precision': tk.BooleanVar(),
61-
'Run Starter Only': tk.BooleanVar(),
62-
'Anim - vtk': tk.BooleanVar(),
63-
'Anim - vtkhdf': tk.BooleanVar(),
64-
'Anim - d3plot': tk.BooleanVar(),
65-
'TH - csv': tk.BooleanVar(),
62+
'Single Precision': tk.BooleanVar(value=sp_status),
63+
'Run Starter Only': tk.BooleanVar(value=starter_status),
64+
'Anim - vtk': tk.BooleanVar(value=vtk_status),
65+
'Anim - vtkhdf': tk.BooleanVar(value=vtkhdf_status),
66+
'Anim - d3plot': tk.BooleanVar(value=d3plot_status),
67+
'TH - csv': tk.BooleanVar(value=csv_status),
6668
}
6769

6870
self.variable_flags = {
@@ -115,19 +117,26 @@ def get_selected_options(self):
115117
# Return the current state of the dropdown variables
116118
return self.variables
117119

118-
def menubar(self,title):
120+
121+
def menubar(self):
119122
self.menubar = tk.Menu(self.root)
120123
self.root.config(menu=self.menubar)
124+
#
125+
self.config_menu = tk.Menu(self.menubar, tearoff=False)
126+
self.menubar.add_cascade(label="Config", menu=self.config_menu)
127+
#
128+
self.about_menu = tk.Menu(self.menubar, tearoff=False)
129+
self.menubar.add_cascade(label="Info", menu=self.about_menu)
130+
#
131+
self.config_menu.add_command(label="MPI Path", command=self._set_mpi_path_dialog)
132+
#
133+
self.about_menu.add_command(label="Get the latest version of OpenRadioss (github link)", command=self._latestv_dialog)
134+
self.about_menu.add_command(label="Documentation and Latest Version of this gui (github_link)", command=self._latestgui_dialog)
135+
self.about_menu.add_command(label="Get the latest version of the VortexRadioss d3plot python module (github link)", command=self._latestvrad_dialog)
136+
self.about_menu.add_command(label="Get the latest version of the kitware animtovtkhdf python module (gitlab link)", command=self._latestvtkh_dialog)
137+
self.about_menu.add_command(label="Visit the OpenRadioss web page", command=self._orweb_dialog)
138+
self.about_menu.add_command(label="About this gui", command=self._about_dialog)
121139

122-
if title=='Info':
123-
self.about_menu = tk.Menu(self.menubar, tearoff=False)
124-
self.menubar.add_cascade(label="Info", menu=self.about_menu)
125-
self.about_menu.add_command(label="Get the latest version of OpenRadioss (github link)", command=self._latestv_dialog)
126-
self.about_menu.add_command(label="Documentation and Latest Version of this gui (github_link)", command=self._latestgui_dialog)
127-
self.about_menu.add_command(label="Get the latest version of the VortexRadioss d3plot python module (github link)", command=self._latestvrad_dialog)
128-
self.about_menu.add_command(label="Get the latest version of the kitware animtovtkhdf python module (gitlab link)", command=self._latestvtkh_dialog)
129-
self.about_menu.add_command(label="Visit the OpenRadioss web page", command=self._orweb_dialog)
130-
self.about_menu.add_command(label="About this gui", command=self._about_dialog)
131140

132141
def file(self,text,command,icon_folder):
133142
job_file_entry = PlaceholderEntry(self.frame_file, placeholder_text=text, entry_width=83)
@@ -161,4 +170,7 @@ def _orweb_dialog(self):
161170
webbrowser.open("https://openradioss.org")
162171
def _about_dialog(self):
163172
messagebox.showinfo("About", "this job submission gui is from OpenRadioss tools" )
164-
173+
def _set_mpi_path_dialog(self):
174+
value = simpledialog.askstring("MPI Path", "Enter the ROOT directory of MPI installation: ", initialvalue=self.mpi_path)
175+
if value is not None:
176+
self.mpi_path = value
16.2 KB
Loading
-7.84 KB
Binary file not shown.
35.6 KB
Loading

openradioss_gui/job_window.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(self, command,debug):
7070
self.job_dir = os.path.dirname(command[0])
7171
self.stop_after_starter=False
7272
jnm1 = command[0]
73+
mpi_path= command[9]
7374

7475
# Create an instance of RunOpenRadioss
7576
self.runOpenRadioss = RunOpenRadioss(self.command,self.debug)

0 commit comments

Comments
 (0)