1
- .. _ tutorials_split_mesh :
1
+ .. _ ref_tutorials_split_mesh :
2
2
3
3
============
4
4
Split a mesh
5
5
============
6
6
7
7
:bdg-mapdl: `MAPDL ` :bdg-lsdyna: `LSDYNA ` :bdg-fluent: `Fluent ` :bdg-cfx: `CFX `
8
8
9
- This tutorial show how to split a mesh into different meshes.
9
+ .. include :: ../../../links_and_refs.rst
10
10
11
- .. |MeshedRegion | replace :: :class: `MeshedRegion <ansys.dpf.core.meshed_region.MeshedRegion> `
12
11
.. |MeshesContainer | replace :: :class: `MeshesContainer <ansys.dpf.core.meshes_container.MeshesContainer> `
13
12
.. |split_mesh | replace :: :class: `split_mesh <ansys.dpf.core.operators.mesh.split_mesh.split_mesh> `
14
13
.. |split_on_property_type | replace :: :class: `split_on_property_type <ansys.dpf.core.operators.scoping.split_on_property_type.split_on_property_type> `
15
14
.. |from_scopings | replace :: :class: `from_scopings <ansys.dpf.core.operators.mesh.from_scopings.from_scopings> `
16
- .. |DataSources | replace :: :class: `Model <ansys.dpf.core.data_sources.DataSources> `
17
- .. |Scoping | replace :: :class: `Scoping <ansys.dpf.core.scoping.Scoping> `
18
15
.. |ScopingsContainer | replace :: :class: `ScopingsContainer <ansys.dpf.core.scopings_container.ScopingsContainer> `
19
- .. |Examples | replace :: :mod: ` Examples <ansys.dpf.core.examples > `
16
+ .. |PropertyField | replace :: :class: ` PropertyField <ansys.dpf.core.property_field.PropertyField > `
20
17
21
- The mesh object in DPF is a | MeshedRegion |. If you want to split your mesh you can store them in a | MeshedRegion | .
18
+ This tutorial shows how to split a mesh on a give property .
22
19
23
- You have two approaches to split your mesh :
20
+ There are two approaches to accomplish this goal :
24
21
25
- 1) Using the |split_mesh |, to split a already existing |MeshedRegion | into a MeshesContainer;
26
- 2) Split the scoping with the |split_on_property_type | operator and than creating the |MeshedRegion |
27
- objects with the |from_scopings | operator.
22
+ - :ref: `Use the split_mesh operator to split a already existing MeshedRegion<ref_first_approach_split_mesh> `;
23
+ - :ref: `Split the mesh scoping and create the split MeshedRegion objects <ref_second_approach_split_mesh >`.
24
+
25
+ :jupyter-download-script: `Download tutorial as Python script<split_mesh> `
26
+ :jupyter-download-notebook: `Download tutorial as Jupyter notebook<split_mesh> `
28
27
29
28
Define the mesh
30
29
---------------
31
30
32
- The mesh object in DPF is a |MeshedRegion |. You can obtain a |MeshedRegion | by creating your
33
- own by scratch or by getting it from a result file. For more information check the
34
- :ref: ` tutorials_create_a_mesh_from_scratch ` and :ref: ` tutorials_get_mesh_from_result_file ` tutorials.
31
+ The mesh object in DPF is a |MeshedRegion |. You can obtain a |MeshedRegion | by creating your own from scratch or by getting it from a result file. For more
32
+ information check the :ref: ` ref_tutorials_create_a_mesh_from_scratch ` and :ref: ` ref_tutorials_get_mesh_from_result_file `
33
+ tutorials.
35
34
36
- In this part we will download simulation result files available
37
- in our | Examples | package .
35
+ For this tutorial, we get a | MeshedRegion | from a result file. You can use one available in the | Examples | module.
36
+ For more information see the :ref: ` ref_tutorials_get_mesh_from_result_file ` tutorial .
38
37
39
38
.. tab-set ::
40
39
41
40
.. tab-item :: MAPDL
42
41
43
42
.. jupyter-execute ::
44
43
45
- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
44
+ # Import the ``ansys.dpf.core `` module
46
45
from ansys.dpf import core as dpf
46
+ # Import the examples module
47
47
from ansys.dpf.core import examples
48
+ # Import the operators module
48
49
from ansys.dpf.core import operators as ops
49
- # Define the result file
50
+
51
+ # Define the result file path
50
52
result_file_path_1 = examples.find_multishells_rst()
51
53
# Create the model
52
- my_model_1 = dpf.Model(data_sources=result_file_path_1)
54
+ model_1 = dpf.Model(data_sources=result_file_path_1)
53
55
# Get the mesh
54
- my_meshed_region_1 = my_model_1 .metadata.meshed_region
56
+ meshed_region_1 = model_1 .metadata.meshed_region
55
57
56
58
.. tab-item :: LSDYNA
57
59
58
60
.. jupyter-execute ::
59
61
60
- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
62
+ # Import the ``ansys.dpf.core `` module
61
63
from ansys.dpf import core as dpf
64
+ # Import the examples module
62
65
from ansys.dpf.core import examples
66
+ # Import the operators module
63
67
from ansys.dpf.core import operators as ops
64
- # Define the result file
68
+
69
+ # Define the result file path
65
70
result_file_path_2 = examples.download_d3plot_beam()
66
71
# Create the DataSources object
67
- my_data_sources_2 = dpf.DataSources()
68
- my_data_sources_2 .set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
69
- my_data_sources_2 .add_file_path(filepath=result_file_path_2[3], key="actunits")
72
+ ds_2 = dpf.DataSources()
73
+ ds_2 .set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
74
+ ds_2 .add_file_path(filepath=result_file_path_2[3], key="actunits")
70
75
# Create the model
71
- my_model_2 = dpf.Model(data_sources=my_data_sources_2 )
76
+ model_2 = dpf.Model(data_sources=ds_2 )
72
77
# Get the mesh
73
- my_meshed_region_2 = my_model_2 .metadata.meshed_region
78
+ meshed_region_2 = model_2 .metadata.meshed_region
74
79
75
80
.. tab-item :: Fluent
76
81
77
82
.. jupyter-execute ::
78
83
79
- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
84
+ # Import the ``ansys.dpf.core `` module
80
85
from ansys.dpf import core as dpf
86
+ # Import the examples module
81
87
from ansys.dpf.core import examples
88
+ # Import the operators module
82
89
from ansys.dpf.core import operators as ops
83
- # Define the result file
90
+
91
+ # Define the result file path
84
92
result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
85
93
# Create the model
86
- my_model_3 = dpf.Model(data_sources=result_file_path_3)
94
+ model_3 = dpf.Model(data_sources=result_file_path_3)
87
95
# Get the mesh
88
- my_meshed_region_3 = my_model_3 .metadata.meshed_region
96
+ meshed_region_3 = model_3 .metadata.meshed_region
89
97
90
98
.. tab-item :: CFX
91
99
92
100
.. jupyter-execute ::
93
101
94
- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
102
+ # Import the ``ansys.dpf.core `` module
95
103
from ansys.dpf import core as dpf
104
+ # Import the examples module
96
105
from ansys.dpf.core import examples
106
+ # Import the operators module
97
107
from ansys.dpf.core import operators as ops
98
- # Define the result file
108
+
109
+ # Define the result file path
99
110
result_file_path_4 = examples.download_cfx_mixing_elbow()
100
111
# Create the model
101
- my_model_4 = dpf.Model(data_sources=result_file_path_4)
112
+ model_4 = dpf.Model(data_sources=result_file_path_4)
102
113
# Get the mesh
103
- my_meshed_region_4 = my_model_4.metadata.meshed_region
114
+ meshed_region_4 = model_4.metadata.meshed_region
115
+
116
+ .. _ref_first_approach_split_mesh :
104
117
105
- 1) First approach
106
- -----------------
118
+ First approach
119
+ --------------
107
120
108
- Use the |split_mesh | operator to split a already existing |MeshedRegion | into a MeshesContainer based on a property.
121
+ Use the |split_mesh | operator to split an already existing |MeshedRegion | based on a property.
109
122
Currently you can split a mesh by material or eltype.
110
123
124
+ When you split a |MeshedRegion | the split parts are stored in the DPF collection called |MeshesContainer |.
125
+
126
+ Here, we split the |MeshedRegion | by material.
127
+
111
128
.. tab-set ::
112
129
113
130
.. tab-item :: MAPDL
114
131
115
132
.. jupyter-execute ::
116
133
117
134
# Split the mesh by material
118
- my_meshes_11 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval()
135
+ meshes_11 = ops.mesh.split_mesh(mesh=meshed_region_1,property="mat").eval()
136
+
119
137
# Print the meshes
120
- print(my_meshes_11 )
138
+ print(meshes_11 )
121
139
122
140
.. tab-item :: LSDYNA
123
141
124
142
.. jupyter-execute ::
125
143
126
144
# Split the mesh by material
127
- my_meshes_21 = ops.mesh.split_mesh(mesh=my_meshed_region_2,property="mat").eval()
145
+ meshes_21 = ops.mesh.split_mesh(mesh=meshed_region_2,property="mat").eval()
146
+
128
147
# Print the meshes
129
- print(my_meshes_21 )
148
+ print(meshes_21 )
130
149
131
150
.. tab-item :: Fluent
132
151
133
152
.. jupyter-execute ::
134
153
135
154
# Split the mesh by material
136
- my_meshes_31 = ops.mesh.split_mesh(mesh=my_meshed_region_3,property="mat").eval()
155
+ meshes_31 = ops.mesh.split_mesh(mesh=meshed_region_3,property="mat").eval()
156
+
137
157
# Print the meshes
138
- print(my_meshes_31 )
158
+ print(meshes_31 )
139
159
140
160
.. tab-item :: CFX
141
161
142
162
.. jupyter-execute ::
143
163
144
164
# Split the mesh by material
145
- my_meshes_41 = ops.mesh.split_mesh(mesh=my_meshed_region_4 ,property="mat").eval()
165
+ meshes_41 = ops.mesh.split_mesh(mesh=meshed_region_4 ,property="mat").eval()
146
166
# Print the meshes
147
- print(my_meshes_41)
167
+ print(meshes_41)
168
+
169
+ .. _ref_second_approach_split_mesh :
148
170
171
+ Second approach
172
+ ---------------
149
173
150
- 2) Second approach
151
- ------------------
174
+ First, use the |split_on_property_type | operator to split the mesh scoping. This operator splits a |Scoping | on given
175
+ properties (elshape and/or material, since 2025R1 it supports any scalar property field name contained in the mesh
176
+ property fields) and returns a |ScopingsContainer | with those split scopings.
152
177
153
- Use the | split_on_property_type | operator to split the scoping and then create the | MeshedRegion |
154
- objects with the | from_scopings | operator .
178
+ Finally, create the split | MeshedRegion | objects with the | from_scopings | operator. The split parts are stored
179
+ in the DPF collection called | MeshesContainer | .
155
180
156
- The |split_on_property_type | a given |Scoping | on given properties (elshape and/or material, since 2025R1
157
- it supports any scalar property field name contained in the mesh property fields) and returns a |ScopingsContainer |
158
- with those split scopings.
181
+ Here, we split the mesh scoping by material.
159
182
160
183
.. tab-set ::
161
184
@@ -164,41 +187,41 @@ with those split scopings.
164
187
.. jupyter-execute ::
165
188
166
189
# Define the scoping split by material
167
- split_scoping_1 = ops.scoping.split_on_property_type(mesh=my_meshed_region_1 , label1="mat").eval()
190
+ split_scoping_1 = ops.scoping.split_on_property_type(mesh=meshed_region_1 , label1="mat").eval()
168
191
# Get the split meshes
169
- my_meshes_12 = ops.mesh.from_scopings(scopings_container=split_scoping_1,mesh=my_meshed_region_1 ).eval()
192
+ meshes_12 = ops.mesh.from_scopings(scopings_container=split_scoping_1,mesh=meshed_region_1 ).eval()
170
193
# Print the meshes
171
- print(my_meshes_12 )
194
+ print(meshes_12 )
172
195
173
196
.. tab-item :: LSDYNA
174
197
175
198
.. jupyter-execute ::
176
199
177
200
# Define the scoping split by material
178
- split_scoping_2 = ops.scoping.split_on_property_type(mesh=my_meshed_region_2 , label1="mat").eval()
201
+ split_scoping_2 = ops.scoping.split_on_property_type(mesh=meshed_region_2 , label1="mat").eval()
179
202
# Get the split meshes
180
- my_meshes_22 = ops.mesh.from_scopings(scopings_container=split_scoping_2,mesh=my_meshed_region_2 ).eval()
203
+ meshes_22 = ops.mesh.from_scopings(scopings_container=split_scoping_2,mesh=meshed_region_2 ).eval()
181
204
# Print the meshes
182
- print(my_meshes_22 )
205
+ print(meshes_22 )
183
206
184
207
.. tab-item :: Fluent
185
208
186
209
.. jupyter-execute ::
187
210
188
211
# Define the scoping split by material
189
- split_scoping_3 = ops.scoping.split_on_property_type(mesh=my_meshed_region_3 , label1="mat").eval()
212
+ split_scoping_3 = ops.scoping.split_on_property_type(mesh=meshed_region_3 , label1="mat").eval()
190
213
# Get the split meshes
191
- my_meshes_32 = ops.mesh.from_scopings(scopings_container=split_scoping_3,mesh=my_meshed_region_3 ).eval()
214
+ meshes_32 = ops.mesh.from_scopings(scopings_container=split_scoping_3,mesh=meshed_region_3 ).eval()
192
215
# Print the meshes
193
- print(my_meshes_32 )
216
+ print(meshes_32 )
194
217
195
218
.. tab-item :: CFX
196
219
197
220
.. jupyter-execute ::
198
221
199
222
# Define the scoping split by material
200
- split_scoping_4 = ops.scoping.split_on_property_type(mesh=my_meshed_region_4 , label1="mat").eval()
223
+ split_scoping_4 = ops.scoping.split_on_property_type(mesh=meshed_region_4 , label1="mat").eval()
201
224
# Get the split meshes
202
- my_meshes_42 = ops.mesh.from_scopings(scopings_container=split_scoping_4,mesh=my_meshed_region_4 ).eval()
225
+ meshes_42 = ops.mesh.from_scopings(scopings_container=split_scoping_4,mesh=meshed_region_4 ).eval()
203
226
# Print the meshes
204
- print(my_meshes_42 )
227
+ print(meshes_42 )
0 commit comments