Module containing the Mesh
class.
Mesh#
- class ansys.dpf.post.mesh.Mesh(meshed_region: MeshedRegion)#
Exposes the complete mesh of the simulation.
- property named_selections: NamedSelections#
Returns a dictionary of available named selections for this mesh.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.named_selections) NamedSelections dictionary with 1 named selections: - '_FIXEDSU'
- property node_ids: List[int]#
Returns the list of node IDs in the mesh.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.node_ids) [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81]
- property num_nodes: int#
Returns the number of nodes in the mesh.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.num_nodes) 81
- property element_ids: List[int]#
Returns the list of element IDs in the mesh.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.element_ids) [5 6 1 2 7 8 3 4]
- property num_elements: int#
Returns the number of elements in the mesh.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.num_elements) 8
- property elements: ElementListByIndex#
Returns a list of elements indexed by ID.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.elements) [hex20, ..., hex20]
- get_element_by_id(id: int)#
Returns an element in the mesh from a given ID.
- Return type:
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.get_element_by_id(1)) DPF Element 1 Index: 2 Nodes: 20 Type: Hex20 Shape: Solid
- property num_faces: int#
Returns the number of faces in the mesh.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> files = examples.download_fluent_axial_comp() >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) >>> print(simulation.mesh.num_faces) 44242
- property face_ids: List[int]#
Returns the list of face IDs in the mesh.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> files = examples.download_fluent_axial_comp() >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) >>> print(simulation.mesh.face_ids) [ 1003 1004 1005 ... 45165 45166 45167]
- property faces: FaceListByIndex#
Returns a list of faces indexed by ID.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> files = examples.download_fluent_axial_comp() >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) >>> print(simulation.mesh.faces) [quad4, ..., quad4]
- property nodes: NodeListByIndex#
Returns a list of nodes indexed by ID.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.nodes) [Node(id=1, coordinates=[0.015, 0.045, 0.015]), ..., Node(id=81, coordinates=[0.03, 0.045, 0.0075])]
- get_node_by_id(id: int)#
Returns a node of the mesh from a given ID.
- Return type:
Node
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.get_node_by_id(1)) Node(id=1, coordinates=[0.015, 0.045, 0.015])
- property element_types: DataFrame#
Returns a DataFrame containing element types ID.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.element_types) results elem_type_id element_ids 5 1 6 1 1 1 2 1 7 1 8 1 ... ...
- property materials: DataFrame#
Returns a DataFrame containing element materials ID.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.materials) results material_id element_ids 5 1 6 1 1 1 2 1 7 1 8 1 ... ...
- property element_to_node_ids_connectivity: ConnectivityListByIndex#
Returns a connectivity map between element index and node IDs.
To get the connectivity map by element ID, use the ‘by_id’ property of the object returned.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> element_to_node_ids_connectivity = simulation.mesh.element_to_node_ids_connectivity >>> print(element_to_node_ids_connectivity[0]) [1, 26, 14, 12, 2, 27, 15, 13, 33, 64, 59, 30, 37, 65, 61, 34, 28, 81, 63, 58] >>> element_to_node_ids_connectivity_by_id = element_to_node_ids_connectivity.by_id >>> print(element_to_node_ids_connectivity[1]) [1, 12, 14, 26, 3, 10, 9, 4, 30, 59, 64, 33, 41, 53, 43, 38, 29, 56, 54, 44]
- property node_to_element_ids_connectivity: ConnectivityListByIndex#
Returns a connectivity map between node index and element IDs.
To get the connectivity map by node ID, use the ‘by_id’ property of the object returned.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> node_to_element_ids_connectivity = simulation.mesh.node_to_element_ids_connectivity >>> print(node_to_element_ids_connectivity[0]) [5, 6, 1, 2, 7, 8, 3, 4] >>> node_to_element_ids_connectivity_by_id = node_to_element_ids_connectivity.by_id >>> print(node_to_element_ids_connectivity_by_id[1]) [5, 6, 1, 2, 7, 8, 3, 4]
- property element_to_node_connectivity: ConnectivityListByIndex#
Returns a connectivity map between element index and node indexes.
To get the connectivity map by element ID, use the ‘by_id’ property of the object returned.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> element_to_node_connectivity = simulation.mesh.element_to_node_connectivity >>> print(element_to_node_connectivity[0]) [0, 25, 13, 11, 1, 26, 14, 12, 32, 63, 58, 29, 36, 64, 60, 33, 27, 80, 62, 57] >>> element_to_node_connectivity_by_id = element_to_node_connectivity.by_id >>> print(element_to_node_connectivity_by_id[1]) [0, 17, 19, 25, 1, 18, 20, 26, 30, 69, 74, 32, 34, 71, 75, 36, 27, 68, 73, 80]
- property node_to_element_connectivity: ConnectivityListByIndex#
Returns a connectivity map between node index and element indexes.
To get the connectivity map by node ID, use the ‘by_id’ property of the object returned.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> node_to_element_connectivity = simulation.mesh.node_to_element_connectivity >>> print(node_to_element_connectivity[0]) [0, 1, 2, 3, 4, 5, 6, 7] >>> node_to_element_connectivity_by_id = node_to_element_connectivity.by_id >>> print(node_to_element_connectivity_by_id[1]) [0, 1, 2, 3, 4, 5, 6, 7]
- property face_to_node_ids_connectivity: ConnectivityListByIndex#
Returns a connectivity map between face index and node IDs.
To get the connectivity map by face ID, use the ‘by_id’ property of the object returned.
- property face_to_node_connectivity: ConnectivityListByIndex#
Returns a connectivity map between face index and node indexes.
To get the connectivity map by face ID, use the ‘by_id’ property of the object returned.
- property unit: str#
Returns the unit of the mesh (same as coordinates of the mesh).
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> simulation = post.load_simulation(examples.static_rst) >>> print(simulation.mesh.unit) m
- plot(**kwargs)#
Plots the Mesh.
- Parameters:
kwargs – Additional keyword arguments for the plotter. For additional keyword arguments, see
help(pyvista.plot)
.- Return type:
A Plotter instance of the current plotting back-end.
Examples
>>> from ansys.dpf import post >>> from ansys.dpf.post import examples >>> from ansys.dpf.post.common import elemental_properties >>> example_path = examples.download_all_kinds_of_complexity() >>> simulation = post.StaticMechanicalSimulation(example_path) >>> mesh = simulation.mesh >>> mesh.plot()
- property coordinates: DataFrame#
Returns the nodal coordinates of the Mesh as a DataFrame.
Examples
>>> from ansys.dpf.post import StaticMechanicalSimulation >>> from ansys.dpf.post import examples >>> simulation = StaticMechanicalSimulation(examples.static_rst) >>> mesh = simulation.mesh >>> coord = mesh.coordinates >>> print(coord) results coord (m) node_ids components 1 X 1.5000e-02 Y 4.5000e-02 Z 1.5000e-02 2 X 1.5000e-02 Y 4.5000e-02 Z 0.0000e+00 ... ... ...