Elements
#
- class ansys.dpf.core.elements.Elements(mesh)#
Contains elements belonging to a meshed region.
- Parameters:
mesh (str) – Name of the meshed region.
Examples
>>> import ansys.dpf.core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_static_rst()) >>> elements = model.metadata.meshed_region.elements >>> elements.n_elements 8
Overview#
Retrieve an element by element ID. |
|
Retrieve an element using its index. |
|
Add one or more elements in the mesh. |
|
Add a solid 3D element in the mesh. |
|
Add a shell 2D element in the mesh. |
|
Add a beam 1D element in the mesh. |
|
Add a point element (one node connectivity) in the mesh. |
|
Add an element in the mesh. |
|
Retrieve the indices to map the scoping of these elements to the scoping of a field. |
Scoping of the elements. |
|
Field of all element types. |
|
Field of all material IDs. |
|
Field containing for each element ID the node indices connected to the element. |
|
Number of elements. |
|
Mapping between the IDs and indices of the entity. |
|
Whether at least one element is a 2D element (shell). |
|
Whether at list one element is a 3D element (solid). |
|
Whether at least one element is a 1D beam element. |
|
Whether at least one element is a point element. |
Provide a custom string representation. |
|
Retrieve element based on an index. |
|
Retrieve the number of elements. |
|
Provide for looping through the elements in loops. |
Import detail#
from ansys.dpf.core.elements import Elements
Property detail#
- property Elements.scoping: scoping.Scoping#
Scoping of the elements.
- Return type:
Examples
>>> import ansys.dpf.core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_static_rst()) >>> elements = model.metadata.meshed_region.elements >>> my_scoping = elements.scoping
- property Elements.element_types_field#
Field of all element types.
- Returns:
Field of all element types.
- Return type:
Examples
>>> import ansys.dpf.core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_static_rst()) >>> elements = model.metadata.meshed_region.elements >>> field = elements.element_types_field >>> print(field.data) [1 1 1 1 1 1 1 1]
- property Elements.materials_field#
Field of all material IDs.
- Returns:
Field of all materials IDs.
- Return type:
Examples
Extract the material IDs from the materials_field
>>> import ansys.dpf.core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_static_rst()) >>> elements = model.metadata.meshed_region.elements >>> print(elements.materials_field.data) [1 1 1 1 1 1 1 1]
- property Elements.connectivities_field#
Field containing for each element ID the node indices connected to the element.
- Returns:
Field containing for each element ID the node indices connected to the element.
- Return type:
Examples
>>> import ansys.dpf.core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_static_rst()) >>> elements = model.metadata.meshed_region.elements >>> field = elements.connectivities_field >>> field.get_entity_data(1) DPFArray([ 0, 11, 13, 25, 2, 9, 8, 3, 29, 58, 63, 32, 40, 52, 42, 37, 28, 55, 53, 43]...
- property Elements.n_elements: int#
Number of elements.
- property Elements.mapping_id_to_index: dict#
Mapping between the IDs and indices of the entity.
This property is useful for mapping scalar results from a field to the meshed region.
Examples
>>> import ansys.dpf.core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_simple_bar()) >>> meshed_region = model.metadata.meshed_region >>> map = meshed_region.nodes.mapping_id_to_index
- property Elements.has_shell_elements: bool#
Whether at least one element is a 2D element (shell).
- Return type:
bool
- property Elements.has_solid_elements: bool#
Whether at list one element is a 3D element (solid).
- Return type:
bool
- property Elements.has_beam_elements: bool#
Whether at least one element is a 1D beam element.
- Return type:
bool
- property Elements.has_point_elements: bool#
Whether at least one element is a point element.
- Return type:
bool
Method detail#
- Elements.__str__()#
Provide a custom string representation.
- Elements.__getitem__(index)#
Retrieve element based on an index.
- Elements.__len__()#
Retrieve the number of elements.
- Elements.__iter__()#
Provide for looping through the elements in loops.
- Elements.element_by_id(id) Element #
Retrieve an element by element ID.
- Parameters:
id (int) – Number (ID) of the element.
- Returns:
Element object.
- Return type:
- Elements.element_by_index(index) Element #
Retrieve an element using its index.
- Parameters:
index (int) – Zero-based index.
- Returns:
Yield element.
- Return type:
Examples
elements.element_by_index(0)
Notes
This is equivalent to
elements[0]
- Elements.add_elements(num)#
Add one or more elements in the mesh.
- Parameters:
num (int) – Number of elements to add in the mesh.
- Returns:
Elements added to the mesh.
- Return type:
Examples
>>> import ansys.dpf.core as dpf >>> meshed_region = dpf.MeshedRegion(num_nodes=4,num_elements=3) >>> i=0 >>> for node in meshed_region.nodes.add_nodes(4): ... node.id = i+1 ... node.coordinates = [float(i), float(i), 0.0] ... i=i+1 >>> i=0 >>> for element in meshed_region.elements.add_elements(3): ... element.id=i+1 ... element.connectivity = [i, i+1] ... element.is_beam=True #or is_solid, is_beam, is_point ... i=i+1
- Elements.add_solid_element(id, connectivity)#
Add a solid 3D element in the mesh.
- Parameters:
id (int) – ID to assign the new element.
connectivity (list) – List of the node indices to connect to the new element.
- Elements.add_shell_element(id, connectivity)#
Add a shell 2D element in the mesh.
- Parameters:
id (int) – ID to assign the new element.
connectivity (list) – List of the node indices to connect to the new element.
- Elements.add_beam_element(id, connectivity)#
Add a beam 1D element in the mesh.
- Parameters:
id (int) – ID to assign the new element.
connectivity (list) – List of the node indices to connect to the new element.
- Elements.add_point_element(id, connectivity)#
Add a point element (one node connectivity) in the mesh.
- Parameters:
id (int) – ID to assign the new element.
connectivity (list) – List of the node indices to connect to the new element.
- Elements.add_element(id, shape, connectivity)#
Add an element in the mesh.
- Parameters:
id (int) – ID to assign the new element.
shape (str) – Shape of the element. Options are
"solid"
,"shell"
,"beam"
and"unknown_shape"
.connectivity (list) – List of the node indices to connect to the new element.
- Elements.map_scoping(external_scope)#
Retrieve the indices to map the scoping of these elements to the scoping of a field.
- Parameters:
external_scope (
ansys.dpf.core.scoping.Scoping
) – Scoping to map to.- Returns:
indices (numpy.ndarray) – List of indices to map from the external scope to the scoping of these elements.
mask (numpy.ndarray) – Members of the external scope that are in the element scoping.
Examples
Return the indices that map a field to an elements collection.
>>> import ansys.dpf.core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_static_rst()) >>> elements = model.metadata.meshed_region.elements >>> vol = model.results.elemental_volume() >>> field = vol.outputs.fields_container()[0] >>> ind, mask = elements.map_scoping(field.scoping)