ansys-pyensight-core 0.8.0__tar.gz → 0.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansys-pyensight-core might be problematic. Click here for more details.

Files changed (35) hide show
  1. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/PKG-INFO +1 -1
  2. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/pyproject.toml +1 -1
  3. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/session.py +35 -0
  4. ansys_pyensight_core-0.8.1/src/ansys/pyensight/core/utils/readers.py +270 -0
  5. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/variables.py +71 -82
  6. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/LICENSE +0 -0
  7. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/README.rst +0 -0
  8. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/__init__.py +0 -0
  9. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/deep_pixel_view.html +0 -0
  10. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/dockerlauncher.py +0 -0
  11. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/enscontext.py +0 -0
  12. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/enshell_grpc.py +0 -0
  13. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/ensight_grpc.py +0 -0
  14. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/ensobj.py +0 -0
  15. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/launch_ensight.py +0 -0
  16. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/launcher.py +0 -0
  17. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/listobj.py +0 -0
  18. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/locallauncher.py +0 -0
  19. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/py.typed +0 -0
  20. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/renderable.py +0 -0
  21. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/sgeo_poll.html +0 -0
  22. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/__init__.py +0 -0
  23. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/adr.py +0 -0
  24. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/export.py +0 -0
  25. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/omniverse.py +0 -0
  26. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/omniverse_dsg_server.py +0 -0
  27. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/parts.py +0 -0
  28. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/query.py +0 -0
  29. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/resources/Materials/000_sky.exr +0 -0
  30. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_BaseColor.png +0 -0
  31. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_N.png +0 -0
  32. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_ORM.png +0 -0
  33. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/resources/Materials/Fieldstone.mdl +0 -0
  34. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/support.py +0 -0
  35. {ansys_pyensight_core-0.8.0 → ansys_pyensight_core-0.8.1}/src/ansys/pyensight/core/utils/views.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ansys-pyensight-core
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: A python wrapper for Ansys EnSight
5
5
  Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
6
6
  Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
@@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"
6
6
 
7
7
  [project]
8
8
  name = "ansys-pyensight-core"
9
- version = "0.8.0"
9
+ version = "0.8.1"
10
10
  description = "A python wrapper for Ansys EnSight"
11
11
  readme = "README.rst"
12
12
  requires-python = ">=3.9,<4"
@@ -1778,3 +1778,38 @@ class Session:
1778
1778
  message = f"A newer version of EnSight is required to use this API:{base_msg}"
1779
1779
  raise InvalidEnSightVersion(message)
1780
1780
  return valid
