From 8a897e797a9c0c29e89be2d71702b0a912af2932 Mon Sep 17 00:00:00 2001 From: "paul.profizi" Date: Thu, 23 Nov 2023 11:33:48 +0100 Subject: [PATCH 1/2] Update basic plotting as Premium is default --- examples/06-plotting/00-basic_plotting.py | 36 +++++++++++------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/examples/06-plotting/00-basic_plotting.py b/examples/06-plotting/00-basic_plotting.py index 6841b4b72c..c7063f109e 100644 --- a/examples/06-plotting/00-basic_plotting.py +++ b/examples/06-plotting/00-basic_plotting.py @@ -74,22 +74,20 @@ # ############################################################################################## # # This next section requires a Premium context to be active du to the ``split_mesh`` operator. # # Comment this last part to run the example as Entry. -# -# dpf.SERVER.apply_context(dpf.AvailableServerContexts.premium) -# -# # One can also plot a MeshesContainer. Here our mesh is split by material. -# split_mesh_op = dpf.Operator("split_mesh") -# split_mesh_op.connect(7, mesh) -# split_mesh_op.connect(13, "mat") -# meshes_cont = split_mesh_op.get_output(0, dpf.types.meshes_container) -# meshes_cont.plot(title='Meshes Container', text='Meshes Container plot') -# # A fields_container can be given as input, with results on each part of our split mesh. -# disp_op = dpf.Operator("U") -# disp_op.connect(7, meshes_cont) -# ds = dpf.DataSources(examples.find_multishells_rst()) -# disp_op.connect(4, ds) -# disp_fc = disp_op.outputs.fields_container() -# meshes_cont.plot(disp_fc, title='Meshes Container disp_fc', text='Meshes Container disp_fc plot') -# # Additional PyVista kwargs are supported, such as: -# meshes_cont.plot(off_screen=True, notebook=False, screenshot='meshes_cont_plot.png', -# title='Meshes Container', text='Meshes Container plot') + +# One can also plot a MeshesContainer. Here our mesh is split by material. +split_mesh_op = dpf.Operator("split_mesh") +split_mesh_op.connect(7, mesh) +split_mesh_op.connect(13, "mat") +meshes_cont = split_mesh_op.get_output(0, dpf.types.meshes_container) +meshes_cont.plot(title='Meshes Container', text='Meshes Container plot') +# A fields_container can be given as input, with results on each part of our split mesh. +disp_op = dpf.Operator("U") +disp_op.connect(7, meshes_cont) +ds = dpf.DataSources(examples.find_multishells_rst()) +disp_op.connect(4, ds) +disp_fc = disp_op.outputs.fields_container() +meshes_cont.plot(disp_fc, title='Meshes Container disp_fc', text='Meshes Container disp_fc plot') +# Additional PyVista kwargs are supported, such as: +meshes_cont.plot(off_screen=True, notebook=False, screenshot='meshes_cont_plot.png', + title='Meshes Container', text='Meshes Container plot') From fdedf495d6b9f3a1e691c6d7c443d9e747be8cd0 Mon Sep 17 00:00:00 2001 From: "paul.profizi" Date: Thu, 23 Nov 2023 11:34:11 +0100 Subject: [PATCH 2/2] Remove notebook argument from kwargs to prevent useless warning --- src/ansys/dpf/core/meshed_region.py | 1 + src/ansys/dpf/core/meshes_container.py | 1 + src/ansys/dpf/core/model.py | 1 + 3 files changed, 3 insertions(+) diff --git a/src/ansys/dpf/core/meshed_region.py b/src/ansys/dpf/core/meshed_region.py index 7dfefe091c..f2cf49ab23 100644 --- a/src/ansys/dpf/core/meshed_region.py +++ b/src/ansys/dpf/core/meshed_region.py @@ -583,6 +583,7 @@ def plot( show_axes=kwargs.pop("show_axes", True), **kwargs, ) + kwargs.pop("notebook", None) return pl.show_figure(**kwargs) def deep_copy(self, server=None): diff --git a/src/ansys/dpf/core/meshes_container.py b/src/ansys/dpf/core/meshes_container.py index 49af566c8a..8cd50c0f32 100644 --- a/src/ansys/dpf/core/meshes_container.py +++ b/src/ansys/dpf/core/meshes_container.py @@ -114,6 +114,7 @@ def plot(self, fields_container=None, deform_by=None, scale_factor=1.0, **kwargs **kwargs, ) # Plot the figure + kwargs.pop("notebook", None) return pl.show_figure(**kwargs) def get_meshes(self, label_space): diff --git a/src/ansys/dpf/core/model.py b/src/ansys/dpf/core/model.py index f1bb34e21d..0659b7f752 100644 --- a/src/ansys/dpf/core/model.py +++ b/src/ansys/dpf/core/model.py @@ -237,6 +237,7 @@ def plot(self, color="w", show_edges=True, **kwargs): kwargs["show_edges"] = show_edges pl = DpfPlotter(**kwargs) pl.add_mesh(self.metadata.meshed_region, show_axes=kwargs.pop("show_axes", True), **kwargs) + kwargs.pop("notebook", None) return pl.show_figure(**kwargs) @property