Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mesh tutorials to the main tutorials branch #1908

Open
wants to merge 39 commits into
base: doc/new-tutorials-section
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
59e3b20
add tutorials files and update index page
luisaFelixSalles Nov 15, 2024
d11c900
add get_mesh_from_result_file.rst tutorial
luisaFelixSalles Nov 18, 2024
b7e94b5
updates on the index
luisaFelixSalles Nov 18, 2024
4ba833c
updates on get_mesh_from_result_file.rst
luisaFelixSalles Nov 18, 2024
c8e43ae
add create_a_mesh_from_scratch.rst tutorial
luisaFelixSalles Nov 18, 2024
1b175e2
updates the read the mesh tut
luisaFelixSalles Nov 18, 2024
1b2aa28
updates the read the mesh tut
luisaFelixSalles Nov 18, 2024
30db03f
add get_specific_part_mesh.rst and split_mesh.rst tutorials
luisaFelixSalles Nov 18, 2024
94d362b
updates on thr get_specific_part_mesh.rst tutorial
luisaFelixSalles Nov 18, 2024
ff8e6e4
updates the create_a_mesh_from_scratch.rst tut
luisaFelixSalles Nov 18, 2024
0a13b04
erases add and plot data parts from the create_a_mesh_from_scratch.rs…
luisaFelixSalles Nov 19, 2024
9d66175
update references in get_mesh_from_result_file.rst tutorial
luisaFelixSalles Nov 19, 2024
79ae3cd
update references in read_mesh.rst tutorial
luisaFelixSalles Nov 19, 2024
397d7e2
add second approach to the split_mesh.rst tutorial
luisaFelixSalles Nov 19, 2024
452fe3d
updates on get_specific_part_mesh.rst
luisaFelixSalles Nov 19, 2024
0ec9ddc
put a tab for each solver
luisaFelixSalles Nov 20, 2024
3b1a825
update
luisaFelixSalles Nov 20, 2024
21675f4
put a tab for each solver in the get_specific_part_mesh.rst tutorial
luisaFelixSalles Nov 20, 2024
fc4edef
put a tab for each solver in the split_mesh.rst tutorial
luisaFelixSalles Nov 20, 2024
70c117a
put a tab for each solver and update the read_mesh_metadata.rst tutorial
luisaFelixSalles Nov 20, 2024
bb0ff86
put a tab for each solver and update the explore_mesh.rst tutorial
luisaFelixSalles Nov 20, 2024
f0ed6d1
put badge for each solver in the main page cards
luisaFelixSalles Nov 20, 2024
9247860
put badge for each solver in the beginning of the tutorials
luisaFelixSalles Nov 20, 2024
aebead2
update title read_mesh_metadata.rst
luisaFelixSalles Nov 20, 2024
79c607d
update title get_specific_part_mesh.rst
luisaFelixSalles Nov 20, 2024
4a7aed7
update substitution text
luisaFelixSalles Nov 20, 2024
b1baaac
Update doc/source/user_guide/tutorials/mesh/explore_mesh.rst
luisaFelixSalles Nov 21, 2024
24570d0
use only the jupyter sphinx extension
luisaFelixSalles Nov 22, 2024
40873f6
updates the examples package references
luisaFelixSalles Nov 22, 2024
ddfb66c
update badges in the index.rst
luisaFelixSalles Dec 3, 2024
236241a
change the section name
luisaFelixSalles Dec 3, 2024
8b74e04
add badges in each tutorial
luisaFelixSalles Dec 3, 2024
d79cc05
update2 the create_a_mesh_from_scratch.rst tutorial to the tutorials …
luisaFelixSalles Dec 4, 2024
6dbd1c1
update the explore_mesh.rst to the tutorials guidelines
luisaFelixSalles Dec 4, 2024
dc3e238
update the extract_mesh_in_split_parts.rst to the tutorials guidelines
luisaFelixSalles Dec 4, 2024
c3deaec
update the get_mesh_from_result_file.rst to the tutorials guidelines
luisaFelixSalles Dec 4, 2024
8901fc3
update the read_mesh_metadata.rst to the tutorials guidelines
luisaFelixSalles Dec 4, 2024
a9ba987
update the split_mesh.rst to the tutorials guidelines
luisaFelixSalles Dec 4, 2024
47afb3b
update the index page of the mesh tutorials section
luisaFelixSalles Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update the explore_mesh.rst to the tutorials guidelines
luisaFelixSalles committed Dec 4, 2024
commit 6dbd1c10bea36dc2a2b65af37bd56069d5fb8427
210 changes: 118 additions & 92 deletions doc/source/user_guide/tutorials/mesh/explore_mesh.rst
Original file line number Diff line number Diff line change
@@ -1,172 +1,185 @@
.. _tutorials_explore_mesh:
.. _ref_tutorials_explore_mesh:

==============
Explore a mesh
==============

:bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX`

.. |MeshedRegion| replace:: :class:`MeshedRegion <ansys.dpf.core.meshed_region.MeshedRegion>`
.. |Model| replace:: :class:`Model <ansys.dpf.core.model.Model>`
.. |DataSources| replace:: :class:`Model <ansys.dpf.core.data_sources.DataSources>`
.. |MeshInfo| replace:: :class:`MeshInfo <ansys.dpf.core.mesh_info.MeshInfo>`
.. |Nodes| replace:: :class:`Nodes <ansys.dpf.core.nodes.Nodes>`
.. |Elements| replace:: :class:`Elements <ansys.dpf.core.elements.Elements>`
.. |Faces| replace:: :class:`Faces <ansys.dpf.core.faces.Faces>`
.. |Scoping| replace:: :class:`Scoping <ansys.dpf.core.scoping.Scoping>`
.. include:: ../../../links_and_refs.rst
.. |PropertyField| replace:: :class:`PropertyField <ansys.dpf.core.property_field.PropertyField>`
.. |Examples| replace:: :mod:`Examples<ansys.dpf.core.examples>`
.. |element_types| replace:: :class:`list of available element types in a DPF mesh<ansys.dpf.core.elements.element_types>`

This tutorial explains how to access the mesh data and metadata (data about the elements, nodes, faces, region, zone ...)
so it can be manipulated.
This tutorial explains how to access a mesh data and metadata so it can be manipulated.


There is a general method to read the |MeshedRegion| by manipulating
the methods of this object.
:jupyter-download-script:`Download tutorial as Python script<explore_mesh>`
:jupyter-download-notebook:`Download tutorial as Jupyter notebook<explore_mesh>`

Define the mesh
---------------

The mesh object in DPF is a |MeshedRegion|. You can obtain a |MeshedRegion| by creating your
own by scratch or by getting it from a result file. For more information check the
:ref:`tutorials_create_a_mesh_from_scratch` and :ref:`tutorials_get_mesh_from_result_file` tutorials.
own from scratch or by getting it from a result file. For more information check the
:ref:`ref_tutorials_create_a_mesh_from_scratch` and :ref:`ref_tutorials_get_mesh_from_result_file` tutorials.

Here we we will download a result file available in our |Examples| package.
For more information about how to import your result file in DPF check
the :ref:`ref_tutorials_import_data` tutorial section.
For this tutorial, we get a |MeshedRegion| from a result file. You can use one available in the |Examples| module.
For more information see the :ref:`ref_tutorials_get_mesh_from_result_file` tutorial.

.. tab-set::

.. tab-item:: MAPDL

.. jupyter-execute::

# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
# Import the ``ansys.dpf.core`` module
from ansys.dpf import core as dpf
# Import the examples module
from ansys.dpf.core import examples
# Import the operators module
from ansys.dpf.core import operators as ops
# Define the result file

# Define the result file path
result_file_path_1 = examples.find_static_rst()
# Create the model
my_model_1 = dpf.Model(data_sources=result_file_path_1)
model_1 = dpf.Model(data_sources=result_file_path_1)
# Get the mesh
my_meshed_region_1 = my_model_1.metadata.meshed_region
meshed_region_1 = model_1.metadata.meshed_region

.. tab-item:: LSDYNA

.. jupyter-execute::

# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
# Import the ``ansys.dpf.core`` module
from ansys.dpf import core as dpf
# Import the examples module
from ansys.dpf.core import examples
# Import the operators module
from ansys.dpf.core import operators as ops
# Define the result file

# Define the result file path
result_file_path_2 = examples.download_d3plot_beam()
# Create the DataSources object
my_data_sources_2 = dpf.DataSources()
my_data_sources_2.set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
my_data_sources_2.add_file_path(filepath=result_file_path_2[3], key="actunits")
ds_2 = dpf.DataSources()
ds_2.set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
ds_2.add_file_path(filepath=result_file_path_2[3], key="actunits")
# Create the model
my_model_2 = dpf.Model(data_sources=my_data_sources_2)
model_2 = dpf.Model(data_sources=ds_2)
# Get the mesh
my_meshed_region_2 = my_model_2.metadata.meshed_region
meshed_region_2 = model_2.metadata.meshed_region

.. tab-item:: Fluent

.. jupyter-execute::

# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
# Import the ``ansys.dpf.core`` module
from ansys.dpf import core as dpf
# Import the examples module
from ansys.dpf.core import examples
# Import the operators module
from ansys.dpf.core import operators as ops
# Define the result file

# Define the result file path
result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
# Create the model
my_model_3 = dpf.Model(data_sources=result_file_path_3)
model_3 = dpf.Model(data_sources=result_file_path_3)
# Get the mesh
my_meshed_region_3 = my_model_3.metadata.meshed_region
meshed_region_3 = model_3.metadata.meshed_region

.. tab-item:: CFX

.. jupyter-execute::

# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
# Import the ``ansys.dpf.core`` module
from ansys.dpf import core as dpf
# Import the examples module
from ansys.dpf.core import examples
# Import the operators module
from ansys.dpf.core import operators as ops
# Define the result file

# Define the result file path
result_file_path_4 = examples.download_cfx_mixing_elbow()
# Create the model
my_model_4 = dpf.Model(data_sources=result_file_path_4)
model_4 = dpf.Model(data_sources=result_file_path_4)
# Get the mesh
my_meshed_region_4 = my_model_4.metadata.meshed_region
meshed_region_4 = model_4.metadata.meshed_region

Read the mesh
-------------
Explore the mesh data
---------------------

From the |MeshedRegion| you can access its information by manipulating this object properties.
The mesh information includes :
You can access the mesh data by manipulating the |MeshedRegion| object methods.
The mesh data includes :

- Unit;
- Nodes, elements and faces;
- Named selections;
- Properties.
- Named selections.

Check all the information you can get at: |MeshedRegion|.
Check all the types of data you can get from a mesh at |MeshedRegion|.

Access the mesh nodes, element, faces and named selection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When instantiating nodes, elements, faces and named selections you get the correspondent DPF objects:
|Nodes|, |Elements|, |Faces| and |Scoping|.

When instantiating the nodes, element, faces and named selection you get the correspondent DPF objects:
|Nodes|, |Elements|, |Faces| and |Scoping|. For example:
Here, we get the mesh nodes.

.. tab-set::

.. tab-item:: MAPDL

.. jupyter-execute::

# Get the mesh elements
my_nodes_1 = my_meshed_region_1.nodes
# Get the mesh nodes
nodes_1 = meshed_region_1.nodes

# Print the object type
print("Object type: ",type(nodes_1),'\n')

# Print the nodes
print(my_nodes_1)
print("Object type: ",type(my_nodes_1))
print("Nodes: ", nodes_1)

.. tab-item:: LSDYNA

.. jupyter-execute::

# Get the mesh elements
my_nodes_2 = my_meshed_region_2.nodes
# Get the mesh nodes
nodes_2 = meshed_region_2.nodes

# Print the object type
print("Object type: ",type(nodes_2),'\n')

# Print the nodes
print(my_nodes_2)
print("Object type: ",type(my_nodes_2))
print("Nodes: ", nodes_2)

.. tab-item:: Fluent

.. jupyter-execute::

# Get the mesh elements
my_nodes_3 = my_meshed_region_3.nodes
# Get the mesh nodes
nodes_3 = meshed_region_3.nodes

# Print the object type
print("Object type: ",type(nodes_3),'\n')

# Print the nodes
print(my_nodes_3)
print("Object type: ",type(my_nodes_3))
print("Nodes: ", nodes_3)

.. tab-item:: CFX

.. jupyter-execute::

# Get the mesh elements
my_nodes_4 = my_meshed_region_4.nodes
# Get the mesh nodes
nodes_4 = meshed_region_4.nodes

# Print the object type
print("Object type: ",type(nodes_4),'\n')

# Print the nodes
print(my_nodes_4)
print("Object type: ",type(my_nodes_4))
print("Nodes: ", nodes_4)

Explore the mesh metadata
-------------------------

Access the mesh properties
^^^^^^^^^^^^^^^^^^^^^^^^^^
You can access the mesh metadata by manipulating the |MeshedRegion| object properties.

When handling properties you can check which are the available ones and also
chose those you want to extract.
You can check which ones are available.

.. tab-set::

@@ -175,39 +188,48 @@ chose those you want to extract.
.. jupyter-execute::

# Get the available properties
my_available_props_1 = my_meshed_region_1.available_property_fields
available_props_1 = meshed_region_1.available_property_fields

# Print the available properties
print(my_available_props_1)
print("Available properties: ", available_props_1)

.. tab-item:: LSDYNA

.. jupyter-execute::

# Get the available properties
my_available_props_2 = my_meshed_region_2.available_property_fields
available_props_2 = meshed_region_2.available_property_fields

# Print the available properties
print(my_available_props_2)
print("Available properties: ", available_props_2)

.. tab-item:: Fluent

.. jupyter-execute::

# Get the available properties
my_available_props_3 = my_meshed_region_3.available_property_fields
available_props_3 = meshed_region_3.available_property_fields

# Print the available properties
print(my_available_props_3)
print("Available properties: ", available_props_3)

.. tab-item:: CFX

.. jupyter-execute::

# Get the available properties
my_available_props_4 = my_meshed_region_4.available_property_fields
available_props_4 = meshed_region_4.available_property_fields

# Print the available properties
print(my_available_props_4)
print("Available properties: ", available_props_4)

When extracting those properties you get a |PropertyField| with that information. Their data is mapped
to the entity they are defined at:
You can also chose which property you want to extract.

When extracting the properties you get a |PropertyField| with that information. Their data is mapped to
the entity they are defined at.

The element type is given as a number. Check the |element_types| to find the
corresponding element name.

.. tab-set::

@@ -216,34 +238,38 @@ to the entity they are defined at:
.. jupyter-execute::

# Get the element types on the mesh
my_el_types_1 = my_meshed_region_1.property_field(property_name="eltype")
# Print the element types
print(my_el_types_1)
el_types_1 = meshed_region_1.property_field(property_name="eltype")

# Print the element types by element
print(el_types_1)


.. tab-item:: LSDYNA

.. jupyter-execute::

# Get the element types on the mesh
my_el_types_2 = my_meshed_region_2.property_field(property_name="eltype")
# Print the element types
print(my_el_types_2)
el_types_2 = meshed_region_2.property_field(property_name="eltype")

# Print the element types by element
print(el_types_2)

.. tab-item:: Fluent

.. jupyter-execute::

# Get the element types on the mesh
my_el_types_3 = my_meshed_region_3.property_field(property_name="eltype")
# Print the element types
print(my_el_types_3)
el_types_3 = meshed_region_3.property_field(property_name="eltype")

# Print the element types by element
print(el_types_3)

.. tab-item:: CFX

.. jupyter-execute::

# Get the element types on the mesh
my_el_types_4 = my_meshed_region_4.property_field(property_name="eltype")
# Print the element types
print(my_el_types_4)
el_types_4 = meshed_region_4.property_field(property_name="eltype")

# Print the element types by element
print(el_types_4)