1781
+
1782
+ def find_remote_unused_ports(
1783
+ self,
1784
+ count: int,
1785
+ start: Optional[int] = None,
1786
+ end: Optional[int] = None,
1787
+ avoid: Optional[list[int]] = None,
1788
+ ) -> Optional[List[int]]:
1789
+ """
1790
+ Find "count" unused ports on the host system. A port is considered
1791
+ unused if it does not respond to a "connect" attempt. Walk the ports
1792
+ from 'start' to 'end' looking for unused ports and avoiding any ports
1793
+ in the 'avoid' list. Stop once the desired number of ports have been
1794
+ found. If an insufficient number of ports were found, return None.
1795
+ An admin user check is used to skip [1-1023].
1796
+
1797
+ Parameters
1798
+ ----------
1799
+ count: int
1800
+ number of unused ports to find
1801
+ start: int
1802
+ the first port to check or None (random start)
1803
+ end: int
1804
+ the last port to check or None (full range check)
1805
+ avoid: list
1806
+ an optional list of ports not to check
1807
+
1808
+ Returns
1809
+ -------
1810
+ the detected ports or None on failure
1811
+ """
1812
+ cmd = "from cei import find_unused_ports\n"
1813
+ cmd += f"ports = find_unused_ports({count}, start={start}, end={end}, avoid={avoid})"
1814
+ self.cmd(cmd, do_eval=False)
1815
+ return self.cmd("ports")
@@ -0,0 +1,270 @@
1
+ """Readers module.
2
+
3
+ This module contains utilities to do readers specific operations.
4
+ """
5
+ import os
6
+ import re
7
+ from threading import Thread
8
+ import time
9
+ from types import ModuleType
10
+ from typing import Optional, Tuple, Union
11
+ import uuid
12
+
13
+ from ansys.pyensight.core import LocalLauncher
14
+
15
+ try:
16
+ import ensight
17
+ except ImportError:
18
+ from ansys.api.pyensight import ensight_api
19
+
20
+
21
+ class Readers:
22
+ """A namespace to access the interfaces of specific readers"""
23
+
24
+ def __init__(self, interface: Union["ensight_api.ensight", "ensight"]):
25
+ self._ensight = interface
26
+ self._dvs = DVS(self._ensight)
27
+
28
+ @property
29
+ def dvs(self):
30
+ return self._dvs
31
+
32
+
33
+ class DVS:
34
+ """A namespace to access specific DVS interfaces"""
35
+
36
+ def __init__(self, interface: Union["ensight_api.ensight", "ensight"]):
37
+ self._ensight: Union["ensight_api.ensight", "ensight"] = interface
38
+ self._dvs_port: Optional[int] = None
39
+
40
+ MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT = "stay_at_current"
41
+ MONITOR_NEW_TIMESTEPS_JUMP_TO_END = "jump_to_end"
42
+
43
+ def _launch_live_dvs_242_cmd(
44
+ self,
45
+ tmp_name: str,
46
+ port: int = 0,
47
+ secret_key: Optional[str] = None,
48
+ monitor_new_timesteps: str = MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT,
49
+ ):
50
+ """Launch a live DVS session from PyEnSight for EnSight 242 and onward"""
51
+ indent = " "
52
+ cmd = "import re\n"
53
+ cmd += "def dvs_callback():\n"
54
+ cmd += f'{indent}command_string = f"set_server_port={port}"\n'
55
+ if secret_key is not None:
56
+ secret_string = f'{indent}command_string += f"&set_secret_key='
57
+ secret_string += secret_key + '"\n'
58
+ cmd += secret_string
59
+ tmp_name = tmp_name.replace("\\", "\\\\")
60
+ cmd += f"{indent}reply = ensight.objs.core.CURRENTCASE[0].client_command(command_string)\n"
61
+ cmd += f"{indent}dvs_port_string = ensight.objs.core.CURRENTCASE[0].client_command('get_server_port')\n"
62
+ cmd += (
63
+ f"{indent}dvs_port = int(re.search(r':([0-9]{{4,5}})', dvs_port_string).groups(1)[0])\n"
64
+ )
65
+ cmd += f"{indent}with open('{tmp_name}', 'w') as temp_file:\n"
66
+ cmd += f"{2*indent}temp_file.write(str(dvs_port))\n"
67
+ cmd += f"{indent}return True\n\n"
68
+ cmd += "reply = ensight.objs.core.CURRENTCASE[0].client_command_callback(dvs_callback)\n"
69
+ if monitor_new_timesteps:
70
+ cmd += f'ensight.solution_time.monitor_for_new_steps("{monitor_new_timesteps}")\n'
71
+ cmd += 'ensight.part.elt_representation("3D_feature_2D_full")\n'
72
+ cmd += 'err = ensight.data.replace("notexisting.dvs")\n'
73
+ return cmd
74
+
75
+ def _launch_live_dvs_241_cmd(
76
+ self,
77
+ port: int = 0,
78
+ secret_key: Optional[str] = None,
79
+ monitor_new_timesteps: str = MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT,
80
+ ):
81
+ """Launch a live DVS session from PyEnSight for EnSight 241"""
82
+ if port == 0:
83
+ ports = self._ensight._session.find_remote_unused_ports(1)
84
+ if ports:
85
+ self._dvs_port = ports[0]
86
+ port = ports[0]
87
+ indent = " "
88
+ cmd = "import os\n"
89
+ cmd += f"try:\n{indent}os.remove('remote.dvs')\n"
90
+ cmd += f"except (FileNotFoundError, OSError):\n{indent}pass\n"
91
+ cmd += "path = os.path.join(os.getcwd(), 'remote.dvs')\n"
92
+ cmd += "with open(path, 'w') as dvsfile:\n"
93
+ cmd += f"{indent}dvsfile.write('#!DVS_CASE 1.0\\n')\n"
94
+ cmd += f"{indent}dvsfile.write(f'SERVER_PORT_BASE={port}\\n')\n"
95
+ cmd += f"{indent}dvsfile.write('SERVER_PORT_MULT=1\\n')\n"
96
+ if secret_key:
97
+ cmd += f"{indent}dvsfile.write(f'SERVER_SECURITY_SECRET={secret_key}\\n')\n"
98
+ cmd += f'ensight.solution_time.monitor_for_new_steps("{monitor_new_timesteps}")\n'
99
+ cmd += 'ensight.part.elt_representation("3D_feature_2D_full")\n'
100
+ cmd += "ensight.data.replace(path)\n"
101
+ return cmd
102
+
103
+ def _find_dvs_port(self, tmp_name: Optional[str] = None):
104
+ """Find the dvs port allocated from the input temporary name"""
105
+ if not tmp_name:
106
+ raise RuntimeError("Temporary name for dvs port file not available")
107
+ is_local = isinstance(self._ensight._session._launcher, LocalLauncher)
108
+ if is_local:
109
+ with open(tmp_name) as dvs_port_file:
110
+ self._dvs_port = int(dvs_port_file.read().strip())
111
+ else:
112
+ log_content = self._ensight._session._launcher.enshell_log_contents()
113
+ dvs_port_match = re.search(r"\(0.0.0.0\):([0-9]{4,5})\n", log_content)
114
+ if dvs_port_match:
115
+ self._dvs_port = int(str(dvs_port_match.groups(1)[0]).strip())
116
+
117
+ @staticmethod
118
+ def _launch_dvs_callback_in_ensight(
119
+ port: int,
120
+ filename: Optional[str],
121
+ secret_key: Optional[str],
122
+ monitor_new_timesteps: str = MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT,
123
+ ) -> None: # pragma: no cover
124
+ """Launch a live DVS session in EnSight"""
125
+ from ceiversion import ensight_suffix # pylint: disable=import-outside-toplevel
126
+
127
+ if int(ensight_suffix) < 242:
128
+ from cei import find_unused_ports # pylint: disable=import-outside-toplevel
129
+
130
+ if port == 0:
131
+ ports = find_unused_ports(1)
132
+ if ports:
133
+ port = ports[0]
134
+ try:
135
+ os.remove("remote.dvs")
136
+ except (FileNotFoundError, OSError):
137
+ pass
138
+ path = os.path.join(os.getcwd(), "remote.dvs")
139
+ with open(path, "w") as dvsfile:
140
+ dvsfile.write("#!DVS_CASE 1.0\n")
141
+ dvsfile.write(f"SERVER_PORT_BASE={port}\n")
142
+ dvsfile.write("SERVER_PORT_MULT=1\n")
143
+ if secret_key is not None:
144
+ dvsfile.write(f"SERVER_SECURITY_SECRET={secret_key}\n")
145
+ if filename:
146
+ try:
147
+ with open(filename, "w") as dvs_port_file:
148
+ dvs_port_file.write(str(port))
149
+ except Exception:
150
+ raise RuntimeError(f"Couldn't write allocated DVS port to {filename}")
151
+ ensight.part.elt_representation("3D_feature_2D_full")
152
+ ensight.solution_time.monitor_for_new_steps(f"{monitor_new_timesteps}")
153
+ ensight.data.replace(path)
154
+ else:
155
+
156
+ def dvs_callback():
157
+ command_string = f"set_server_port={port}"
158
+ if secret_key is not None:
159
+ command_string += f"&set_secret_key={secret_key}"
160
+ ensight.objs.core.CURRENTCASE[0].client_command(command_string)
161
+ dvs_port_string = ensight.objs.core.CURRENTCASE[0].client_command("get_server_port")
162
+ dvs_port_match = re.search(r":([0-9]{4,5})", dvs_port_string)
163
+ dvs_port = None
164
+ if dvs_port_match:
165
+ dvs_port = int(dvs_port_match.groups(1)[0])
166
+ if not dvs_port:
167
+ raise RuntimeError("DVS couldn't allocate a port")
168
+ if filename:
169
+ try:
170
+ with open(filename, "w") as dvs_port_file:
171
+ dvs_port_file.write(str(dvs_port))
172
+ except Exception:
173
+ raise RuntimeError(f"Couldn't write allocated DVS port to {filename}")
174
+ return True
175
+
176
+ ensight.objs.core.CURRENTCASE[0].client_command_callback(dvs_callback)
177
+ ensight.solution_time.monitor_for_new_steps(f"{monitor_new_timesteps}")
178
+ ensight.part.elt_representation("3D_feature_2D_full")
179
+ ensight.data.replace("notexisting.dvs")
180
+
181
+ def launch_live_dvs(
182
+ self,
183
+ port: int = 0,
184
+ secret_key: Optional[str] = None,
185
+ monitor_new_timesteps: str = MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT,
186
+ start_thread: bool = True,
187
+ filename: Optional[str] = None,
188
+ ) -> Tuple[Optional[Thread], Optional[int]]:
189
+ """To provide an interface to launch an in-situ EnSight DVS session.
190
+ If in PyEnSight, the function will return a thread which will launch the DVS reader
191
+ in EnSight, hence the DVS servers, and will also return the port allocated by DVS, to
192
+ cover the case the port 0 was asked for.
193
+ If instead the function will be used directly in EnSight via the utils interface, since
194
+ the reader launch will block the interpreter waiting for new data, the port cannot be returned
195
+ and cannot be printed up until the first update happens.
196
+ So, if you need to access the port number in a script and you cannot check the EnSight console,
197
+ please supply a filename to store the dvs port into.
198
+
199
+ Parameters
200
+ ----------
201
+ port: int
202
+ the port number where the first DVS server will be started. In case of a
203
+ SOS EnSight session, on the following server the DVS servers will be started on the
204
+ next port, e.g. if the first server starts at port 50055, the second will start
205
+ at port 50056 and so on
206
+ secret_key: str
207
+ an optional secret key to pass in case the DVS clients have been started with a secret key
208
+ for the underlying gRPC connections. An empty string can be provided if needed
209
+ monitor_new_timesteps: str
210
+ set the way EnSight will monitor for new timesteps. Defaults to MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT.
211
+ The allowed values are MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT
212
+ and MONITOR_NEW_TIMESTEPS_JUMP_TO_END
213
+ start_thread: bool
214
+ True if the thread to be returned needs to be started already. Default is True
215
+ filename: str
216
+ An optional path to store the port number in. It will be used only if the utils is being
217
+ called directly in EnSight.
218
+
219
+ Returns
220
+ -------
221
+ Thread:
222
+ a python Thread which holds the dvs load
223
+ """
224
+
225
+ def load_dvs():
226
+ self._ensight._session.cmd(cmd, do_eval=False)
227
+
228
+ if monitor_new_timesteps not in [
229
+ self.MONITOR_NEW_TIMESTEPS_JUMP_TO_END,
230
+ self.MONITOR_NEW_TIMESTEPS_STAY_AT_CURRENT,
231
+ ]:
232
+ raise RuntimeError(
233
+ f"{monitor_new_timesteps} value not allowed for an in-situ DVS session"
234
+ )
235
+ if not isinstance(self._ensight, ModuleType): # pragma: no cover
236
+ self._ensight._session.ensight_version_check("2024 R1")
237
+ else:
238
+ self._launch_dvs_callback_in_ensight(
239
+ port=port,
240
+ secret_key=secret_key,
241
+ monitor_new_timesteps=monitor_new_timesteps,
242
+ filename=filename,
243
+ )
244
+ return None, None
245
+ cmd = ""
246
+ path = None
247
+ if int(self._ensight._session.cei_suffix) < 242:
248
+ cmd = self._launch_live_dvs_241_cmd(
249
+ port=port, secret_key=secret_key, monitor_new_timesteps=monitor_new_timesteps
250
+ )
251
+ else:
252
+ tmp_name = str(uuid.uuid4())
253
+ path = os.path.join(self._ensight._session._launcher.session_directory, tmp_name)
254
+ cmd = self._launch_live_dvs_242_cmd(
255
+ port=port,
256
+ secret_key=secret_key,
257
+ monitor_new_timesteps=monitor_new_timesteps,
258
+ tmp_name=path,
259
+ )
260
+ t = Thread(target=load_dvs)
261
+ if start_thread:
262
+ t.start()
263
+ start = time.time()
264
+ while not self._dvs_port and time.time() - start < 60:
265
+ try:
266
+ self._find_dvs_port(path)
267
+ except Exception:
268
+ pass
269
+ time.sleep(0.5)
270
+ return t, self._dvs_port
@@ -486,24 +486,18 @@ class Variables:
486
486
  #
