1- .. _ tutorials_split_mesh :
1+ .. _ ref_tutorials_split_mesh :
22
33============
44Split a mesh
55============
66
77:bdg-mapdl: `MAPDL ` :bdg-lsdyna: `LSDYNA ` :bdg-fluent: `Fluent ` :bdg-cfx: `CFX `
88
9- This tutorial show how to split a mesh into different meshes.
9+ .. include :: ../../../links_and_refs.rst
1010
11- .. |MeshedRegion | replace :: :class: `MeshedRegion <ansys.dpf.core.meshed_region.MeshedRegion> `
1211.. |MeshesContainer | replace :: :class: `MeshesContainer <ansys.dpf.core.meshes_container.MeshesContainer> `
1312.. |split_mesh | replace :: :class: `split_mesh <ansys.dpf.core.operators.mesh.split_mesh.split_mesh> `
1413.. |split_on_property_type | replace :: :class: `split_on_property_type <ansys.dpf.core.operators.scoping.split_on_property_type.split_on_property_type> `
1514.. |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> `
1815.. |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 > `
2017
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 .
2219
23- You have two approaches to split your mesh :
20+ There are two approaches to accomplish this goal :
2421
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> `
2827
2928Define the mesh
3029---------------
3130
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.
3534
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 .
3837
3938.. tab-set ::
4039
4140 .. tab-item :: MAPDL
4241
4342 .. jupyter-execute ::
4443
45- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
44+ # Import the ``ansys.dpf.core `` module
4645 from ansys.dpf import core as dpf
46+ # Import the examples module
4747 from ansys.dpf.core import examples
48+ # Import the operators module
4849 from ansys.dpf.core import operators as ops
49- # Define the result file
50+
51+ # Define the result file path
5052 result_file_path_1 = examples.find_multishells_rst()
5153 # 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)
5355 # Get the mesh
54- my_meshed_region_1 = my_model_1 .metadata.meshed_region
56+ meshed_region_1 = model_1 .metadata.meshed_region
5557
5658 .. tab-item :: LSDYNA
5759
5860 .. jupyter-execute ::
5961
60- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
62+ # Import the ``ansys.dpf.core `` module
6163 from ansys.dpf import core as dpf
64+ # Import the examples module
6265 from ansys.dpf.core import examples
66+ # Import the operators module
6367 from ansys.dpf.core import operators as ops
64- # Define the result file
68+
69+ # Define the result file path
6570 result_file_path_2 = examples.download_d3plot_beam()
6671 # 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")
7075 # Create the model
71- my_model_2 = dpf.Model(data_sources=my_data_sources_2 )
76+ model_2 = dpf.Model(data_sources=ds_2 )
7277 # Get the mesh
73- my_meshed_region_2 = my_model_2 .metadata.meshed_region
78+ meshed_region_2 = model_2 .metadata.meshed_region
7479
7580 .. tab-item :: Fluent
7681
7782 .. jupyter-execute ::
7883
79- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
84+ # Import the ``ansys.dpf.core `` module
8085 from ansys.dpf import core as dpf
86+ # Import the examples module
8187 from ansys.dpf.core import examples
88+ # Import the operators module
8289 from ansys.dpf.core import operators as ops
83- # Define the result file
90+
91+ # Define the result file path
8492 result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
8593 # 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)
8795 # Get the mesh
88- my_meshed_region_3 = my_model_3 .metadata.meshed_region
96+ meshed_region_3 = model_3 .metadata.meshed_region
8997
9098 .. tab-item :: CFX
9199
92100 .. jupyter-execute ::
93101
94- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
102+ # Import the ``ansys.dpf.core `` module
95103 from ansys.dpf import core as dpf
104+ # Import the examples module
96105 from ansys.dpf.core import examples
106+ # Import the operators module
97107 from ansys.dpf.core import operators as ops
98- # Define the result file
108+
109+ # Define the result file path
99110 result_file_path_4 = examples.download_cfx_mixing_elbow()
100111 # 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)
102113 # 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 :
104117
105- 1) First approach
106- -----------------
118+ First approach
119+ --------------
107120
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.
109122Currently you can split a mesh by material or eltype.
110123
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+
111128.. tab-set ::
112129
113130 .. tab-item :: MAPDL
114131
115132 .. jupyter-execute ::
116133
117134 # 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+
119137 # Print the meshes
120- print(my_meshes_11 )
138+ print(meshes_11 )
121139
122140 .. tab-item :: LSDYNA
123141
124142 .. jupyter-execute ::
125143
126144 # 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+
128147 # Print the meshes
129- print(my_meshes_21 )
148+ print(meshes_21 )
130149
131150 .. tab-item :: Fluent
132151
133152 .. jupyter-execute ::
134153
135154 # 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+
137157 # Print the meshes
138- print(my_meshes_31 )
158+ print(meshes_31 )
139159
140160 .. tab-item :: CFX
141161
142162 .. jupyter-execute ::
143163
144164 # 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()
146166 # Print the meshes
147- print(my_meshes_41)
167+ print(meshes_41)
168+
169+ .. _ref_second_approach_split_mesh :
148170
171+ Second approach
172+ ---------------
149173
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.
152177
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 | .
155180
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.
159182
160183.. tab-set ::
161184
@@ -164,41 +187,41 @@ with those split scopings.
164187 .. jupyter-execute ::
165188
166189 # 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()
168191 # 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()
170193 # Print the meshes
171- print(my_meshes_12 )
194+ print(meshes_12 )
172195
173196 .. tab-item :: LSDYNA
174197
175198 .. jupyter-execute ::
176199
177200 # 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()
179202 # 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()
181204 # Print the meshes
182- print(my_meshes_22 )
205+ print(meshes_22 )
183206
184207 .. tab-item :: Fluent
185208
186209 .. jupyter-execute ::
187210
188211 # 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()
190213 # 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()
192215 # Print the meshes
193- print(my_meshes_32 )
216+ print(meshes_32 )
194217
195218 .. tab-item :: CFX
196219
197220 .. jupyter-execute ::
198221
199222 # 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()
201224 # 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()
203226 # Print the meshes
204- print(my_meshes_42 )
227+ print(meshes_42 )
0 commit comments