Nodes

class ansys.dpf.core.nodes.Node(mesh, nodeid, index, coordinates)
A node of the mesh. Encapsulates all the properties of a node:

its id, index, coordinates…

Created from Elements or a MeshedRegion.

Examples

>>> import ansys.dpf.core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.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 in the model (int starting at 0)

property id: int

Node number

property coordinates

Cartesian coordinates of the node.

Examples

>>> node.coordinates
[0.015, 0.045, 0.015]
property nodal_connectivity

Elements indices connected to the given node

Returns

nodal_connectivity

Return type

numpy.array

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

Collection of DPF Nodes.

Created from a MeshedRegion

Examples

>>> import ansys.dpf.core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.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 index

node_by_index(index)

Array of node coordinates ordered by index

property scoping

Return the scoping of the Nodes

Returns

scoping – Scoping of the Nodes

Return type

Scoping

Examples

Get the ids of all the nodes in this collection

>>> nodes.scoping.ids[2]
3
property n_nodes

Number of nodes

property coordinates_field

Coordinates field

Returns

coordinates_field – field of all the nodes coordinates

Return type

Field

Examples

>>> coordinates = nodes.coordinates_field
>>> # Extract the array of coordinates the coordinates field
>>> nodes.coordinates_field.data[2]
array([0.015, 0.045, 0.03 ])
property nodal_connectivity_field

field containing for each node id the elements indices connected to the given node

Returns

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

Return type

PropertyField

Examples

>>> field = nodes.nodal_connectivity_field
>>> field.get_entity_data(1)
array([0, 2, 4, 6])
Type

Nodal connectivity field

map_scoping(external_scope)

Return 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

Return 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.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 nodes.coordinates to match the order of the field data. That way the field data matches the order of the nodes in the meshed_region

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

Appends a new node in the mesh

Parameters
  • id (int) – new node’s id

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

add_nodes(num)

Add num new nodes in the mesh. add_nodes yields num nodes that the user can fill

Parameters

num (int) – number of nodes to add

Returns

yield node – node to add

Return type

NodeAdder

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

A class used to add new nodes into a meshed region

id
Type

int

coordinates

x, y, z coordinates

Type

list of doubles

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

Node id