487
487
  #
488
488
  temp_string = "ENS_Force_Net_Tan_ShearForce_X = StatMoment(plist,ENS_Force_Tan_ShearForce_X, 0, Compute_Per_part)"
489
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
490
- err_string = "Error, failed to calculate a variable in {}".format(
491
- fcn_name
492
- ) # pragma: no cover
489
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
490
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
493
491
  raise RuntimeError(err_string) # pragma: no cover
494
492
 
495
493
  temp_string = "ENS_Force_Net_Tan_ShearForce_Y = StatMoment(plist,ENS_Force_Tan_ShearForce_Y, 0, Compute_Per_part)"
496
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
497
- err_string = "Error, failed to calculate a variable in {}".format(
498
- fcn_name
499
- ) # pragma: no cover
494
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
495
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
500
496
  raise RuntimeError(err_string) # pragma: no cover
501
497
 
502
498
  temp_string = "ENS_Force_Net_Tan_ShearForce_Z = StatMoment(plist,ENS_Force_Tan_ShearForce_Z, 0, Compute_Per_part)"
503
499
  if not self._calc_var(pobj_list, temp_string): # pragma: no cover
504
- err_string = "Error, failed to calculate a variable in {}".format(
505
- fcn_name
506
- ) # pragma: no cover
500
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
507
501
  raise RuntimeError(err_string) # pragma: no cover
