Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
37c5d1c
Fix plot behavior when using keywords screenshot and off_screen
PProfizi Mar 15, 2022
f6cb40b
Fixed flake8 style
PProfizi Mar 22, 2022
4450f9c
Fixed flake8 style
PProfizi Mar 22, 2022
36edd01
Fixed error due to "text" kwarg in MeshedRegion.plot() that was given…
PProfizi Mar 22, 2022
833f12e
Fixed behavior for keyword "notebook=False" when using a jupyter note…
PProfizi Mar 23, 2022
89fe588
Fixed behavior of Field.plot wrt notebook argument.
PProfizi Mar 23, 2022
edd898e
Fixed MeshesContainer.plot for screenshot and off_screen kwargs
PProfizi May 20, 2022
2b87eba
Fix plot_chart
PProfizi May 20, 2022
ddb839e
Fix plot_chart for off_screen and screenshot
PProfizi May 20, 2022
863a580
Add example for basic plotting commands
PProfizi May 20, 2022
c2210cf
Add example for basic plotting commands
PProfizi May 23, 2022
9a0c632
Fix plotting commands for screenshot and off_screen
PProfizi May 23, 2022
7ea10b7
Add tests for plotting with screenshot and off_screen arguments
PProfizi May 23, 2022
4a2a11b
Fixing stuck docstring test for meshes_container.plot
PProfizi May 23, 2022
16b41df
Fixing stuck docstring test for field.plot_contour.plot
PProfizi May 23, 2022
8933088
Testing without PYVISTA_OFF_SCREEN=True
PProfizi May 24, 2022
940fe2a
Model.plot now goes through DpfPlotter
PProfizi May 25, 2022
3269660
Plot_contour in DpfPlotter,
PProfizi May 25, 2022
51db5ce
Field.plot goes through DpfPlotter.plot_contour
PProfizi May 25, 2022
629602c
meshes_container.plot updated
PProfizi May 25, 2022
132298d
WIP on double scalar_bar when calling mesh.plot(field) after mesh.plo…
PProfizi May 25, 2022
e24fb11
Fixed double scalar bar when calling two consecituve mesh.plot with d…
PProfizi May 25, 2022
2ed0be3
Make _set_scalar_bar_title private
PProfizi May 25, 2022
9ef2d52
Merge branch 'master' into fix/Issue#193_screenshots
PProfizi May 25, 2022
95c5d62
Flake8 errors
PProfizi May 25, 2022
89dd3db
Changed when grid.active_scalars is set to None because doing it at t…
PProfizi May 25, 2022
0e6e7b7
Resolve Codacy issues
PProfizi May 27, 2022
7c4b503
Refactor _InternalPlotter to pass through a factory (for future multi…
PProfizi May 27, 2022
4c085e1
No plot_chart in basic_plotting yet
PProfizi May 30, 2022
11bf7cd
Test MeshedRegion.plot
PProfizi May 30, 2022
d55ccae
Test cpos argument for pyvista.show
PProfizi May 30, 2022
7d7cf09
Test return_cpos argument for pyvista.show and fixed
PProfizi May 30, 2022
5814f9e
Test plot_mesh with DpfPlotter and fix
PProfizi May 30, 2022
a8cbbc5
Test test_chart_plotter is for now limited to legacy Plotter as plotè…
PProfizi May 30, 2022
858d65e
Improve test coverage and fix codacy quality remarks
PProfizi May 30, 2022
f1d0545
Revert refactoring for MeshedRegion.plot and Field.plot to go through…
PProfizi May 30, 2022
5b55b58
Revert changes to ci
PProfizi May 30, 2022
8cbe368
Revert changes to ci
PProfizi May 30, 2022
3fb44bf
Minimize changes to field.py
PProfizi May 30, 2022
9fed7ba
Small fix useless line in test_chart_plotter
PProfizi May 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions ansys/dpf/core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def to_nodal(self):
op.inputs.connect(self)
return op.outputs.field()

def plot(self, notebook=None, shell_layers=None):
def plot(self, notebook=None, shell_layers=None, **kwargs):
"""Plot the field or fields container on the mesh support if it exists.

Warning
Expand Down Expand Up @@ -266,9 +266,12 @@ def plot(self, notebook=None, shell_layers=None):
shell_layers : shell_layers, optional
Enum used to set the shell layers if the model to plot
contains shell elements. The default is ``None``.
**kwargs : optional
Additional keyword arguments for the plotter. For additional keyword
arguments, see ``help(pyvista.plot)``.
"""
pl = Plotter(self.meshed_region)
pl.plot_contour(self, notebook, shell_layers)
pl = Plotter(self.meshed_region, **kwargs)
pl.plot_contour(self, notebook, shell_layers, **kwargs)

def resize(self, nentities, datasize):
"""Allocate memory.
Expand Down
22 changes: 10 additions & 12 deletions ansys/dpf/core/meshed_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ansys.dpf.core.common import locations, types, nodal_properties, elemental_properties
from ansys.dpf.core.elements import Elements, element_types
from ansys.dpf.core.nodes import Nodes
from ansys.dpf.core.plotter import Plotter as _DpfPlotter
from ansys.dpf.core.plotter import DpfPlotter, Plotter
from ansys.dpf.core.cache import class_handling_cache
from ansys.grpc.dpf import meshed_region_pb2, meshed_region_pb2_grpc

Expand Down Expand Up @@ -406,20 +406,18 @@ def plot(
>>> model.metadata.meshed_region.plot(field)

"""
pl = _DpfPlotter(self)
if field_or_fields_container is not None:
return pl.plot_contour(
field_or_fields_container,
notebook,
shell_layers,
off_screen,
show_axes,
**kwargs
)
pl = Plotter(self, **kwargs)
return pl.plot_contour(field_or_fields_container, notebook,
shell_layers, off_screen, show_axes, **kwargs)

# otherwise, simply plot self
# otherwise, simply plot the mesh
kwargs["off_screen"] = off_screen
kwargs["notebook"] = notebook
return pl.plot_mesh(**kwargs)
pl = DpfPlotter(**kwargs)
pl.add_mesh(self, **kwargs)
kwargs["show_axes"] = show_axes
return pl.show_figure(**kwargs)

def deep_copy(self, server=None):
"""Create a deep copy of the meshed region's data on a given server.
Expand Down
13 changes: 10 additions & 3 deletions ansys/dpf/core/meshes_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def plot(self, fields_container=None, **kwargs):
----------
fields_container : FieldsContainer, optional
Data to plot. The default is ``None``.
**kwargs : optional
Additional keyword arguments for the plotter. For additional keyword
arguments, see ``help(pyvista.plot)``.

Examples
--------
Expand All @@ -64,9 +67,11 @@ def plot(self, fields_container=None, **kwargs):
>>> meshes_cont.plot(disp_fc)

"""
# DPF defaults
kwargs.setdefault("show_edges", True)
notebook = kwargs.pop("notebook", None)
pl = DpfPlotter(notebook=notebook)
# Initiate plotter
pl = DpfPlotter(**kwargs)
# If a fields' container is given
if fields_container is not None:
for i in range(len(fields_container)):
label_space = fields_container.get_label_space(i)
Expand All @@ -80,13 +85,15 @@ def plot(self, fields_container=None, **kwargs):
field = fields_container[i]
pl.add_field(field, mesh_to_send, **kwargs)
else:
# If no field given, associate a random color to each mesh in the container
from random import random
random_color = "color" not in kwargs
for mesh in self:
if random_color:
kwargs["color"] = [random(), random(), random()]
pl.add_mesh(mesh, **kwargs)
pl.show_figure()
# Plot the figure
pl.show_figure(**kwargs)

def get_meshes(self, label_space):
"""Retrieve the meshes at a label space.
Expand Down
19 changes: 16 additions & 3 deletions ansys/dpf/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ def __str__(self):
def plot(self, color="w", show_edges=True, **kwargs):
"""Plot the mesh of the model.

Parameters
----------
color : str
color of the mesh faces in PyVista format. The default is white with ``"w"``.
show_edges : bool
Whether to show the mesh edges. The default is ``True``.
**kwargs : optional
Additional keyword arguments for the plotter. For additional keyword
arguments, see ``help(pyvista.plot)``.

Examples
--------
Plot the model using the default options.
Expand All @@ -225,9 +235,12 @@ def plot(self, color="w", show_edges=True, **kwargs):
>>> model.plot()

"""
self.metadata.meshed_region.grid.plot(
color=color, show_edges=show_edges, **kwargs
)
from ansys.dpf.core.plotter import DpfPlotter
kwargs["color"] = color
kwargs["show_edges"] = show_edges
pl = DpfPlotter(**kwargs)
pl.add_mesh(self.metadata.meshed_region, **kwargs)
pl.show_figure(**kwargs)

@property
def mesh_by_default(self):
Expand Down
Loading