44Create a mesh from scratch
55==========================
66
7- .. |Field | replace :: :class: `Field<ansys.dpf.core.field.Field> `
8- .. |FieldsContainer | replace :: :class: `FieldsContainer<ansys.dpf.core.fields_container.FieldsContainer> `
9- .. |MeshedRegion | replace :: :class: `MeshedRegion <ansys.dpf.core.meshed_region.MeshedRegion> `
10- .. |Model | replace :: :class: `Model <ansys.dpf.core.model.Model> `
7+ .. include :: ../../../links_and_refs.rst
118
12- The mesh object in DPF is a |MeshedRegion |. You can create your own |MeshedRegion | object to use DPF operators
13- with your own data. The ability to use scripting to create any DPF entity means
9+ This tutorial demonstrates how to build a |MeshedRegion | from the scratch.
10+
11+ The mesh object in DPF is a |MeshedRegion |. You can create your own |MeshedRegion | object and use it
12+ with DPF operators. The ability to use scripting to create any DPF entity means
1413that you are not dependent on result files and can connect the DPF environment
1514with any Python tool.
1615
17- This tutorial demonstrates how to build a | MeshedRegion | from the scratch .
16+ Here, we create a parallel piped mesh made of linear hexa elements .
1817
19- Here we create a parallel piped mesh made of linear hexa elements.
18+ :jupyter-download-script: `Download tutorial as Python script<create_a_mesh_from_scratch> `
19+ :jupyter-download-notebook: `Download tutorial as notebook<create_a_mesh_from_scratch> `
2020
2121Import the necessary modules
2222----------------------------
2323
24- Import the ``ansys.dpf.core `` module, including the operators subpackage and the numpy library
24+ Import the ``ansys.dpf.core `` module, including the operators subpackage and the numpy library.
2525
2626.. jupyter-execute ::
2727
28+ # Import the numpy library
2829 import numpy as np
30+ # Import the ``ansys.dpf.core `` module
2931 from ansys.dpf import core as dpf
32+ # Import the operators subpackage
3033 from ansys.dpf.core import operators as ops
3134
3235Define the mesh dimensions
@@ -47,10 +50,10 @@ Define the mesh dimensions
4750Define the connectivity function
4851--------------------------------
4952
50- To create a mesh we need to define the nodes connectivity. This means to define
51- the elements and nodes indices connected to each node.
53+ To create a mesh you must define the nodes connectivity. This means to define
54+ the nodes ids connected to each node.
5255
53- Here we create a function that will find the connectivity of our entities .
56+ Here we create a function that will find this connectivity.
5457
5558.. jupyter-execute ::
5659
@@ -66,7 +69,7 @@ Here we create a function that will find the connectivity of our entities.
6669Add nodes
6770---------
6871
69- Add nodes to the |MeshedRegion | object:
72+ Add | Nodes | to the |MeshedRegion | object.
7073
7174.. jupyter-execute ::
7275
@@ -83,34 +86,35 @@ Add nodes to the |MeshedRegion| object:
8386 my_meshed_region.nodes.add_node(node_id, [x, y, z])
8487 node_id += 1
8588
86- Get the nodes coordinates field
89+ Get the nodes coordinates field.
8790
8891.. jupyter-execute ::
8992
9093 my_nodes_coordinates = my_meshed_region.nodes.coordinates_field
9194
92- Set the mesh node properties
93- ----------------------------
95+ Set the mesh properties
96+ -----------------------
9497
95- Set the mesh unit:
98+ Set the mesh unit.
9699
97100.. jupyter-execute ::
98101
99102 my_meshed_region.unit = "mm"
100103
101- Set the nodes coordinates:
104+ Set the nodes coordinates.
102105
103106.. jupyter-execute ::
104107
105108 # Get the nodes coordinates data
106109 my_nodes_coordinates_data = my_nodes_coordinates.data
107110 # As we use the connectivity function we need to get the data as a list
108111 my_nodes_coordinates_data_list = my_nodes_coordinates.data_as_list
109- # Get the nodes scoping
112+ # Set the nodes scoping
110113 my_coordinates_scoping = my_nodes_coordinates.scoping
111114
112- Add the elements
113- ----------------
115+ Add elements
116+ ------------
117+ Add |Elements | to the |MeshedRegion | object.
114118
115119.. jupyter-execute ::
116120
@@ -141,9 +145,11 @@ Add the elements
141145 connectivity[7] = tmp
142146 my_meshed_region.elements.add_solid_element(element_id, connectivity)
143147 element_id += 1
148+
144149Plot the mesh
145150-------------
146151
147152.. jupyter-execute ::
148153
154+ # Plot the mesh you created
149155 my_meshed_region.plot()
0 commit comments