508
502
  #
509
503
  # get the 3 constant force values XYZ
@@ -520,7 +514,7 @@ class Variables:
520
514
  if val:
521
515
  if isinstance(val, list):
522
516
  for v in val:
523
- if not v: # pragma: no cover
517
+ if v is None: # pragma: no cover
524
518
  return None # pragma: no cover
525
519
  Fx.append(v)
526
520
  else:
@@ -531,7 +525,7 @@ class Variables:
531
525
  if val:
532
526
  if isinstance(val, list):
533
527
  for v in val:
534
- if not v: # pragma: no cover
528
+ if v is None: # pragma: no cover
535
529
  return None # pragma: no cover
536
530
  Fy.append(v)
537
531
  else:
@@ -542,7 +536,7 @@ class Variables:
542
536
  if val:
543
537
  if isinstance(val, list):
544
538
  for v in val:
545
- if not v: # pragma: no cover
539
+ if v is None: # pragma: no cover
546
540
  return None # pragma: no cover
547
541
  Fz.append(v)
548
542
  else:
@@ -553,69 +547,51 @@ class Variables:
553
547
  # they are calc'd to give the user the totals.
554
548
  #
555
549
  temp_string = "ENS_Force_Total_Net_Tan_ShearForce_X = StatMoment(plist,ENS_Force_Tan_ShearForce_X, 0, Compute_Per_case)"
