|
26 | 26 | Contains classes associated with the DPF FieldsContainer. |
27 | 27 | """ |
28 | 28 |
|
| 29 | +from __future__ import annotations |
| 30 | + |
| 31 | +from typing import TYPE_CHECKING |
| 32 | + |
29 | 33 | from ansys import dpf |
30 | 34 | from ansys.dpf.core import errors as dpf_errors, field |
31 | 35 | from ansys.dpf.core.collection_base import CollectionBase |
| 36 | +from ansys.dpf.core.common import shell_layers |
| 37 | + |
| 38 | +if TYPE_CHECKING: |
| 39 | + from ansys.dpf.core import Operator, Result |
32 | 40 |
|
33 | 41 |
|
34 | 42 | class FieldsContainer(CollectionBase["field.Field"]): |
@@ -543,23 +551,39 @@ def plot(self, label_space: dict = None, **kwargs): |
543 | 551 | plt.add_field(field=f, **kwargs) |
544 | 552 | plt.show_figure(**kwargs) |
545 | 553 |
|
546 | | - def animate(self, save_as=None, deform_by=None, scale_factor=1.0, **kwargs): |
| 554 | + def animate( |
| 555 | + self, |
| 556 | + save_as: str = None, |
| 557 | + deform_by: Union[FieldsContainer, Result, Operator] = None, |
| 558 | + scale_factor: Union[float, Sequence[float]] = 1.0, |
| 559 | + shell_layer: shell_layers = shell_layers.top, |
| 560 | + **kwargs, |
| 561 | + ): |
547 | 562 | """Create an animation based on the Fields contained in the FieldsContainer. |
548 | 563 |
|
549 | 564 | This method creates a movie or a gif based on the time ids of a FieldsContainer. |
550 | 565 | For kwargs see pyvista.Plotter.open_movie/add_text/show. |
551 | 566 |
|
552 | 567 | Parameters |
553 | 568 | ---------- |
554 | | - save_as : Path of file to save the animation to. Defaults to None. Can be of any format |
| 569 | + save_as: |
| 570 | + Path of file to save the animation to. Defaults to None. Can be of any format |
555 | 571 | supported by pyvista.Plotter.write_frame (.gif, .mp4, ...). |
556 | | - deform_by : FieldsContainer, Result, Operator, optional |
| 572 | + deform_by: |
557 | 573 | Used to deform the plotted mesh. Must return a FieldsContainer of the same length as |
558 | 574 | self, containing 3D vector Fields of distances. |
559 | 575 | Defaults to None, which takes self if possible. Set as False to force static animation. |
560 | 576 | scale_factor : float, list, optional |
561 | 577 | Scale factor to apply when warping the mesh. Defaults to 1.0. Can be a list to make |
562 | 578 | scaling frequency-dependent. |
| 579 | + shell_layer: |
| 580 | + Enum used to set the shell layer if the field to plot |
| 581 | + contains shell elements. Defaults to top layer. |
| 582 | + **kwargs: |
| 583 | + Additional keyword arguments for the animator. |
| 584 | + Used by :func:`pyvista.Plotter` (off_screen, cpos, ...), |
| 585 | + or by :func:`pyvista.Plotter.open_movie` |
| 586 | + (framerate, quality, ...) |
563 | 587 | """ |
564 | 588 | from ansys.dpf.core.animator import Animator |
565 | 589 |
|
@@ -655,6 +679,7 @@ def animate(self, save_as=None, deform_by=None, scale_factor=1.0, **kwargs): |
655 | 679 | loop_over=loop_over_field, |
656 | 680 | save_as=save_as, |
657 | 681 | scale_factor=scale_factor, |
| 682 | + shell_layer=shell_layer, |
658 | 683 | **kwargs, |
659 | 684 | ) |
660 | 685 |
|
|
0 commit comments