:class:`DpfPlotter` =================== .. py:class:: ansys.dpf.core.plotter.DpfPlotter(**kwargs) DpfPlotter class. Can be used in order to plot results over a mesh. The current DpfPlotter is a PyVista based object. That means that PyVista must be installed, and that it supports kwargs as parameter (the argument must be supported by the installed PyVista version). More information about the available arguments are available at :class:`pyvista.Plotter`. .. py:currentmodule:: DpfPlotter Overview -------- .. tab-set:: .. tab-item:: Methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~add_node_labels` - Add labels at nodal locations. * - :py:attr:`~add_points` - Add points to the plot. * - :py:attr:`~add_line` - Add lines to the plot. * - :py:attr:`~add_plane` - Add a plane to the plot. * - :py:attr:`~add_mesh` - Add a mesh to plot. * - :py:attr:`~add_streamlines` - Add a streamline to the plotter. * - :py:attr:`~add_field` - Add a field containing data to the plotter. * - :py:attr:`~show_figure` - Plot the figure built by the plotter object. .. tab-item:: Properties .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~labels` - Return a list of labels. Import detail ------------- .. code-block:: python from ansys.dpf.core.plotter import DpfPlotter Property detail --------------- .. py:property:: labels Return a list of labels. :returns: List of Label(s). Each list member or member group will share same properties. :rtype: list Method detail ------------- .. py:method:: add_node_labels(nodes: Union[ansys.dpf.core.nodes.Nodes, List[ansys.dpf.core.nodes.Node], List[int]], meshed_region: ansys.dpf.core.meshed_region.MeshedRegion, labels: Union[List[str], None] = None, **kwargs) Add labels at nodal locations. :param nodes: Nodes where the labels should be added. :param meshed_region: MeshedRegion to plot. :param labels: The labels to use. A node for which the label is not defined or `None` will show the scalar value of the currently active field at that node, or, if no field is active, its node ID. :param kwargs: Keyword arguments controlling label properties. See :func:`pyvista.Plotter.add_point_labels`. .. py:method:: add_points(points, field=None, **kwargs) Add points to the plot. .. py:method:: add_line(points, field=None, **kwargs) Add lines to the plot. .. py:method:: add_plane(plane, field=None, **kwargs) Add a plane to the plot. .. py:method:: add_mesh(meshed_region, deform_by=None, scale_factor=1.0, **kwargs) Add a mesh to plot. :param meshed_region: MeshedRegion to plot. :type meshed_region: MeshedRegion :param deform_by: Used to deform the plotted mesh. Must output a 3D vector field. Defaults to None. :type deform_by: Field, Result, Operator, optional :param scale_factor: Scaling factor to apply when warping the mesh. Defaults to 1.0. :type scale_factor: float, optional :param \*\*kwargs: Additional keyword arguments for the plotter. More information are available at :func:`pyvista.plot`. :type \*\*kwargs: optional .. rubric:: Examples >>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_multishells_rst()) >>> mesh = model.metadata.meshed_region >>> from ansys.dpf.core.plotter import DpfPlotter >>> pl = DpfPlotter() >>> pl.add_mesh(mesh) .. py:method:: add_streamlines(streamlines, source=None, radius=0.1, **kwargs) Add a streamline to the plotter. The current add_streamlines method adds streamline as a PyVista based object. For more information about arguments, see :func:`pyvista.DataSetFilters.streamlines`. :param streamlines: Object containing computed streamlines data, computed using `helpers.streamlines.compute_streamlines` function. :type streamlines: helpers.streamlines.Streamlines :param source: Object containing computed streamines source data, computed using `helpers.streamlines.compute_streamlines` function. :type source: helpers.streamlines.StreamlinesSource, optional :param \*\*kwargs: Additional keyword arguments for the plotter. More information is available at :func:`pyvista.plot`. The "permissive" (boolean, default being True) can be used to avoid throwing if computed streamlines are empty. See ``Examples`` section for more information. :type \*\*kwargs: optional .. rubric:: Examples >>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> from ansys.dpf.core.helpers.streamlines import compute_streamlines >>> # Get model and meshed region >>> files = examples.download_fluent_mixing_elbow_steady_state() >>> ds = dpf.DataSources() >>> ds.set_result_file_path(files["cas"][0], "cas") >>> ds.add_file_path(files["dat"][1], "dat") >>> model = dpf.Model(ds) >>> mesh = model.metadata.meshed_region >>> # Get velocity data >>> velocity_op = model.results.velocity() >>> fc = velocity_op.outputs.fields_container() >>> op = dpf.operators.averaging.to_nodal_fc(fields_container=fc) >>> field = op.outputs.fields_container()[0] >>> # Plot >>> from ansys.dpf.core.plotter import DpfPlotter >>> pl = DpfPlotter() >>> pl.add_mesh(meshed_region=mesh, opacity=0.15, color="g") >>> streamline_obj = compute_streamlines( ... meshed_region=mesh, ... field=field, ... source_center=(0.55, 0.55, 0.), ... n_points=10, ... source_radius=0.08, ... max_time=10.0 ... ) >>> pl.add_streamlines( ... streamlines=streamline_obj, ... radius=0.001, ... ) >>> pl.show_figure(show_axes=True) .. py:method:: add_field(field, meshed_region=None, show_max=False, show_min=False, label_text_size=30, label_point_size=20, deform_by=None, scale_factor=1.0, **kwargs) Add a field containing data to the plotter. A meshed_region to plot on can be added. If no ``meshed_region`` is specified, the field support will be used. Ensure that the field support is a ``meshed_region``. :param field: Field data to plot :type field: Field :param meshed_region: ``MeshedRegion`` to plot the field on. :type meshed_region: MeshedRegion, optional :param show_max: Label the point with the maximum value. :type show_max: bool, optional :param show_min: Label the point with the minimum value. :type show_min: bool, optional :param deform_by: Used to deform the plotted mesh. Must output a 3D vector field. Defaults to None. :type deform_by: Field, Result, Operator, optional :param scale_factor: Scaling factor to apply when warping the mesh. Defaults to 1.0. :type scale_factor: float, optional :param \*\*kwargs: Additional keyword arguments for the plotter. More information are available at :func:`pyvista.plot`. :type \*\*kwargs: optional .. rubric:: Examples >>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_multishells_rst()) >>> mesh = model.metadata.meshed_region >>> field = model.results.displacement().outputs.fields_container()[0] >>> from ansys.dpf.core.plotter import DpfPlotter >>> pl = DpfPlotter() >>> pl.add_field(field, mesh) .. py:method:: show_figure(**kwargs) Plot the figure built by the plotter object. :param \*\*kwargs: Additional keyword arguments for the plotter. More information are available at :func:`pyvista.plot`. :type \*\*kwargs: optional .. rubric:: Examples >>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_multishells_rst()) >>> mesh = model.metadata.meshed_region >>> field = model.results.displacement().outputs.fields_container()[0] >>> from ansys.dpf.core.plotter import DpfPlotter >>> pl = DpfPlotter() >>> pl.add_field(field, mesh) >>> pl.show_figure()