556
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
557
- err_string = "Error, failed to calculate a variable in {}".format(
558
- fcn_name
559
- ) # pragma: no cover
550
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
551
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
560
552
  raise RuntimeError(err_string) # pragma: no cover
561
553
 
562
554
  temp_string = "ENS_Force_Total_Net_Tan_ShearForce_Y = StatMoment(plist,ENS_Force_Tan_ShearForce_Y, 0, Compute_Per_case)"
563
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
564
- err_string = "Error, failed to calculate a variable in {}".format(
565
- fcn_name
566
- ) # pragma: no cover
555
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
556
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
567
557
  raise RuntimeError(err_string) # pragma: no cover
568
558
 
569
559
  temp_string = "ENS_Force_Total_Net_Tan_ShearForce_Z = StatMoment(plist,ENS_Force_Tan_ShearForce_Z, 0, Compute_Per_case)"
570
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
571
- err_string = "Error, failed to calculate a variable in {}".format(
572
- fcn_name
573
- ) # pragma: no cover
560
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
561
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
574
562
  raise RuntimeError(err_string) # pragma: no cover
575
563
 
576
564
  if frame_index > 0 and frame_index < len(self.ensight.objs.core.FRAMES):
577
565
  temp_string = "ENS_Force_Net_Tan_ShearForce_R = StatMoment(plist,ENS_Force_Tan_ShearForce_R,0, Compute_Per_part)"
