Nodes#

class ansys.dpf.core.nodes.Nodes(mesh)#

Provides a collection of DPF nodes.

Parameters:

mesh (ansys.dpf.core.meshed_region class) – Mesh region that the collection is created from.

Examples

>>> import ansys.dpf.core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.find_static_rst())
>>> meshed_region = model.metadata.meshed_region
>>> nodes = model.metadata.meshed_region.nodes
>>> nodes.n_nodes
81

Overview#

node_by_id

Array of node coordinates ordered by ID.

node_by_index

Array of node coordinates ordered by index.

map_scoping

Retrieve the indices to map the scoping of these elements to the scoping of a field.

add_node

Add a node in the mesh.

add_nodes

Add a number of nodes in the mesh.

scoping

Scoping of the nodes.

n_nodes

Number of nodes.

coordinates_field

Coordinates field.

nodal_connectivity_field

Nodal connectivity field.

mapping_id_to_index

Property storing mapping between IDs and indices of the entity.

__str__

Return custom str representation with information about number of nodes.

__getitem__

Return node based on index.

__len__

Return the number of nodes.

__iter__

Provide for iterating through the nodes.

Import detail#

from ansys.dpf.core.nodes import Nodes

Property detail#

property Nodes.scoping#

Scoping of the nodes.

Returns:

scoping – Scoping of the nodes.

Return type:

Scoping

Examples

Get the IDs of all nodes in this collection.

>>> import ansys.dpf.core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.find_static_rst())
>>> meshed_region = model.metadata.meshed_region
>>> nodes = model.metadata.meshed_region.nodes
>>> nodes.scoping.ids[2]
np.int32(3)
property Nodes.n_nodes#

Number of nodes.

property Nodes.coordinates_field#

Coordinates field.

Returns:

coordinates_field – Field with all the coordinates for the nodes.

Return type:

Field

Examples

>>> import ansys.dpf.core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.find_static_rst())
>>> meshed_region = model.metadata.meshed_region
>>> nodes = model.metadata.meshed_region.nodes
>>> coordinates = nodes.coordinates_field
>>> # Extract the array of coordinates the coordinates field
>>> nodes.coordinates_field.data[2]
DPFArray([0.015, 0.045, 0.03 ]...
property Nodes.nodal_connectivity_field#

Nodal connectivity field.

Field containing each node ID for the elements indices connected to the given node.

Returns:

nodal_connectivity_field – Field of the element indices associated with each node.

Return type:

PropertyField

Examples

>>> import ansys.dpf.core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.find_static_rst())
>>> meshed_region = model.metadata.meshed_region
>>> nodes = model.metadata.meshed_region.nodes
>>> field = nodes.nodal_connectivity_field
>>> field.get_entity_data(1)
DPFArray([0, 2, 4, 6]...
property Nodes.mapping_id_to_index#

Property storing mapping between IDs and indices of the entity.

Method detail#

Nodes.__str__()#

Return custom str representation with information about number of nodes.

Nodes.__getitem__(index)#

Return node based on index.

Nodes.__len__()#

Return the number of nodes.

Nodes.__iter__()#

Provide for iterating through the nodes.

Nodes.node_by_id(id)#

Array of node coordinates ordered by ID.

Nodes.node_by_index(index)#

Array of node coordinates ordered by index.

Nodes.map_scoping(external_scope)#

Retrieve the indices to map the scoping of these elements to the scoping of a field.

Parameters:

external_scope (scoping.Scoping) – Scoping to map to.

Returns:

  • indices (numpy.ndarray) – List of indices to map from the external scope to the scoping of these nodes.

  • mask (numpy.ndarray) – Members of the external scope that are in the node scoping.

Examples

Retrieve the indices that map a field to a nodes collection.

>>> import ansys.dpf.core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.find_static_rst())
>>> nodes = model.metadata.meshed_region.nodes
>>> disp = model.results.displacement()
>>> field = disp.outputs.fields_container()[0]
>>> ind, mask = nodes.map_scoping(field.scoping)

These indices can then be used to remap the coordinates of the nodes to match the order of the field data. This way, the field data matches the order of the nodes in the ansys.dpf.core.meshed_region class.

>>> mapped_nodes = nodes.coordinates_field.data[ind]
Nodes.add_node(id, coordinates)#

Add a node in the mesh.

Parameters:
  • id (int) – ID for the new node.

  • coordinates (list[float]) – List of [x, y, z] coordinates for the node.

Nodes.add_nodes(num)#

Add a number of nodes in the mesh.

This method yields a number of nodes that you can define.

Parameters:

num (int) – Number of nodes to add.

Yields:

yield node (NodeAdder) – Node to add

Examples

>>> import ansys.dpf.core as dpf
>>> meshed_region = dpf.MeshedRegion(num_nodes=4,num_elements=3)
>>> for i, node in enumerate(meshed_region.nodes.add_nodes(4)):
...     node.id = i+1
...     node.coordinates = [float(i), float(i), 0.0]