Skip to content

Commit

Permalink
Improve desktop launch (#3947)
Browse files Browse the repository at this point in the history
* speed improvement on import_nastran method
Desktop is not launched anymore in a thread in Windows

* speed improvement on import_nastran method
Desktop is not launched anymore in a thread in Windows

* removed setting launch_desktop_in_thread

* removed unnecessary value_with_units call in add_variation method

---------

Co-authored-by: maxcapodi78 <Shark78>
  • Loading branch information
Alberto-DM committed Dec 6, 2023
1 parent 3376ce9 commit 223399e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
8 changes: 2 additions & 6 deletions pyaedt/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,9 @@ def launch_desktop_on_port():
my_env[env] = val
if is_linux: # pragma: no cover
command.append("&")
with subprocess.Popen(command, env=my_env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) as p:
p.wait()
subprocess.Popen(command, env=my_env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
with subprocess.Popen(
" ".join(command), env=my_env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
) as p:
p.wait()
subprocess.Popen(" ".join(command), env=my_env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

_aedt_process_thread = threading.Thread(target=launch_desktop_on_port)
_aedt_process_thread.daemon = True
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/generic/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self):
}
if is_linux:
self._aedt_environment_variables["ANS_NODEPCHECK"] = "1"
self._desktop_launch_timeout = 90
self._desktop_launch_timeout = 120
self._number_of_grpc_api_retries = 6
self._retry_n_times_time_interval = 0.1
self._wait_for_license = False
Expand Down
2 changes: 2 additions & 0 deletions pyaedt/modeler/geometry_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ def normalize_vector(v):
"""
# normalize a vector to its norm
norm = GeometryOperators.v_norm(v)
if norm == 0.0:
return v
vn = [i / norm for i in v]
return vn

Expand Down
12 changes: 8 additions & 4 deletions pyaedt/modeler/modeler3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,8 @@ def import_nastran(self, file_path, import_lines=True, lines_thickness=0, import
with open(file_path, "r") as f:
lines = f.read().splitlines()
id = 0
for line in lines:
for lk in range(len(lines)):
line = lines[lk]
line_type = line[:8].strip()
if line.startswith("$") or line.startswith("*"):
continue
Expand Down Expand Up @@ -939,7 +940,8 @@ def import_nastran(self, file_path, import_lines=True, lines_thickness=0, import

n3 = line[72:88].strip()
if not n3 or n3 == "*":
n3 = lines[lines.index(line) + 1][8:24].strip()
lk += 1
n3 = lines[lk][8:24].strip()
if "-" in n3[1:]:
n3 = n3[0] + n3[1:].replace("-", "e-")
if line_type == "GRID*":
Expand Down Expand Up @@ -978,8 +980,9 @@ def import_nastran(self, file_path, import_lines=True, lines_thickness=0, import
if line_type == "CHEXA":
n5 = int(line[56:64])
n6 = int(line[64:72])
n7 = int(lines[lines.index(line) + 1][8:16].strip())
n8 = int(lines[lines.index(line) + 1][16:24].strip())
lk += 1
n7 = int(lines[lk][8:16].strip())
n8 = int(lines[lk][16:24].strip())

obj_list.extend([n5, n6, n7, n8])
if obj_id in nas_to_dict["Solids"]:
Expand Down Expand Up @@ -1021,6 +1024,7 @@ def import_nastran(self, file_path, import_lines=True, lines_thickness=0, import
n = [1, 0, 0]
else:
n = GeometryOperators.v_cross(cv1, cv2)

normal = GeometryOperators.normalize_vector(n)
if normal:
f.write(" facet normal {} {} {}\n".format(normal[0], normal[1], normal[2]))
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/modules/DesignXPloration.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def add_variation(self, sweep_var, start_point, end_point=None, step=100, unit=N
elif variation_type == "LogScale":
sweep_range = "DEC {} {} {}".format(start_point, end_point, self._app.value_with_units(step, unit))
elif variation_type == "SingleValue":
sweep_range = "{}".format(self._app.value_with_units(start_point, unit))
sweep_range = "{}".format(start_point)
if not sweep_range:
return False
self._activate_variable(sweep_var)
Expand Down

0 comments on commit 223399e

Please sign in to comment.