578
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
579
- err_string = "Error, failed to calculate a variable in {}".format(
580
- fcn_name
581
- ) # pragma: no cover
566
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
567
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
582
568
  raise RuntimeError(err_string) # pragma: no cover
583
569
 
584
570
  temp_string = "ENS_Force_Net_Tan_ShearForce_T = StatMoment(plist,ENS_Force_Tan_ShearForce_T,0, Compute_Per_part)"
585
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
586
- err_string = "Error, failed to calculate a variable in {}".format(
587
- fcn_name
588
- ) # pragma: no cover
571
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
572
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
589
573
  raise RuntimeError(err_string) # pragma: no cover
590
574
 
591
575
  temp_string = "ENS_Force_Net_Tan_ShearForce_A = StatMoment(plist,ENS_Force_Tan_ShearForce_A,0, Compute_Per_part)"
592
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
593
- err_string = "Error, failed to calculate a variable in {}".format(
594
- fcn_name
595
- ) # pragma: no cover
576
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
577
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
596
578
  raise RuntimeError(err_string) # pragma: no cover
597
579
  #
598
580
  # Totals
599
581
  #
600
582
  temp_string = "ENS_Force_Total_Net_Tan_ShearForce_R = StatMoment(plist,ENS_Force_Tan_ShearForce_R,0, Compute_Per_case)"
601
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
602
- err_string = "Error, failed to calculate a variable in {}".format(
603
- fcn_name
604
- ) # pragma: no cover
583
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
584
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
605
585
  raise RuntimeError(err_string) # pragma: no cover
606
586
 
607
587
  temp_string = "ENS_Force_Total_Net_Tan_ShearForce_T = StatMoment(plist,ENS_Force_Tan_ShearForce_T,0, Compute_Per_case)"
608
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
609
- err_string = "Error, failed to calculate a variable in {}".format(
610
- fcn_name
611
- ) # pragma: no cover
588
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
589
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
612
590
  raise RuntimeError(err_string) # pragma: no cover
613
591
 
614
592
  temp_string = "ENS_Force_Total_Net_Tan_ShearForce_A = StatMoment(plist,ENS_Force_Tan_ShearForce_A,0, Compute_Per_case)"
615
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
616
- err_string = "Error, failed to calculate a variable in {}".format(
617
- fcn_name
618
- ) # pragma: no cover
593
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
594
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
619
595
  raise RuntimeError(err_string) # pragma: no cover
620
596
  #
621
597
  # get the 3 constant force values Radial, Theta, Axial
@@ -633,7 +609,7 @@ class Variables:
633
609
  if val:
634
610
  if isinstance(val, list):
635
611
  for v in val:
636
- if not v: # pragma: no cover
612
+ if v is None: # pragma: no cover
637
613
  return None # pragma: no cover
638
614
  Fr.append(v)
639
615
  else:
@@ -644,7 +620,7 @@ class Variables:
644
620
  if val:
645
621
  if isinstance(val, list):
646
622
  for v in val:
647
- if not v: # pragma: no cover
623
+ if v is None: # pragma: no cover
648
624
  return None # pragma: no cover
649
625
  Ft.append(v)
650
626
  else:
@@ -655,7 +631,7 @@ class Variables:
655
631
  if val:
656
632
  if isinstance(val, list):
657
633
  for v in val:
658
- if not v: # pragma: no cover
634
+ if v is None: # pragma: no cover
659
635
  return None # pragma: no cover
660
636
  Fa.append(v)
661
637
  else:
@@ -1027,6 +1003,7 @@ class Variables:
1027
1003
  #
1028
1004
  # Select the part(s) in the list
1029
1005
  # ensight.variables.evaluate("ENS_Force_Net_press_Y = StatMoment(plist,pressure,0,Compute_Per_part)")
1006
+ fcn_name = "sum_press_forces_xyz_rtz"
1030
1007
  self.ensight.utils.parts.select_parts(pobj_list)
1031
1008
  #
