@@ -233,6 +233,7 @@ def add_field(
233233 scale_factor = 1.0 ,
234234 scale_factor_legend = None ,
235235 as_linear = True ,
236+ shell_layer = eshell_layers .top ,
236237 ** kwargs ,
237238 ):
238239 # Get the field name
@@ -275,6 +276,21 @@ def add_field(
275276 mesh_location = meshed_region .elements
276277 else :
277278 raise ValueError ("Only elemental, nodal or faces location are supported for plotting." )
279+
280+ # Treat multilayered shells
281+ if not isinstance (shell_layer , eshell_layers ):
282+ raise TypeError ("shell_layer attribute must be a core.shell_layers instance." )
283+ if field .shell_layers in [
284+ eshell_layers .topbottom ,
285+ eshell_layers .topbottommid ,
286+ ]:
287+ change_shell_layer_op = core .operators .utility .change_shell_layers ()
288+ change_shell_layer_op .inputs .fields_container .connect (field )
289+ change_shell_layer_op .inputs .e_shell_layer .connect (
290+ shell_layer .value
291+ ) # top layers taken
292+ field = change_shell_layer_op .get_output (0 , core .types .field )
293+
278294 component_count = field .component_count
279295 if component_count > 1 :
280296 overall_data = np .full ((len (mesh_location ), component_count ), np .nan )
@@ -603,6 +619,7 @@ def add_field(
603619 label_point_size = 20 ,
604620 deform_by = None ,
605621 scale_factor = 1.0 ,
622+ shell_layer = eshell_layers .top ,
606623 ** kwargs ,
607624 ):
608625 """Add a field containing data to the plotter.
@@ -627,6 +644,9 @@ def add_field(
627644 Defaults to None.
628645 scale_factor : float, optional
629646 Scaling factor to apply when warping the mesh. Defaults to 1.0.
647+ shell_layer: core.shell_layers, optional
648+ Enum used to set the shell layer if the field to plot
649+ contains shell elements. Defaults to top layer.
630650 **kwargs : optional
631651 Additional keyword arguments for the plotter. More information
632652 are available at :func:`pyvista.plot`.
@@ -653,6 +673,7 @@ def add_field(
653673 deform_by = deform_by ,
654674 scale_factor = scale_factor ,
655675 as_linear = True ,
676+ shell_layer = eshell_layers .top ,
656677 ** kwargs ,
657678 )
658679
0 commit comments