@@ -183,15 +183,19 @@ def __str__(self):
183183 # self._message = skin.get_output(0, types.meshed_region)
184184 # return MeshedRegion(self._channel, skin, self._model, name)
185185
186- def _as_vtk (self , as_linear = True ):
186+ def _as_vtk (self , as_linear = True , include_ids = False ):
187187 """Convert DPF mesh to a pyvista unstructured grid"""
188188 from ansys .dpf .core .vtk_helper import dpf_mesh_to_vtk
189189 nodes = self .nodes .coordinates_field .data
190190 etypes = self .elements .element_types_field .data
191191 conn = self .elements .connectivities_field .data
192192 grid = dpf_mesh_to_vtk (nodes , etypes , conn , as_linear )
193- grid ['node_ids' ] = self .nodes .scoping .ids
194- grid ['element_ids' ] = self .elements .scoping .ids
193+
194+ # consider adding this when scoping request is faster
195+ if include_ids :
196+ grid ['node_ids' ] = self .nodes .scoping .ids
197+ grid ['element_ids' ] = self .elements .scoping .ids
198+
195199 return grid
196200
197201 @property
@@ -290,7 +294,8 @@ def plot(self, field_or_fields_container=None, notebook=None,
290294 off_screen , show_axes , ** kwargs )
291295
292296 # otherwise, simply plot self
293- return pl .plot_mesh (notebook )
297+ kwargs ['notebook' ] = notebook
298+ return pl .plot_mesh (** kwargs )
294299
295300
296301class Node :
@@ -642,13 +647,13 @@ def mapping_id_to_index(self):
642647 self ._mapping_id_to_index = self ._build_mapping_id_to_index ()
643648 return self ._mapping_id_to_index
644649
645- def map_scoping (self , scope ):
650+ def map_scoping (self , external_scope ):
646651 """Return the indices to map the scoping of these elements to
647652 the scoping of a field.
648653
649654 Parameters
650655 ----------
651- scope : scoping.Scoping
656+ external_scope : scoping.Scoping
652657 Scoping to map to.
653658
654659 Returns
@@ -657,6 +662,9 @@ def map_scoping(self, scope):
657662 List of indices to map from the external scope to the
658663 scoping of these nodes.
659664
665+ mask : numpy.ndarray
666+ Members of the external scope that are in the node scoping.
667+
660668 Examples
661669 --------
662670 Return the indices that map a field to a nodes collection.
@@ -667,9 +675,10 @@ def map_scoping(self, scope):
667675 >>> nodes = model.metadata.meshed_region.nodes
668676 >>> disp = model.results.displacements()
669677 >>> field = disp.outputs.field_containers()[0]
670- >>> ind = nodes.map_scoping(field.scoping)
671- >>> ind
678+ >>> ind, mask = nodes.map_scoping(field.scoping)
679+ >>> ind, mask
672680 array([ 508, 509, 909, ..., 3472, 3471, 3469])
681+ array([True, True, True, ..., True, True, True])
673682
674683 These indices can then be used to remap ``nodes.coordinates`` to
675684 match the order of the field data. That way the field data matches the
@@ -678,10 +687,12 @@ def map_scoping(self, scope):
678687 >>> mapped_nodes = nodes.coordinates[ind]
679688
680689 """
681- if scope .location in ['Elemental' , 'NodalElemental' ]:
690+ if external_scope .location in ['Elemental' , 'NodalElemental' ]:
682691 raise ValueError ('Input scope location must be "Nodal"' )
683- return np .array (list (map (self .mapping_id_to_index .get , scope .ids )))
684-
692+ arr = np .array (list (map (self .mapping_id_to_index .get , external_scope .ids )))
693+ mask = arr != None
694+ ind = arr [mask ].astype (np .int )
695+ return ind , mask
685696
686697class Elements ():
687698 """Elements belonging to a ``meshed_region``.
@@ -899,13 +910,13 @@ def mapping_id_to_index(self) -> dict:
899910 self ._mapping_id_to_index = self ._build_mapping_id_to_index ()
900911 return self ._mapping_id_to_index
901912
902- def map_scoping (self , scope ):
913+ def map_scoping (self , external_scope ):
903914 """Return the indices to map the scoping of these elements to
904915 the scoping of a field.
905916
906917 Parameters
907918 ----------
908- scope : scoping.Scoping
919+ external_scope : scoping.Scoping
909920 Scoping to map to.
910921
911922 Returns
@@ -914,6 +925,9 @@ def map_scoping(self, scope):
914925 List of indices to map from the external scope to the
915926 scoping of these elements.
916927
928+ mask : numpy.ndarray
929+ Members of the external scope that are in the element scoping.
930+
917931 Examples
918932 --------
919933 Return the indices that map a field to an elements collection.
@@ -924,7 +938,7 @@ def map_scoping(self, scope):
924938 >>> elements = model.metadata.meshed_region.elements
925939 >>> vol = model.results.volume()
926940 >>> field = vol.outputs.field_containers()[0]
927- >>> ind = elements.map_scoping(field.scoping)
941+ >>> ind, mask = elements.map_scoping(field.scoping)
928942 >>> ind
929943 [66039
930944 11284,
@@ -942,6 +956,9 @@ def map_scoping(self, scope):
942956 >>> mapped_data = field.data[ind]
943957
944958 """
945- if scope .location in ['Nodal' , 'NodalElemental' ]:
946- raise ValueError ('Input scope location must be "Elemental"' )
947- return np .array (list (map (self .mapping_id_to_index .get , scope .ids )))
959+ if external_scope .location in ['Nodal' , 'NodalElemental' ]:
960+ raise ValueError ('Input scope location must be "Nodal"' )
961+ arr = np .array (list (map (self .mapping_id_to_index .get , external_scope .ids )))
962+ mask = arr != None
963+ ind = arr [mask ].astype (np .int )
964+ return ind , mask
0 commit comments