1032
1009
  # Calculate the net force X, Y, and Z , 10.2.0(d) now per part constant variable
@@ -1034,20 +1011,23 @@ class Variables:
1034
1011
  force_calc_string = "ENS_Force_Net_press_X = StatMoment"
1035
1012
  calc_string = "(plist," + "ENS_Force_press_X , 0, Compute_Per_part )"
1036
1013
  temp_string = force_calc_string + calc_string
1037
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1038
- return None # pragma: no cover
1014
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1015
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1016
+ raise RuntimeError(err_string) # pragma: no cover
1039
1017
  #
1040
1018
  force_calc_string = "ENS_Force_Net_press_Y = StatMoment"
1041
1019
  calc_string = "(plist," + "ENS_Force_press_Y , 0, Compute_Per_part )"
1042
1020
  temp_string = force_calc_string + calc_string
1043
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1044
- return None # pragma: no cover
1021
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1022
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1023
+ raise RuntimeError(err_string) # pragma: no cover
1045
1024
  #
1046
1025
  force_calc_string = "ENS_Force_Net_press_Z = StatMoment"
1047
1026
  calc_string = "(plist," + "ENS_Force_press_Z , 0, Compute_Per_part )"
1048
1027
  temp_string = force_calc_string + calc_string
1049
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1050
- return None # pragma: no cover
1028
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1029
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1030
+ raise RuntimeError(err_string) # pragma: no cover
1051
1031
  #
1052
1032
  # Calculate the Total force X, Y, and Z , 10.2.0(d) now case constant variable
1053
1033
  # Totals are a case constants. We don't do anything with these vars
@@ -1056,20 +1036,23 @@ class Variables:
1056
1036
  force_calc_string = "ENS_Force_Total_Net_press_X = StatMoment"
1057
1037
  calc_string = "(plist," + "ENS_Force_press_X , 0, Compute_Per_case )"
1058
1038
  temp_string = force_calc_string + calc_string
1059
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1060
- return None # pragma: no cover
1039
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1040
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1041
+ raise RuntimeError(err_string) # pragma: no cover
1061
1042
  #
1062
1043
  force_calc_string = "ENS_Force_Total_Net_press_Y = StatMoment"
1063
1044
  calc_string = "(plist," + "ENS_Force_press_Y , 0, Compute_Per_case )"
1064
1045
  temp_string = force_calc_string + calc_string
1065
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1066
- return None # pragma: no cover
1046
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1047
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1048
+ raise RuntimeError(err_string) # pragma: no cover
1067
1049
  #
1068
1050
  force_calc_string = "ENS_Force_Total_Net_press_Z = StatMoment"
1069
1051
  calc_string = "(plist," + "ENS_Force_press_Z , 0, Compute_Per_case )"
1070
1052
  temp_string = force_calc_string + calc_string
1071
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1072
- return None # pragma: no cover
1053
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1054
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1055
+ raise RuntimeError(err_string) # pragma: no cover
1073
1056
  #
1074
1057
  # get a list with a per part force, one for each part, new 10.1.6(b)
1075
1058
  #
@@ -1083,7 +1066,7 @@ class Variables:
1083
1066
  if val:
1084
1067
  if isinstance(val, list):
1085
1068
  for v in val:
1086
- if not v: # pragma: no cover
1069
+ if v is None: # pragma: no cover
1087
1070
  return None # pragma: no cover
1088
1071
  Fx.append(v)
1089
1072
  else:
@@ -1094,7 +1077,7 @@ class Variables:
1094
1077
  if val:
1095
1078
  if isinstance(val, list):
1096
1079
  for v in val:
1097
- if not v: # pragma: no cover
1080
+ if v is None: # pragma: no cover
1098
1081
  return None # pragma: no cover
1099
1082
  Fy.append(v)
1100
1083
  else:
@@ -1105,7 +1088,7 @@ class Variables:
1105
1088
  if val:
1106
1089
  if isinstance(val, list):
1107
1090
  for v in val:
1108
- if not v: # pragma: no cover
1091
+ if v is None: # pragma: no cover
1109
1092
  return None # pragma: no cover
1110
1093
  Fz.append(v)
1111
1094
  else:
@@ -1125,20 +1108,23 @@ class Variables:
1125
1108
  force_calc_string = "ENS_Force_Net_press_R = StatMoment"
