Nodes#

class ansys.dpf.core.nodes.Node(mesh, nodeid, index, coordinates)#

Encapsulates all properties of a node in the mesh.

A node is created from the ansys.dpf.core.elements or ansys.dpf.core.meshed_region class.

Parameters:
  • mesh (ansys.dpf.core.meshed_region class) – Mesh region that the node is contained in.

  • nodeid (int) – ID of the node.

  • index (int) – Index of the node.

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

Examples

>>> 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
>>> # Initialize a node from a nodes collection
>>> node = nodes[0]

Initialize a node from an element.

>>> element = model.metadata.meshed_region.elements[0]
>>> node = element.nodes[0]
property index: int#

Index of the node. The index starts at 0.

property id: int#

ID of the node.

property coordinates#

Cartesian coordinates of the node.

Examples

>>> import ansys.dpf.core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.find_static_rst())
>>> node = model.metadata.meshed_region.nodes[0]
>>> node.coordinates
[0.015, 0.045, 0.015]
property nodal_connectivity#

Elements indices connected to the node.

Returns:

nodal_connectivity

Return type:

numpy.array

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
node_by_id(id)#

Array of node coordinates ordered by ID.

node_by_index(index)#

Array of node coordinates ordered by index

property 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 n_nodes#

Number of nodes.

property 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 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]...
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]
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.

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]
class ansys.dpf.core.nodes.NodeAdder#

Adds a new node to a meshed region.

Examples

Create a meshed region from scratch.

>>> import ansys.dpf.core as dpf
>>> meshed_region = dpf.MeshedRegion(num_nodes=4,num_elements=1)
>>> 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
property id#

ID of the node.

property coordinates#

Coordinates of the node.