ansys-pyensight-core 0.7.0__py3-none-any.whl → 0.7.2__py3-none-any.whl

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.

@@ -5,10 +5,9 @@ Emulation of the EnSight ensobjlist class
5
5
  """
6
6
  from collections.abc import Iterable
7
7
  import fnmatch
8
- from typing import Any, List, Optional, TypeVar, no_type_check, overload
8
+ from typing import Any, List, Optional, SupportsIndex, TypeVar, no_type_check, overload
9
9
 
10
10
  from ansys.pyensight.core.ensobj import ENSOBJ
11
- from typing_extensions import SupportsIndex
12
11
 
13
12
  T = TypeVar("T")
14
13
 
@@ -525,15 +525,11 @@ class RenderableWebGL(Renderable):
525
525
 
526
526
 
527
527
  class RenderableVNC(Renderable):
528
- """Generates a URL that can be used to connect to the EnSight VNC remote image renderer."""
528
+ """Generates an ansys-nexus-viewer component that can be used to connect to the EnSight VNC remote image renderer."""
529
529
 
530
530
  def __init__(self, *args, **kwargs) -> None:
531
531
  super().__init__(*args, **kwargs)
532
- self._query_params = {
533
- "autoconnect": "true",
534
- "host": self._session.html_hostname,
535
- "port": self._session.ws_port,
536
- }
532
+ self._generate_url()
537
533
  self._rendertype = "remote"
538
534
  self.update()
539
535
 
@@ -544,10 +540,31 @@ class RenderableVNC(Renderable):
544
540
  iframe reference.
545
541
 
546
542
  """
547
- url = f"{self._http_protocol}://{self._session.html_hostname}:{self._session.html_port}"
548
- url += "/ansys/nexus/novnc/vnc_envision.html"
549
- url += self._get_query_parameters_str(self._query_params)
550
- self._url = url
543
+ optional_query = self._get_query_parameters_str()
544
+
545
+ html = f"<script src='/ansys/nexus/viewer-loader.js{optional_query}'></script>\n"
546
+ rest_uri = (
547
+ f"{self._http_protocol}://{self._session.html_hostname}:{self._session.html_port}"
548
+ )
549
+ ws_uri = f"{self._http_protocol}://{self._session.html_hostname}:{self._session.ws_port}"
550
+
551
+ query_args = ""
552
+ if self._using_proxy and optional_query:
553
+ query_args = f', "extra_query_args":"{optional_query[1:]}"'
554
+
555
+ attributes = ' renderer="envnc"'
556
+ attributes += ' ui="simple"'
557
+ attributes += ' active="true"'
558
+ attributes += (
559
+ " renderer_options='"
560
+ + f'{{ "ws":"{ws_uri}", "http":"{rest_uri}", "security_token":"{self._session.secret_key}", "connect_to_running_ens":true {query_args} }}'
561
+ + "'"
562
+ )
563
+
564
+ html += f"<ansys-nexus-viewer {attributes}></ansys-nexus-viewer>\n"
565
+
566
+ # refresh the remote HTML
567
+ self._save_remote_html_page(html)
551
568
  super().update()
552
569
 
553
570
 
@@ -1510,6 +1510,13 @@ class Session:
1510
1510
  tail = s.find(", cached:yes")
1511
1511
  if tail == -1:
1512
1512
  break
1513
+ # Subtype (PartType:, AnnotType:, ToolType:)
1514
+ subtype = None
1515
+ for name in ("PartType:", "AnnotType:", "ToolType:"):
1516
+ location = s.find(name)
1517
+ if (location != -1) and (location > id):
1518
+ subtype = int(s[location + len(name) :].split(",")[0])
1519
+ break
1513
1520
  # isolate the block to replace
1514
1521
  prefix = s[:start]
1515
1522
  suffix = s[tail + tail_len :]
@@ -1526,8 +1533,11 @@ class Session:
1526
1533
  else:
1527
1534
  subclass_info = ""
1528
1535
  if attr_id is not None:
1529
- # if a "subclass" case and no subclass attrid value, ask for it...
1530
- if classname_lookup is not None:
1536
+ if subtype is not None:
1537
+ # the 2024 R2 interface includes the subtype
1538
+ subclass_info = f",attr_id={attr_id}, attr_value={subtype}"
1539
+ elif classname_lookup is not None:
1540
+ # if a "subclass" case and no subclass attrid value, ask for it...
1531
1541
  remote_name = self.remote_obj(objid)
1532
1542
  cmd = f"{remote_name}.getattr({attr_id})"
1533
1543
  attr_value = self.cmd(cmd)
@@ -15,26 +15,132 @@ Example for selecting all 3D parts:
15
15
  >>> parts.select_by_dimension(3)
16
16
 
17
17
  """
18
-
19
- from typing import TYPE_CHECKING, Dict, Optional, Union
18
+ from types import ModuleType
19
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
20
20
 
21
21
  try:
22
22
  import ensight
23
- from ensight.objs import ensobjlist # type: ignore
23
+ from ensight.objs import ens_emitterobj, ensobjlist # type: ignore
24
24
  except ImportError:
25
+ from ansys.api.pyensight.ens_emitterobj import ens_emitterobj
25
26
  from ansys.pyensight.core.listobj import ensobjlist
26
27
 
27
28
  if TYPE_CHECKING:
28
29
  try:
29
- from ensight.objs import ENS_PART # type: ignore
30
+ from ensight.objs import ENS_PART, ENS_VAR # type: ignore
30
31
  except ImportError:
31
32
  from ansys.api.pyensight import ensight_api
32
33
  from ansys.api.pyensight.ens_part import ENS_PART
34
+ from ansys.api.pyensight.ens_var import ENS_VAR
35
+
36
+
37
+ def convert_part(
38
+ _ensight: Union["ensight_api.ensight", "ensight"], part: Union[str, int, "ENS_PART"]
39
+ ):
40
+ if isinstance(part, str):
41
+ return _ensight.objs.core.PARTS[part][0].PARTNUMBER
42
+ elif isinstance(part, int):
43
+ return part
44
+ elif hasattr(part, "PARTNUMBER"):
45
+ return part.PARTNUMBER
46
+
47
+
48
+ def convert_variable(
49
+ _ensight: Union["ensight_api.ensight", "ensight"], var: Union[str, int, "ENS_VAR"]
50
+ ):
51
+ if isinstance(var, str):
52
+ return _ensight.objs.core.VARIABLES[var][0].ID
53
+ elif isinstance(var, int):
54
+ return var
55
+ elif hasattr(var, "ID"):
56
+ return var.ID
33
57
 
34
58
 
35
59
  class Parts:
36
60
  """Controls the parts in the current EnSight ``Session`` instance."""
37
61
 
62
+ class _EnSEmitterPoint(ens_emitterobj):
63
+ def __init__(
64
+ self,
65
+ ensight: "ensight",
66
+ point1: Optional[List[float]] = [0, 0, 0],
67
+ ):
68
+ if not isinstance(ensight, ModuleType):
69
+ raise RuntimeError(
70
+ "The class cannot be used directly in PyEnSight. It should not be used directly even in EnSight"
71
+ )
72
+ super().__init__(ensight.objs.EMIT_CURSOR)
73
+ self.ensight = ensight
74
+ self.ensight.view_transf.cursor(*point1)
75
+ self.CENTROID = point1
76
+
77
+ class _EnSEmitterGrid(ens_emitterobj):
78
+ def __init__(
79
+ self,
80
+ ensight: "ensight",
81
+ point1: Optional[List[float]] = [0, 0, 0],
82
+ point2: Optional[List[float]] = [0, 0, 0],
83
+ point3: Optional[List[float]] = [0, 0, 0],
84
+ point4: Optional[List[float]] = [0, 0, 0],
85
+ num_points_x: Optional[int] = 25,
86
+ num_points_y: Optional[int] = 25,
87
+ ):
88
+ if not isinstance(ensight, ModuleType):
89
+ raise RuntimeError(
90
+ "The class cannot be used directly in PyEnSight. It should not be used directly even in EnSight"
91
+ )
92
+ super().__init__(ensight.objs.EMIT_PLANE)
93
+ self.ensight = ensight
94
+ self.ensight.view_transf.plane(1, *point1)
95
+ self.ensight.view_transf.plane(2, *point2)
96
+ self.ensight.view_transf.plane(3, *point3)
97
+ self.POINT1 = point1
98
+ self.POINT2 = point2
99
+ self.POINT3 = point3
100
+ self.POINT4 = point4
101
+ self.NUM_POINTS_X = num_points_x
102
+ self.NUM_POINTS_Y = num_points_y
103
+
104
+ class _EnSEmitterLine(ens_emitterobj):
105
+ def __init__(
106
+ self,
107
+ ensight: "ensight",
108
+ point1: Optional[List[float]] = [0, 0, 0],
109
+ point2: Optional[List[float]] = [0, 0, 0],
110
+ num_points: Optional[int] = 100,
111
+ ):
112
+ if not isinstance(ensight, ModuleType):
113
+ raise RuntimeError(
114
+ "The class cannot be used directly in PyEnSight. It should not be used directly even in EnSight"
115
+ )
116
+ super().__init__(ensight.objs.EMIT_LINE)
117
+ self.ensight = ensight
118
+ self.ensight.view_transf.line(1, *point1)
119
+ self.ensight.view_transf.line(2, *point2)
120
+ self.POINT1 = point1
121
+ self.POINT2 = point2
122
+ self.NUM_POINTS = num_points
123
+
124
+ class _EnSEmitterPart(ens_emitterobj):
125
+ def __init__(
126
+ self,
127
+ ensight: "ensight",
128
+ part: Optional[Any] = None,
129
+ part_kind: Optional[Any] = 0,
130
+ num_points: Optional[int] = 100,
131
+ ):
132
+ if not isinstance(ensight, ModuleType):
133
+ raise RuntimeError(
134
+ "The class cannot be used directly in PyEnSight. It should not be used directly even in EnSight"
135
+ )
136
+ super().__init__(ensight.objs.EMIT_PART)
137
+ self.ensight = ensight
138
+ if not part:
139
+ raise RuntimeError("part is a required input")
140
+ self.PART = convert_part(self.ensight, part)
141
+ self.NUM_POINTS = num_points
142
+ self.DISTRIB_TYPE = part_kind
143
+
38
144
  def __init__(self, ensight: Union["ensight_api.ensight", "ensight"]):
39
145
  self.ensight = ensight
40
146
 
@@ -122,3 +228,673 @@ class Parts:
122
228
  if found:
123
229
  found.set_attr("SELECTED", True)
124
230
  return found
231
+
232
+ _EMIT_POINT: int = 0
233
+ _EMIT_LINE: int = 1
234
+ _EMIT_PLANE: int = 2
235
+ _EMIT_PART: int = 3
236
+ PT_POS_TIME: str = "+"
237
+ PT_NEG_TIME: str = "-"
238
+ PT_POS_NEG_TIME: str = "+/-"
239
+ PART_EMIT_FROM_NODES: int = 0
240
+ PART_EMIT_FROM_AREA: int = 1
241
+
242
+ def _create_emitters(
243
+ self,
244
+ emitter_type: int,
245
+ points: Optional[List[List[float]]] = None,
246
+ point1: Optional[List[float]] = None,
247
+ point2: Optional[List[float]] = None,
248
+ point3: Optional[List[float]] = None,
249
+ parts: Optional[List["ENS_PART"]] = None,
250
+ part_distribution_type: Optional[int] = 0,
251
+ num_points: Optional[int] = 100,
252
+ num_points_x: Optional[int] = 25,
253
+ num_points_y: Optional[int] = 25,
254
+ ) -> List[Any]:
255
+ """Private routine to create emitter objects"""
256
+ new_emitters: List[Any] = []
257
+ if emitter_type == self._EMIT_POINT:
258
+ if not points:
259
+ raise RuntimeError("list of points needed if particle trace emitted from points")
260
+ for p in points:
261
+ if isinstance(self.ensight, ModuleType):
262
+ new_emitters.append(self._EnSEmitterPoint(self.ensight, point1=p))
263
+ else:
264
+ new_emitters.append(
265
+ f"ensight.utils.parts._EnSEmitterPoint(ensight, point1={p})"
266
+ )
267
+ elif emitter_type == self._EMIT_LINE:
268
+ if not any([point1, point2]):
269
+ raise RuntimeError("point1 and point2 needed if particle trace emitted from line")
270
+ if isinstance(self.ensight, ModuleType):
271
+ new_emitters.append(
272
+ self._EnSEmitterLine(
273
+ self.ensight, point1=point1, point2=point2, num_points=num_points
274
+ )
275
+ )
276
+ else:
277
+ new_emitters.append(
278
+ f"ensight.utils.parts._EnSEmitterLine(ensight, point1={point1}, point2={point2}, num_points={num_points})"
279
+ )
280
+ elif emitter_type == self._EMIT_PLANE:
281
+ if not any([point1, point2, point3]):
282
+ raise RuntimeError(
283
+ "point1, point2 and point3 needed if particle trace emitted from plane"
284
+ )
285
+ if isinstance(self.ensight, ModuleType):
286
+ new_emitters.append(
287
+ self._EnSEmitterGrid(
288
+ self.ensight,
289
+ point1=point1,
290
+ point2=point2,
291
+ point3=point3,
292
+ num_points_x=num_points_x,
293
+ num_points_y=num_points_y,
294
+ )
295
+ )
296
+ else:
297
+ new_emitters.append(
298
+ f"ensight.utils.parts._EnSEmitterGrid(ensight, point1={point1}, point2={point2}, point3={point3}, num_points_x={num_points_x}, num_points_y={num_points_y})"
299
+ )
300
+ elif emitter_type == self._EMIT_PART:
301
+ if not parts:
302
+ raise RuntimeError("part and num_points needed if particle trace emitted from part")
303
+ for p in parts:
304
+ if isinstance(self.ensight, ModuleType):
305
+ new_emitters.append(
306
+ self._EnSEmitterPart(
307
+ self.ensight,
308
+ part=p,
309
+ num_points=num_points,
310
+ part_kind=part_distribution_type,
311
+ )
312
+ )
313
+ else:
314
+ new_emitters.append(
315
+ f"ensight.utils.parts._EnSEmitterPart(ensight, part={convert_part(self.ensight ,p)}, num_points={num_points}, part_kind={part_distribution_type})"
316
+ )
317
+ else:
318
+ raise RuntimeError("No input provided to create the emitters for the particle trace")
319
+ return new_emitters
320
+
321
+ def _create_pathline_part(
322
+ self,
323
+ name: str,
324
+ variable: Union[str, int, "ENS_VAR"],
325
+ direction: str,
326
+ source_parts: List["ENS_PART"],
327
+ pathlines: Optional[bool] = False,
328
+ emit_time: Optional[float] = None,
329
+ total_time: Optional[float] = None,
330
+ delta_time: Optional[float] = None,
331
+ ) -> Tuple["ENS_PART", "ENS_PART"]:
332
+ """Private routine to create a pathline part object"""
333
+ direction_map = {
334
+ self.PT_POS_TIME: self.ensight.objs.enums.POS_TIME,
335
+ self.PT_NEG_TIME: self.ensight.objs.enums.NEG_TIME,
336
+ self.PT_POS_NEG_TIME: self.ensight.objs.enums.POS_NEG_TIME,
337
+ }
338
+ idx = self.ensight.objs.enums.PART_PARTICLE_TRACE
339
+ def_part = self.ensight.objs.core.DEFAULTPARTS[idx]
340
+ def_part.TYPE = self.ensight.objs.enums.STREAMLINE
341
+ if pathlines is True:
342
+ def_part.TYPE = self.ensight.objs.enums.PATHLINE
343
+ if total_time:
344
+ def_part.TOTALTIME = total_time
345
+ if delta_time:
346
+ def_part.DELTATIME = delta_time
347
+ if emit_time:
348
+ def_part.STARTTIME = emit_time
349
+ def_part.DESCRIPTION = name
350
+ def_part.VARIABLE = convert_variable(self.ensight, variable)
351
+ def_part.SURFACERESTRICTED = False
352
+ def_part.TRACEDIRECTION = direction_map.get(direction)
353
+ pathline_part = def_part.createpart(sources=source_parts, name=name)[0]
354
+ return pathline_part, def_part
355
+
356
+ def _add_emitters_to_pathline(
357
+ self, pathline_part: "ENS_PART", new_emitters: List[Any], palette: Optional[str] = None
358
+ ) -> "ENS_PART":
359
+ """Private utility to add emitters to an existing pathline part."""
360
+ if isinstance(self.ensight, ModuleType):
361
+ emitters = pathline_part.EMITTERS.copy()
362
+ emitters.extend(new_emitters)
363
+ pathline_part.EMITTERS = emitters
364
+ else:
365
+ self.ensight._session.cmd(
366
+ f"enscl.emitters=ensight.objs.wrap_id({pathline_part.objid}).EMITTERS.copy()",
367
+ do_eval=False,
368
+ )
369
+ text = "enscl.emitters.extend(["
370
+ for emitter in new_emitters:
371
+ text += emitter + ", "
372
+ text = text[:-2]
373
+ text += "])"
374
+ self.ensight._session.cmd(text, do_eval=False)
375
+ self.ensight._session.cmd(
376
+ f"ensight.objs.wrap_id({pathline_part.objid}).setattr('EMITTERS', enscl.emitters.copy())"
377
+ )
378
+ self.ensight._session.cmd("del enscl.emitters", do_eval=False)
379
+ if palette:
380
+ pathline_part.COLORBYPALETTE = palette
381
+ return pathline_part
382
+
383
+ def _cure_pathline_part(self, pathline_part: Union[str, int, "ENS_PART"]) -> "ENS_PART":
384
+ """Private utility to cure an input pathline part and convert it to an ``ENS_PART`"""
385
+ if isinstance(pathline_part, (str, int)):
386
+ temp = self.ensight.objs.core.PARTS[pathline_part]
387
+ if not temp:
388
+ raise RuntimeError("pathline_part input is not a valid part")
389
+ pathline_part = temp[0]
390
+ return pathline_part
391
+
392
+ def _prepare_particle_creation(
393
+ self,
394
+ direction: Optional[str] = None,
395
+ source_parts: Optional[List[Union[str, int, "ENS_PART"]]] = None,
396
+ ) -> Tuple[str, List["ENS_PART"]]:
397
+ """Private utility to set the direction if not provided, and to cure the list of source parts."""
398
+ if not direction:
399
+ direction = self.PT_POS_TIME
400
+ if source_parts:
401
+ converted_source_parts = [convert_part(self.ensight, p) for p in source_parts]
402
+ if not source_parts:
403
+ converted_source_parts = self.ensight.objs.core.selection(name="ENS_PART")
404
+ if not converted_source_parts:
405
+ raise RuntimeError("No part selected for particle trace generation")
406
+ return direction, converted_source_parts
407
+
408
+ def create_particle_trace_from_points(
409
+ self,
410
+ name: str,
411
+ variable: Union[str, int, "ENS_VAR"],
412
+ points: List[List[float]],
413
+ direction: Optional[str] = None,
414
+ pathlines: Optional[bool] = False,
415
+ source_parts: Optional[List[Union[str, int, "ENS_PART"]]] = None,
416
+ emit_time: Optional[float] = None,
417
+ total_time: Optional[float] = None,
418
+ delta_time: Optional[float] = None,
419
+ ) -> "ENS_PART":
420
+ """
421
+ Create a particle trace part from a list o points.
422
+ Returns the ``ENS_PART`` generated.
423
+
424
+ Parameters:
425
+ -----------
426
+
427
+ name: str
428
+ The name of part to be generated
429
+ variable:
430
+ The variable to compute the particle traces with.
431
+ It can be the name, the ID or the ``ENS_VAR`` object. It must be a vector variable.
432
+ direction: str
433
+ The direction for the particle traces to be generated.
434
+ This table describes the options:
435
+
436
+ ================== ==============================================
437
+ Name Query type
438
+ ================== ==============================================
439
+ PT_POS_TIME Follow the vector direction
440
+ PT_NEG_TIME Go contrary to the vector direction
441
+ PT_POS_NEG_TIME Follow and go contrary to the vector direction
442
+ ================== ==============================================
443
+
444
+ If not provided, it will default to ``PT_POS_TIME``
445
+ pathlines: bool
446
+ True if the particle traces need to be pathlines
447
+ points: list
448
+ List of coordinates for the seed points.
449
+ source_parts: list
450
+ A list of parts to create the particle trace in. For instance, in a CFD
451
+ simulation this might be the fluid zone.
452
+ If not provided, the function will try to look for the selected parts.
453
+ emit_time: float
454
+ The emission time to start the particle trace from. If not provided,
455
+ it will use the current time.
456
+ total_time: float
457
+ The total emission time. If not provided, EnSight will provide the end time
458
+ for a transient simulation, an internal best time for steady state simulations.
459
+ delta_time: float
460
+ The interval for the emissions. If not provided, EnSight will provide
461
+ a best estimate.
462
+ """
463
+ emitter_type = self._EMIT_POINT
464
+ direction, converted_source_parts = self._prepare_particle_creation(
465
+ direction=direction, source_parts=source_parts
466
+ )
467
+ pathline_part, def_part = self._create_pathline_part(
468
+ name,
469
+ variable,
470
+ direction,
471
+ converted_source_parts,
472
+ pathlines=pathlines,
473
+ emit_time=emit_time,
474
+ delta_time=delta_time,
475
+ total_time=total_time,
476
+ )
477
+ new_emitters = self._create_emitters(emitter_type=emitter_type, points=points)
478
+ return self._add_emitters_to_pathline(
479
+ pathline_part, new_emitters=new_emitters, palette=def_part.VARIABLE.DESCRIPTION
480
+ )
481
+
482
+ def create_particle_trace_from_line(
483
+ self,
484
+ name: str,
485
+ variable: Union[str, int, "ENS_VAR"],
486
+ point1: List[float],
487
+ point2: List[float],
488
+ num_points: Optional[int] = 100,
489
+ direction: Optional[str] = None,
490
+ pathlines: Optional[bool] = False,
491
+ source_parts: Optional[List[Union[str, int, "ENS_PART"]]] = None,
492
+ emit_time: Optional[float] = None,
493
+ total_time: Optional[float] = None,
494
+ delta_time: Optional[float] = None,
495
+ ) -> "ENS_PART":
496
+ """
497
+ Create a particle trace part from a line.
498
+ Returns the ``ENS_PART`` generated.
499
+
500
+ Parameters:
501
+ -----------
502
+
503
+ name: str
504
+ The name of part to be generated
505
+ variable:
506
+ The variable to compute the particle traces with.
507
+ It can be the name, the ID or the ``ENS_VAR`` object. It must be a vector variable.
508
+ direction: str
509
+ The direction for the particle traces to be generated.
510
+ This table describes the options:
511
+
512
+ ================== ==============================================
513
+ Name Query type
514
+ ================== ==============================================
515
+ PT_POS_TIME Follow the vector direction
516
+ PT_NEG_TIME Go contrary to the vector direction
517
+ PT_POS_NEG_TIME Follow and go contrary to the vector direction
518
+ ================== ==============================================
519
+
520
+ If not provided, it will default to ``PT_POS_TIME``
521
+ pathlines: bool
522
+ True if the particle traces need to be pathlines
523
+ point1: list
524
+ List of coordinates for point 1.
525
+ point2: list
526
+ List of coordinates for point 2.
527
+ source_parts: list
528
+ A list of parts to create the particle trace in. For instance, in a CFD
529
+ simulation this might be the fluid zone.
530
+ If not provided, the function will try to look for the selected parts.
531
+ num_points: int
532
+ The number of points to emit from. Defaults to 100.
533
+ emit_time: float
534
+ The emission time to start the particle trace from. If not provided,
535
+ it will use the current time.
536
+ total_time: float
537
+ The total emission time. If not provided, EnSight will provide the end time
538
+ for a transient simulation, an internal best time for steady state simulations.
539
+ delta_time: float
540
+ The interval for the emissions. If not provided, EnSight will provide
541
+ a best estimate.
542
+ """
543
+ emitter_type = self._EMIT_LINE
544
+ direction, converted_source_parts = self._prepare_particle_creation(
545
+ direction=direction, source_parts=source_parts
546
+ )
547
+ pathline_part, def_part = self._create_pathline_part(
548
+ name,
549
+ variable,
550
+ direction,
551
+ converted_source_parts,
552
+ pathlines=pathlines,
553
+ emit_time=emit_time,
554
+ delta_time=delta_time,
555
+ total_time=total_time,
556
+ )
557
+ new_emitters = self._create_emitters(
558
+ emitter_type=emitter_type, point1=point1, point2=point2, num_points=num_points
559
+ )
560
+ return self._add_emitters_to_pathline(
561
+ pathline_part, new_emitters=new_emitters, palette=def_part.VARIABLE.DESCRIPTION
562
+ )
563
+
564
+ def create_particle_trace_from_plane(
565
+ self,
566
+ name: str,
567
+ variable: Union[str, int, "ENS_VAR"],
568
+ point1: List[float],
569
+ point2: List[float],
570
+ point3: List[float],
571
+ num_points_x: Optional[int] = 25,
572
+ num_points_y: Optional[int] = 25,
573
+ direction: Optional[str] = None,
574
+ pathlines: Optional[bool] = False,
575
+ source_parts: Optional[List[Union[str, int, "ENS_PART"]]] = None,
576
+ emit_time: Optional[float] = None,
577
+ total_time: Optional[float] = None,
578
+ delta_time: Optional[float] = None,
579
+ ) -> "ENS_PART":
580
+ """
581
+ Create a particle trace part from a plane.
582
+ Returns the ``ENS_PART`` generated.
583
+
584
+ Parameters:
585
+ -----------
586
+
587
+ name: str
588
+ The name of part to be generated
589
+ variable:
590
+ The variable to compute the particle traces with.
591
+ It can be the name, the ID or the ``ENS_VAR`` object. It must be a vector variable.
592
+ direction: str
593
+ The direction for the particle traces to be generated.
594
+ This table describes the options:
595
+
596
+ ================== ==============================================
597
+ Name Query type
598
+ ================== ==============================================
599
+ PT_POS_TIME Follow the vector direction
600
+ PT_NEG_TIME Go contrary to the vector direction
601
+ PT_POS_NEG_TIME Follow and go contrary to the vector direction
602
+ ================== ==============================================
603
+
604
+ If not provided, it will default to ``PT_POS_TIME``
605
+ pathlines: bool
606
+ True if the particle traces need to be pathlines
607
+ point1: list
608
+ List of coordinates for point 1, being a corner of the plane.
609
+ point2: list
610
+ List of coordinates for point 2, being a corner of the plane.
611
+ point3: list
612
+ List of coordinates for point 3, being a corner of the plane.
613
+ source_parts: list
614
+ A list of parts to create the particle trace in. For instance, in a CFD
615
+ simulation this might be the fluid zone.
616
+ If not provided, the function will try to look for the selected parts.
617
+ num_points_x: int
618
+ The number of points on the ``X`` direction of the emission plane.
619
+ Defaults to 25.
620
+ num_points_y: int
621
+ The number of points on the ``Y`` direction of the emission plane.
622
+ Defaults to 25.
623
+ emit_time: float
624
+ The emission time to start the particle trace from. If not provided,
625
+ it will use the current time.
626
+ total_time: float
627
+ The total emission time. If not provided, EnSight will provide the end time
628
+ for a transient simulation, an internal best time for steady state simulations.
629
+ delta_time: float
630
+ The interval for the emissions. If not provided, EnSight will provide
631
+ a best estimate.
632
+ """
633
+ emitter_type = self._EMIT_PLANE
634
+ direction, converted_source_parts = self._prepare_particle_creation(
635
+ direction=direction, source_parts=source_parts
636
+ )
637
+ pathline_part, def_part = self._create_pathline_part(
638
+ name,
639
+ variable,
640
+ direction,
641
+ converted_source_parts,
642
+ pathlines=pathlines,
643
+ emit_time=emit_time,
644
+ delta_time=delta_time,
645
+ total_time=total_time,
646
+ )
647
+ new_emitters = self._create_emitters(
648
+ emitter_type=emitter_type,
649
+ point1=point1,
650
+ point2=point2,
651
+ point3=point3,
652
+ num_points_x=num_points_x,
653
+ num_points_y=num_points_y,
654
+ )
655
+ return self._add_emitters_to_pathline(
656
+ pathline_part, new_emitters=new_emitters, palette=def_part.VARIABLE.DESCRIPTION
657
+ )
658
+
659
+ def create_particle_trace_from_parts(
660
+ self,
661
+ name: str,
662
+ variable: Union[str, int, "ENS_VAR"],
663
+ parts: List[Union[str, int, "ENS_PART"]],
664
+ part_distribution_type: Optional[int] = 0,
665
+ num_points: Optional[int] = 100,
666
+ direction: Optional[str] = None,
667
+ pathlines: Optional[bool] = False,
668
+ source_parts: Optional[List[Union[str, int, "ENS_PART"]]] = None,
669
+ emit_time: Optional[float] = None,
670
+ total_time: Optional[float] = None,
671
+ delta_time: Optional[float] = None,
672
+ ) -> "ENS_PART":
673
+ """
674
+ Create a particle trace part from a list of seed parts.
675
+ Returns the ``ENS_PART`` generated.
676
+
677
+ Parameters:
678
+ -----------
679
+
680
+ name: str
681
+ The name of part to be generated
682
+ variable:
683
+ The variable to compute the particle traces with.
684
+ It can be the name, the ID or the ``ENS_VAR`` object. It must be a vector variable.
685
+ direction: str
686
+ The direction for the particle traces to be generated.
687
+ This table describes the options:
688
+
689
+ ================== ==============================================
690
+ Name Query type
691
+ ================== ==============================================
692
+ PT_POS_TIME Follow the vector direction
693
+ PT_NEG_TIME Go contrary to the vector direction
694
+ PT_POS_NEG_TIME Follow and go contrary to the vector direction
695
+ ================== ==============================================
696
+
697
+ If not provided, it will default to ``PT_POS_TIME``
698
+ pathlines: bool
699
+ True if the particle traces need to be pathlines
700
+ source_parts: list
701
+ A list of parts to create the particle trace in. For instance, in a CFD
702
+ simulation this might be the fluid zone.
703
+ If not provided, the function will try to look for the selected parts.
704
+ parts: list
705
+ A list of parts to emit the particle traces from.
706
+ They can be their names, their IDs or the respective ``ENS_PART`` objects.
707
+ part_distribution_type: int
708
+ The distribution of emitters in case of emission from a part.
709
+ This table describes the options:
710
+
711
+ ==================== =================================================
712
+ Name Query type
713
+ ==================== =================================================
714
+ PART_EMIT_FROM_NODES Emit from the nodes of the part
715
+ PART_EMIT_FROM_AREA Create an area of equidistant points for emission
716
+ ================== =================================================
717
+
718
+ If not provided, it will default to ``PART_EMIT_FROM_NODES``
719
+ num_points: int
720
+ The number of points to emit from.
721
+ Defaults to 100.
722
+ emit_time: float
723
+ The emission time to start the particle trace from. If not provided,
724
+ it will use the current time.
725
+ total_time: float
726
+ The total emission time. If not provided, EnSight will provide the end time
727
+ for a transient simulation, an internal best time for steady state simulations.
728
+ delta_time: float
729
+ The interval for the emissions. If not provided, EnSight will provide
730
+ a best estimate.
731
+ """
732
+ emitter_type = self._EMIT_PART
733
+ direction, converted_source_parts = self._prepare_particle_creation(
734
+ direction=direction, source_parts=source_parts
735
+ )
736
+ pathline_part, def_part = self._create_pathline_part(
737
+ name,
738
+ variable,
739
+ direction,
740
+ converted_source_parts,
741
+ pathlines=pathlines,
742
+ emit_time=emit_time,
743
+ delta_time=delta_time,
744
+ total_time=total_time,
745
+ )
746
+ new_parts = [convert_part(self.ensight, p) for p in parts]
747
+ new_emitters = self._create_emitters(
748
+ emitter_type=emitter_type,
749
+ parts=new_parts,
750
+ part_distribution_type=part_distribution_type,
751
+ num_points=num_points,
752
+ )
753
+ return self._add_emitters_to_pathline(
754
+ pathline_part, new_emitters=new_emitters, palette=def_part.VARIABLE.DESCRIPTION
755
+ )
756
+
757
+ def add_emitter_points_to_pathline_part(
758
+ self,
759
+ pathline_part: Union[str, int, "ENS_PART"],
760
+ points: List[List[float]],
761
+ ) -> "ENS_PART":
762
+ """
763
+ Add point emitters to an existing particle trace. The function will return the updated
764
+ ``ENS_PART`` object.
765
+
766
+ Parameters:
767
+ -----------
768
+
769
+ pathline_part:
770
+ The particle trace part to be added emitters to.
771
+ Can be the name, the ID or the ``ENS_PART`` object
772
+ points: list
773
+ List of list containing the coordinates for the seed points.
774
+ """
775
+ emitter_type = self._EMIT_POINT
776
+ pathline_part = self._cure_pathline_part(pathline_part)
777
+ new_emitters = self._create_emitters(emitter_type=emitter_type, points=points)
778
+ return self._add_emitters_to_pathline(pathline_part, new_emitters)
779
+
780
+ def add_emitter_line_to_pathline_part(
781
+ self,
782
+ pathline_part: Union[str, int, "ENS_PART"],
783
+ point1: List[float],
784
+ point2: List[float],
785
+ num_points: Optional[int] = 100,
786
+ ):
787
+ """
788
+ Add a line emitter to an existing particle trace. The function will return the updated
789
+ ``ENS_PART`` object.
790
+
791
+ Parameters:
792
+ -----------
793
+
794
+ pathline_part:
795
+ The particle trace part to be added emitters to.
796
+ Can be the name, the ID or the ``ENS_PART`` object.
797
+ point1: list
798
+ The coordinates for point 1.
799
+ point2: list
800
+ The coordinates for point 2.
801
+ num_points: int
802
+ The number of seed points. Defaults to 100.
803
+ """
804
+ emitter_type = self._EMIT_LINE
805
+ pathline_part = self._cure_pathline_part(pathline_part)
806
+ new_emitters = self._create_emitters(
807
+ emitter_type=emitter_type, point1=point1, point2=point2, num_points=num_points
808
+ )
809
+ return self._add_emitters_to_pathline(pathline_part, new_emitters)
810
+
811
+ def add_emitter_plane_to_pathline_part(
812
+ self,
813
+ pathline_part: Union[str, int, "ENS_PART"],
814
+ point1: List[float],
815
+ point2: List[float],
816
+ point3: List[float],
817
+ num_points_x: Optional[int] = 25,
818
+ num_points_y: Optional[int] = 25,
819
+ ):
820
+ """
821
+ Add a plane emitter to an existing particle trace. The function will return the updated
822
+ ``ENS_PART`` object.
823
+
824
+ Parameters:
825
+ -----------
826
+
827
+ pathline_part:
828
+ The particle trace part to be added emitters to.
829
+ Can be the name, the ID or the ``ENS_PART`` object.
830
+ point1: list
831
+ The coordinates for point 1, being a corner of the plane.
832
+ point2: list
833
+ The coordinates for point 2, being a corner of the plane.
834
+ point3: list
835
+ The coordinates for point 3, being a corner of the plane.
836
+ num_points_x: int
837
+ The number of points on the ``X`` direction of the emission plane.
838
+ Defaults to 25.
839
+ num_points_y: int
840
+ The number of points on the ``Y`` direction of the emission plane.
841
+ Defaults to 25.
842
+ """
843
+ emitter_type = self._EMIT_PLANE
844
+ pathline_part = self._cure_pathline_part(pathline_part)
845
+ new_emitters = self._create_emitters(
846
+ emitter_type=emitter_type,
847
+ point1=point1,
848
+ point2=point2,
849
+ point3=point3,
850
+ num_points_x=num_points_x,
851
+ num_points_y=num_points_y,
852
+ )
853
+ return self._add_emitters_to_pathline(pathline_part, new_emitters)
854
+
855
+ def add_emitter_parts_to_pathline_part(
856
+ self,
857
+ pathline_part: Union[str, int, "ENS_PART"],
858
+ parts: List[Union[str, int, "ENS_PART"]],
859
+ part_distribution_type: Optional[int] = 0,
860
+ num_points: Optional[int] = 100,
861
+ ):
862
+ """
863
+ Add a list of part emitters to an existing particle trace. The function will return the updated
864
+ ``ENS_PART`` object.
865
+
866
+ Parameters:
867
+ -----------
868
+
869
+ pathline_part:
870
+ The particle trace part to be added emitters to.
871
+ Can be the name, the ID or the ``ENS_PART`` object.
872
+ parts: list
873
+ A list of parts to emit the particle traces from.
874
+ They can be their names, their IDs or the respective ``ENS_PART`` objects.
875
+ part_distribution_type: int
876
+ The distribution of emitters in case of emission from a part.
877
+ This table describes the options:
878
+
879
+ ==================== =================================================
880
+ Name Query type
881
+ ==================== =================================================
882
+ PART_EMIT_FROM_NODES Emit from the nodes of the part
883
+ PART_EMIT_FROM_AREA Create an area of equidistant points for emission
884
+ ================== =================================================
885
+
886
+ If not provided, it will default to ``PART_EMIT_FROM_NODES``
887
+ num_points: int
888
+ The number of points to emit from.
889
+ Defaults to 100.
890
+ """
891
+ emitter_type = self._EMIT_PART
892
+ pathline_part = self._cure_pathline_part(pathline_part)
893
+ new_parts = [convert_part(self.ensight, p) for p in parts]
894
+ new_emitters = self._create_emitters(
895
+ emitter_type=emitter_type,
896
+ parts=new_parts,
897
+ part_distribution_type=part_distribution_type,
898
+ num_points=num_points,
899
+ )
900
+ return self._add_emitters_to_pathline(pathline_part, new_emitters)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ansys-pyensight-core
3
- Version: 0.7.0
3
+ Version: 0.7.2
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>
@@ -20,8 +20,6 @@ Requires-Dist: ansys-api-pyensight==0.3.2
20
20
  Requires-Dist: requests>=2.28.2
21
21
  Requires-Dist: docker>=6.1.0
22
22
  Requires-Dist: urllib3<2
23
- Requires-Dist: typing>=3.7.4.3
24
- Requires-Dist: typing-extensions>=4.5.0
25
23
  Requires-Dist: numpy>=1.21.0
26
24
  Requires-Dist: Pillow>=9.3.0
27
25
  Requires-Dist: build>=0.10.0 ; extra == "dev"
@@ -7,20 +7,20 @@ ansys/pyensight/core/ensight_grpc.py,sha256=yFnvxjI2cAWd0c0gcM46MEIA5Ov7DUMlufqU
7
7
  ansys/pyensight/core/ensobj.py,sha256=tynUyYrpzCz2lvcse6fcmutnG6Jj111s518OlO19EqE,17354
8
8
  ansys/pyensight/core/launch_ensight.py,sha256=KqUq3dYc2j4aKMkZYu9rXXw7ODZDqFbD6kx4Vt0uJcg,5915
9
9
  ansys/pyensight/core/launcher.py,sha256=zj-6DBp307-IJ0RTDmZOxCFVGemJu8YaagJLZFLloNw,10445
10
- ansys/pyensight/core/listobj.py,sha256=vsVTeI3RY0P1n5GNOHW-iU95GCWnHlOg_E6leVMQScw,8223
10
+ ansys/pyensight/core/listobj.py,sha256=MFrjl9b-OGntlvh9yib2swUNT2jaMvoP5uniU0Fpt9s,8194
11
11
  ansys/pyensight/core/locallauncher.py,sha256=sgaPrG-7ctXZ_ytGuHeriiVmgvI0kUeX6nKVJ4OiDUs,13984
12
12
  ansys/pyensight/core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- ansys/pyensight/core/renderable.py,sha256=z61Pum_Pa2CVoXVWOCqPngeHT_ifBS3fpqA5mZDDmnc,30777
14
- ansys/pyensight/core/session.py,sha256=nTeqiXsOz_FffeYGsYLsWDznP86-ZBxS0AA8wgOEBeU,62690
13
+ ansys/pyensight/core/renderable.py,sha256=Kf9pLQPLk91D7TwvXrL2wsMyKz_J6opcJ8peQr2pbxQ,31451
14
+ ansys/pyensight/core/session.py,sha256=CHVAYncg8Uaacz4cbA-mAVWyWAOjfol635ohSIfa054,63241
15
15
  ansys/pyensight/core/sgeo_poll.html,sha256=1M4BIc5CZpYA3b40qzk22NcPCLhjFnWdoS2PrS6Rhn4,752
16
16
  ansys/pyensight/core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  ansys/pyensight/core/utils/adr.py,sha256=XslZhlwcrSGzOlnhzprOv3ju_ppxxsWBjCnQL5KiNms,3570
18
18
  ansys/pyensight/core/utils/export.py,sha256=MGdPAPpI4CoLR-Fnctkqf9J7--J3DPEXK79kKZGVCqw,21552
19
- ansys/pyensight/core/utils/parts.py,sha256=x0Zso-ef64UJ-3BmYS3dymjftaWQI21WFTsDt-ghI-k,3986
19
+ ansys/pyensight/core/utils/parts.py,sha256=rDnf17Rw02mwd3-R5qnB47kQAbvZQ0_YegYfxCmTBTY,36478
20
20
  ansys/pyensight/core/utils/query.py,sha256=cQXt_07ZuNAwueAIXinI3_f7G9lXass6j7G0aRJltZE,19035
21
21
  ansys/pyensight/core/utils/support.py,sha256=QI3z9ex7zJxjFbkCPba9DWqWgPFIThORqr0nvRfVjuc,4089
22
22
  ansys/pyensight/core/utils/views.py,sha256=vf4gSBRl6uC_LPwZdzrdMcR0dyi_PwYmRo20CPmjEBE,12209
23
- ansys_pyensight_core-0.7.0.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
24
- ansys_pyensight_core-0.7.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
25
- ansys_pyensight_core-0.7.0.dist-info/METADATA,sha256=nKZPh4wq6SSDRrRwbZsHViS4MSp82NPfOXVOWqXARvE,11781
26
- ansys_pyensight_core-0.7.0.dist-info/RECORD,,
23
+ ansys_pyensight_core-0.7.2.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
24
+ ansys_pyensight_core-0.7.2.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
25
+ ansys_pyensight_core-0.7.2.dist-info/METADATA,sha256=crbiIJ8gYFFT0gaSxui8FMQzCcfRx4DEFAuZ-1sKvxI,11710
26
+ ansys_pyensight_core-0.7.2.dist-info/RECORD,,