1126
1109
  calc_string = "(plist," + "ENS_Force_press_R, 0, Compute_Per_part )"
1127
1110
  temp_string = force_calc_string + calc_string
1128
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1129
- return None # pragma: no cover
1111
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1112
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1113
+ raise RuntimeError(err_string) # pragma: no cover
1130
1114
  #
1131
1115
  force_calc_string = "ENS_Force_Net_press_T = StatMoment"
1132
1116
  calc_string = "(plist," + "ENS_Force_press_T, 0, Compute_Per_part )"
1133
1117
  temp_string = force_calc_string + calc_string
1134
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1135
- return None # pragma: no cover
1118
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1119
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1120
+ raise RuntimeError(err_string) # pragma: no cover
1136
1121
  #
1137
1122
  force_calc_string = "ENS_Force_Net_press_A = StatMoment"
1138
1123
  calc_string = "(plist," + "ENS_Force_press_A, 0, Compute_Per_part )"
1139
1124
  temp_string = force_calc_string + calc_string
1140
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1141
- return None # pragma: no cover
1125
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1126
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1127
+ raise RuntimeError(err_string) # pragma: no cover
1142
1128
  #
1143
1129
  # Totals are a case constants. We don't do anything with these vars
1144
1130
  # they are calc'd to give the user the totals.
@@ -1146,20 +1132,23 @@ class Variables:
1146
1132
  force_calc_string = "ENS_Force_Total_Net_press_R = StatMoment"
1147
1133
  calc_string = "(plist," + "ENS_Force_press_R, 0, Compute_Per_case )"
1148
1134
  temp_string = force_calc_string + calc_string
1149
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1150
- return None # pragma: no cover
1135
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1136
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1137
+ raise RuntimeError(err_string) # pragma: no cover
1151
1138
  #
1152
1139
  force_calc_string = "ENS_Force_Total_Net_press_T = StatMoment"
1153
1140
  calc_string = "(plist," + "ENS_Force_press_T, 0, Compute_Per_case )"
1154
1141
  temp_string = force_calc_string + calc_string
1155
- if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1156
- return None # pragma: no cover
1142
+ if self._calc_var(pobj_list, temp_string) is False: # pragma: no cover
1143
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1144
+ raise RuntimeError(err_string) # pragma: no cover
1157
1145
  #
1158
1146
  force_calc_string = "ENS_Force_Total_Net_press_A = StatMoment"
1159
1147
  calc_string = "(plist," + "ENS_Force_press_A, 0, Compute_Per_case )"
1160
1148
  temp_string = force_calc_string + calc_string
1161
1149
  if not self._calc_var(pobj_list, temp_string): # pragma: no cover
1162
- return None # pragma: no cover
1150
+ err_string = f"Error, failed to calculate {temp_string} in {fcn_name}" # pragma: no cover # pragma: no cover # pragma: no cover
1151
+ raise RuntimeError(err_string) # pragma: no cover
1163
1152
  #
1164
1153
  # get a list with a per part force, one for each part, new 10.1.6(b)
1165
1154
  #
@@ -1172,7 +1161,7 @@ class Variables:
1172
1161
  if val:
1173
1162
  if isinstance(val, list):
1174
1163
  for v in val:
1175
- if not v: # pragma: no cover
1164
+ if v is None: # pragma: no cover
1176
1165
  return None # pragma: no cover
1177
1166
  Fr.append(v)
1178
1167
  else:
@@ -1183,7 +1172,7 @@ class Variables:
1183
1172
  if val:
1184
1173
  if isinstance(val, list):
1185
1174
  for v in val:
1186
- if not v: # pragma: no cover
1175
+ if v is None: # pragma: no cover
1187
1176
  return None # pragma: no cover
1188
1177
  Ft.append(v)
1189
1178
  else:
@@ -1194,7 +1183,7 @@ class Variables:
1194
1183
  if val:
1195
1184
  if isinstance(val, list):
1196
1185
  for v in val:
1197
- if not v: # pragma: no cover
1186
+ if v is None: # pragma: no cover
1198
1187
  return None # pragma: no cover
1199
1188
  Fa.append(v)
1200
1189
  else: