From 811adde031ceba9e03de485eb7a438199f246edb Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 22 Oct 2024 15:18:27 +0200 Subject: [PATCH 01/49] add new basic tutorial and jupyter_ sphinx extension --- .../user_guide/tutorials/basic_tutorial.rst | 241 ++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 doc/source/user_guide/tutorials/basic_tutorial.rst diff --git a/doc/source/user_guide/tutorials/basic_tutorial.rst b/doc/source/user_guide/tutorials/basic_tutorial.rst new file mode 100644 index 0000000000..11b7097676 --- /dev/null +++ b/doc/source/user_guide/tutorials/basic_tutorial.rst @@ -0,0 +1,241 @@ +.. _ref_tutorials_basic: + +================== +The basic tutorial +================== + +This tutorial guides throughout the basic concepts and features of the PyDPF-Core tool. +It helps to have a Python interpreter for hands-on experience, but all code examples are +executed, so the tutorial can be read off-line as well. + +For a complete description of all the objects and modules, see the :ref:`API reference ` section. + +This page is divided in two sections: + +.. grid:: 1 1 2 2 + :gutter: 2 + :padding: 2 + :margin: 2 + + .. grid-item-card:: Overview + :link: tutorials_overview + :link-type: ref + :text-align: center + + Learn the different ways to interact with data by calling PyDPF-Core commands and operators. + + .. grid-item-card:: Postprocessing main steps + :link: tutorials_main_steps + :link-type: ref + :text-align: center + + How to do a basic prost-processing by transforming simulation data into output + data that can be used to visualize and analyze results + +.. _tutorials_overview: + +Overview +-------- + + + +.. _tutorials_main_steps: + +Postprocessing main steps +------------------------- + +There are five main steps to transform simulation data into output data that can +be used to visualize and analyze simulation results: + +.. grid:: + :gutter: 2 + :padding: 2 + :margin: 2 + + .. grid-item-card:: 1 + :link: tutorials_main_steps_1 + :link-type: ref + :text-align: center + + Importing and opening results files + + .. grid-item-card:: 2 + :link: tutorials_main_steps_2 + :link-type: ref + :text-align: center + + Access and extract results + + .. grid-item-card:: 3 + :link: tutorials_main_steps_3 + :link-type: ref + :text-align: center + + Transform available data + + .. grid-item-card:: 4 + :link: tutorials_main_steps_4 + :link-type: ref + :text-align: center + + Visualize the data + + .. grid-item-card:: 5 + :link: tutorials_main_steps_5 + :link-type: ref + :text-align: center + + Extract data + +.. _tutorials_main_steps_1: + +1- Importing and opening results files +************************************** + +First, import the DPF-Core module as ``dpf`` and import the included examples file + +.. code-block:: python + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + +`DataSources' is a class that manages paths to their files. Use this object to declare +data inputs for DPF and define their locations. + +.. code-block:: python + + # Define the DataSources object + my_data_sources = dpf.DataSources(result_path=examples.find_simple_bar()) + + +The model is a helper designed to give shortcuts to access the analysis results +metadata, by opening a DataSources or a Streams, and to instanciate results provider for it. + +Printing the model displays: + + - Analysis type + - Available results + - Size of the mesh + - Number of results + +.. code-block:: python + + # Define the Model object + my_model = dpf.Model(data_sources=my_data_sources) + print(my_model) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + my_data_sources = dpf.DataSources(result_path=examples.find_simple_bar()) + my_model = dpf.Model(data_sources=my_data_sources) + print(my_model) + +.. _tutorials_main_steps_2: + +2- Access and extract results +***************************** + +We see in the model that a displacement result is available. You can access this result by: + +.. code-block:: python + + # Define the displacement results through the models property `results` + my_displacements = my_model.results.displacement.eval() + print(my_displacements) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_displacements = my_model.results.displacement.eval() + print(my_displacements) + +The displacement data can be extract by: + +.. code-block:: python + + # Extract the data of the displacement field + my_displacements_0 = my_displacements[0].data + print(my_displacements_0) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_displacements_0 = my_displacements[0].data + print(my_displacements_0) + +.. _tutorials_main_steps_3: + +3- Transform available data +*************************** + +Several transformations can be made with the data. They can be a single operation, +by using only one operator, or they can represent a succession of operations, by defining a +workflow with chained operators. + +Here we star by computing the displacements norm. + +.. code-block:: python + + # Define the norm operator (here for a fields container) for the displacement + my_norm = ops.math.norm_fc(fields_container=my_displacements).eval() + print(my_norm[0].data) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_norm = ops.math.norm_fc(fields_container=my_displacements).eval() + print(my_norm[0].data) + +Then we compute the maximum values of the normalised displacement + +.. code-block:: python + + # Define the maximum operator and chain it to the norm operator + my_max= ops.min_max.min_max_fc(fields_container=my_norm).outputs.field_max() + print(my_max) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_max = ops.min_max.min_max_fc(fields_container=my_norm).outputs.field_max() + print(my_max) + +.. _tutorials_main_steps_4: + +4- Visualize the data +********************* + +Plot the transformed displacement results + +.. code-block:: python + + # Define the support of the plot (here we plot the displacement over the mesh) + my_model.metadata.meshed_region.plot(field_or_fields_container=my_displacements) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_model.metadata.meshed_region.plot(field_or_fields_container=my_displacements) + +.. _tutorials_main_steps_5: + +5- Extract the data +******************* + From 2266b73242e59f8152fd90c85c4a543ea220b08f Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Fri, 15 Nov 2024 17:17:00 +0100 Subject: [PATCH 02/49] add tutorials files and update index page --- .../mesh/create_a_mesh_from_scratch.rst | 5 +++ .../mesh/get_mesh_from_result_file.rst | 6 +++ .../tutorials/mesh/get_specific_part_mesh.rst | 6 +++ .../user_guide/tutorials/mesh/index.rst | 43 +++++++++++-------- .../tutorials/mesh/read_mesh_metadata.rst | 6 +++ .../tutorials/mesh/read_mesh_structure.rst | 8 ++++ .../user_guide/tutorials/mesh/split_mesh.rst | 6 +++ 7 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst create mode 100644 doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst create mode 100644 doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst create mode 100644 doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst create mode 100644 doc/source/user_guide/tutorials/mesh/read_mesh_structure.rst create mode 100644 doc/source/user_guide/tutorials/mesh/split_mesh.rst diff --git a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst new file mode 100644 index 0000000000..35e2e1be88 --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst @@ -0,0 +1,5 @@ +.. _tutorials_create_a_mesh_from_scratch: + +========================== +Create a mesh from scratch +========================== \ No newline at end of file diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst new file mode 100644 index 0000000000..5fbeb0c5cc --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -0,0 +1,6 @@ +.. _tutorials_get_mesh_from_result_file: + +============================= +Get a mesh from a result file +============================= + diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst new file mode 100644 index 0000000000..a51147e04b --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -0,0 +1,6 @@ +.. _tutorials_get_specific_part_mesh: + +=============================== +Get a specific part of the mesh +=============================== + diff --git a/doc/source/user_guide/tutorials/mesh/index.rst b/doc/source/user_guide/tutorials/mesh/index.rst index 8464839b40..91d53ab59b 100644 --- a/doc/source/user_guide/tutorials/mesh/index.rst +++ b/doc/source/user_guide/tutorials/mesh/index.rst @@ -15,47 +15,56 @@ These tutorials explains how to explore different attributes of a given mesh wit :margin: 2 .. grid-item-card:: Create a mesh from scratch - :link: ref_tutorials + :link: tutorials_create_a_mesh_from_scratch :link-type: ref :text-align: center - This tutorial + This tutorial demonstrates how to build a mesh from the scratch - .. grid-item-card:: Get the mesh from a result file - :link: ref_tutorials + .. grid-item-card:: Get a mesh from a result file + :link: tutorials_get_mesh_from_result_file :link-type: ref :text-align: center - This tutorial + This tutorial explains how to extract the models mesh from a result file - .. grid-item-card:: Read the mesh metadata - :link: ref_tutorials + .. grid-item-card:: Read a mesh definition information + :link: tutorials_read_mesh_metadata :link-type: ref :text-align: center - This tutorial + This tutorial explains how to access and read the mesh metadata information - .. grid-item-card:: Read the mesh - :link: ref_tutorials + .. grid-item-card:: Read a mesh structure + :link: tutorials_read_mesh_structure :link-type: ref :text-align: center - This tutorial + This tutorial explains how to access the data about the mesh structure + (data about the elements, nodes, faces ...) so it can be manipulated. - .. grid-item-card:: Read a subpart of the mesh - :link: ref_tutorials + .. grid-item-card:: Get a specific part of a mesh + :link: tutorials_get_specific_part_mesh :link-type: ref :text-align: center - This tutorial + This tutorial shows how to to access the data about a specific part of a mesh + (data about a region, zone ...) so it can be manipulated. - .. grid-item-card:: Split the mesh - :link: ref_tutorials + .. grid-item-card:: Split a mesh + :link: tutorials_split_mesh :link-type: ref :text-align: center - This tutorial + This tutorial show how to split a mesh into different meshes. .. toctree:: :maxdepth: 2 :hidden: + + create_a_mesh_from_scratch + get_mesh_from_result_file + read_mesh_metadata + read_mesh_structure + get_specific_part_mesh + split_mesh diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst new file mode 100644 index 0000000000..117d763085 --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst @@ -0,0 +1,6 @@ +.. _tutorials_read_mesh_metadata: + +==================================== +Read the mesh definition information +==================================== + diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_structure.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_structure.rst new file mode 100644 index 0000000000..e3c72f5db7 --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_structure.rst @@ -0,0 +1,8 @@ +.. _tutorials_read_mesh_structure: + +======================= +Read the mesh structure +======================= + + + diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst new file mode 100644 index 0000000000..a1ee1d76bf --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -0,0 +1,6 @@ +.. _tutorials_split_mesh: + +============ +Split a mesh +============ + From 9da611a4df701550d2db896d42745596f863a737 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 10:31:08 +0100 Subject: [PATCH 03/49] add get_mesh_from_result_file.rst tutorial --- .../mesh/get_mesh_from_result_file.rst | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 5fbeb0c5cc..0357f1394b 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -4,3 +4,108 @@ Get a mesh from a result file ============================= +.. |Field| replace:: :class:`Field` +.. |FieldsContainer| replace:: :class:`FieldsContainer` +.. |MeshedRegion| replace:: :class:`MeshedRegion ` +.. |Model| replace:: :class:`Model ` +.. |DataSources| replace:: :class:`Model ` +.. |mesh_provider| replace:: ` + +This tutorial explains how to extract the models mesh from a result file. + +Import the result file +---------------------- + +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. + +You have to create a |DataSources| object so the data can be accessed by +PyDPF-Core APIs. + +.. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path = examples.find_static_rst() + # Create the DataSources object + my_data_sources = dpf.DataSources(result_path=result_file_path) + +Get the mesh from the result file +--------------------------------- + +You can Get the mesh from the result file by two methods: + +- :ref:`get_mesh_model` +- :ref:`get_mesh_mesh_provider` + +.. note:: + + The |Model| extracts a large amount of information by default (results, mesh and analysis data). + If using this helper takes a long time for processing the code, mind using a |DataSources| object + and instantiating operators directly with it. Check the ":ref:`get_mesh_mesh_provider`" for more + information on how to get a mesh from a result file. + +.. _get_mesh_model: + +Using the DPF |Model| +^^^^^^^^^^^^^^^^^^^^^ + +The |Model| is a helper designed to give shortcuts to access the analysis results +metadata, by opening a DataSources or a Streams, and to instanciate results provider +for it. + +Get the |MeshedRegion| by instantiating a |Model| object and accessing its metadata: + +.. code-block:: python + + # Create the model + my_model = dpf.Model(data_sources=my_data_sources) + # Get the mesh + my_meshed_region_1 = my_model.metadata.meshed_region + +Printing the |MeshedRegion| displays the mesh dimensions (number of nodes and elements, +unit and elements type): + +.. code-block:: python + + # Print the meshed region + print(my_meshed_region_1) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + result_file_path = examples.find_static_rst() + my_data_sources = dpf.DataSources(result_path=result_file_path) + my_model = dpf.Model(data_sources=my_data_sources) + my_meshed_region_1 = my_model.metadata.meshed_region + print(my_meshed_region_1) + +.. _get_mesh_mesh_provider: + +Using the |mesh_provider| operator +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Get the |MeshedRegion| by instantiating the |mesh_provider| operator and instantiating it with a +|DataSources| object as an argument: + +.. code-block:: python + + # Get the mesh with the mesh_provider operator + my_meshed_region_2 = ops.mesh.mesh_provider(data_sources=my_data_sources).eval() + +Printing the |MeshedRegion| displays the mesh dimensions (number of nodes and elements, +unit and elements type): + +.. code-block:: python + + # Print the meshed region + print(my_meshed_region_2) \ No newline at end of file From d02b96deb6c703f7543ae6fef41b1f6b2adf8f1c Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 10:55:00 +0100 Subject: [PATCH 04/49] updates on the index --- .../user_guide/tutorials/mesh/index.rst | 26 +++++--------- .../user_guide/tutorials/mesh/read_mesh.rst | 36 +++++++++++++++++++ .../tutorials/mesh/read_mesh_metadata.rst | 6 ---- 3 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 doc/source/user_guide/tutorials/mesh/read_mesh.rst delete mode 100644 doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst diff --git a/doc/source/user_guide/tutorials/mesh/index.rst b/doc/source/user_guide/tutorials/mesh/index.rst index 91d53ab59b..e760deb56e 100644 --- a/doc/source/user_guide/tutorials/mesh/index.rst +++ b/doc/source/user_guide/tutorials/mesh/index.rst @@ -28,20 +28,13 @@ These tutorials explains how to explore different attributes of a given mesh wit This tutorial explains how to extract the models mesh from a result file - .. grid-item-card:: Read a mesh definition information - :link: tutorials_read_mesh_metadata + .. grid-item-card:: Read a mesh + :link: tutorials_read_mesh :link-type: ref :text-align: center - This tutorial explains how to access and read the mesh metadata information - - .. grid-item-card:: Read a mesh structure - :link: tutorials_read_mesh_structure - :link-type: ref - :text-align: center - - This tutorial explains how to access the data about the mesh structure - (data about the elements, nodes, faces ...) so it can be manipulated. + This tutorial explains how to access the mesh data and metadata + (data about the elements, nodes, faces ...). .. grid-item-card:: Get a specific part of a mesh :link: tutorials_get_specific_part_mesh @@ -62,9 +55,8 @@ These tutorials explains how to explore different attributes of a given mesh wit :maxdepth: 2 :hidden: - create_a_mesh_from_scratch - get_mesh_from_result_file - read_mesh_metadata - read_mesh_structure - get_specific_part_mesh - split_mesh + create_a_mesh_from_scratch.rst + get_mesh_from_result_file.rst + read_mesh.rst + get_specific_part_mesh.rst + split_mesh.rst diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh.rst b/doc/source/user_guide/tutorials/mesh/read_mesh.rst new file mode 100644 index 0000000000..5924a7425f --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/read_mesh.rst @@ -0,0 +1,36 @@ +.. _tutorials_read_mesh: + +==================================== +Read the mesh definition information +==================================== + +.. |MeshedRegion| replace:: :class:`MeshedRegion ` +.. |Model| replace:: :class:`Model ` +.. |DataSources| replace:: :class:`Model ` + +This tutorial explains how to access and read a 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. + +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. + +.. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path = examples.find_static_rst() + # Create the model + my_model = dpf.Model(data_sources=my_data_sources) + # Get the mesh + my_meshed_region_1 = my_model.metadata.meshed_region + diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst deleted file mode 100644 index 117d763085..0000000000 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. _tutorials_read_mesh_metadata: - -==================================== -Read the mesh definition information -==================================== - From 7480d307d0d98cf8af630671da6e450c5d451596 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 10:55:29 +0100 Subject: [PATCH 05/49] updates on get_mesh_from_result_file.rst --- .../user_guide/tutorials/mesh/get_mesh_from_result_file.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 0357f1394b..9c22562627 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -11,8 +11,12 @@ Get a mesh from a result file .. |DataSources| replace:: :class:`Model ` .. |mesh_provider| replace:: ` +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. + This tutorial explains how to extract the models mesh from a result file. + Import the result file ---------------------- From 3c31dd21743adc8fdbfe19cc436d915cab3a9c2d Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 10:55:52 +0100 Subject: [PATCH 06/49] add create_a_mesh_from_scratch.rst tutorial --- .../mesh/create_a_mesh_from_scratch.rst | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst index 35e2e1be88..dc04bccd86 100644 --- a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst +++ b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst @@ -2,4 +2,44 @@ ========================== Create a mesh from scratch -========================== \ No newline at end of file +========================== + +.. |Field| replace:: :class:`Field` +.. |FieldsContainer| replace:: :class:`FieldsContainer` +.. |MeshedRegion| replace:: :class:`MeshedRegion ` +.. |Model| replace:: :class:`Model ` + +The mesh object in DPF is a |MeshedRegion|. You can create your own |MeshedRegion| object to use DPF operators +with your own data. The ability to use scripting to create any DPF entity means +that you are not dependent on result files and can connect the DPF environment +with any Python tool. + +This tutorial demonstrates how to build a |MeshedRegion| from the scratch. + +Here we create a parallel piped mesh made of linear hexa elements. + +Import the necessary modules +---------------------------- + +Import the ``ansys.dpf.core`` module, including the operators subpackage + +.. code-block:: python + + from ansys.dpf import core as dpf + from ansys.dpf.core import operators as ops + +Define the mesh dimensions +-------------------------- + +.. code-block:: python + + length = 0.1 + width = 0.05 + depth = 0.1 + num_nodes_in_length = 10 + num_nodes_in_width = 5 + num_nodes_in_depth = 10 + my_meshed_region = dpf.MeshedRegion() + + + From 9a66fcac91d20bdfb44bc042285be3e1c599c295 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 14:51:46 +0100 Subject: [PATCH 07/49] updates the read the mesh tut --- .../user_guide/tutorials/mesh/read_mesh.rst | 187 +++++++++++++++++- .../tutorials/mesh/read_mesh_structure.rst | 8 - 2 files changed, 183 insertions(+), 12 deletions(-) delete mode 100644 doc/source/user_guide/tutorials/mesh/read_mesh_structure.rst diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh.rst b/doc/source/user_guide/tutorials/mesh/read_mesh.rst index 5924a7425f..15d330239a 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh.rst @@ -7,11 +7,33 @@ Read the mesh definition information .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |Model| replace:: :class:`Model ` .. |DataSources| replace:: :class:`Model ` +.. |MeshInfo| replace:: :class:`MeshInfo ` +.. |Nodes| replace:: :class:`Nodes ` +.. |Elements| replace:: :class:`Elements ` +.. |Faces| replace:: :class:`Faces ` +.. |Scoping| replace:: :class:`Scoping ` +.. |PropertyField| replace:: :class:`PropertyField ` This tutorial explains how to access and read a 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. + +There is a general method to read the |MeshedRegion| by manipulating +the methods of this object (see :ref: `read_mesh_general` ). + +Nevertheless, if you have a mesh from a LSDYNA, Fluent or CFX file we have a +special object to read more specific metadata information by +exploring the |MeshInfo| object (see :ref: `read_mesh_fluids_lsdyna`). + +.. _read_mesh_general: + +Read a |MeshedRegion| +--------------------- + 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 @@ -28,9 +50,166 @@ the :ref:`ref_tutorials_import_data` tutorial section. from ansys.dpf.core import examples from ansys.dpf.core import operators as ops # Define the result file - result_file_path = examples.find_static_rst() + result_file_path_1 = examples.find_static_rst() # Create the model - my_model = dpf.Model(data_sources=my_data_sources) + my_model_1 = dpf.Model(data_sources=result_file_path_1) # Get the mesh - my_meshed_region_1 = my_model.metadata.meshed_region + my_meshed_region_1 = my_model_1.metadata.meshed_region + +Read the mesh +^^^^^^^^^^^^^ + +From the |MeshedRegion| you can access its information by manipulating this object properties. +The mesh information includes : + +- Unit; +- Nodes, elements and faces; +- Named selections; +- Properties. + +Check all the information you can get at: |MeshedRegion|. + +When instantiating the nodes, element, faces and named selection you get the correspondent DPF objects: +|Nodes|,|Elements|,|Faces| and |Scoping|. For example: + +.. code-block:: python + + # Get the mesh elements + my_nodes = my_meshed_region_1.nodes + # Print the nodes + print(my_nodes) + print(type(my_nodes)) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + result_file_path_1 = examples.find_static_rst() + my_model_1 = dpf.Model(data_sources=result_file_path_1) + my_meshed_region_1 = my_model_1.metadata.meshed_region + my_nodes = my_meshed_region_1.nodes + print(my_nodes) + print(type(my_nodes)) + +When handling properties you can check which are the available ones and then +chose those you want to extract. + +.. code-block:: python + + # Get the available properties + my_available_props = my_meshed_region_1.available_property_fields + # Print the available properties + print(my_available_props) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_available_props = my_meshed_region_1.available_property_fields + print(my_available_props) + +When extracting those properties you get a |PropertyField| with that information. Their data is mapped +to the entity their are defined at: + +.. code-block:: python + + # Get the element types on the mesh + my_el_types = my_meshed_region_1.property_field(property_name="eltype") + # Print the element types + print(my_el_types) + + +.. _read_mesh_fluids_lsdyna: + +Read the mesh of a LSDYNA, Fluent or CFX file +--------------------------------------------- + +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. + +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. + +.. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_2 = examples.download_fluent_axial_comp()["flprj"] + # Create the model + my_model_2 = dpf.Model(data_sources=result_file_path_2) + # Get the mesh + my_meshed_region_2 = my_model.metadata.meshed_region + +Read the mesh +^^^^^^^^^^^^^ + +The |Model| is a helper designed to give shortcuts to access the analysis results +metadata, by opening a DataSources or a Streams, and to instanciate results provider +for it. + +From the |Model| you can access the |MeshedRegion| metadata information. The mesh metadata information +includes : + +- Properties; +- Parts; +- Faces; +- Bodies; +- Zones; +- Number of nodes and elements; +- Elements types. + +Get the the mesh metadata information and print the available ones: + +.. code-block:: python + + # Get the mesh metadata information + my_mesh_info = my_model_2.metadata.mesh_info + # Print the mesh metadata information + print(my_mesh_info) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + result_file_path_2 = examples.download_fluent_axial_comp()["flprj"] + my_model_2 = dpf.Model(data_sources=result_file_path_2) + my_meshed_region_2 = my_model_2.metadata.meshed_region + my_mesh_info = my_model_2.metadata.mesh_info + print(my_mesh_info) + +You can access each of those mesh information's by manipulating the |MeshInfo| object properties. +For example we can check the cell zone names: + +.. code-block:: python + + # Get the cell zone names + my_cell_zones = my_mesh_info.get_property("cell_zone_names") + print(my_cell_zones) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_cell_zones = my_mesh_info.get_property("cell_zone_names") + print(my_cell_zones) +For more information on reading a mesh from a LSDYNA, Fluent or CFX file check the examples sections: +:ref:`fluids_examples` and :ref:`examples_cfx` diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_structure.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_structure.rst deleted file mode 100644 index e3c72f5db7..0000000000 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_structure.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. _tutorials_read_mesh_structure: - -======================= -Read the mesh structure -======================= - - - From 8e1075400fc141056a9b6c55d970764754322d56 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 14:53:44 +0100 Subject: [PATCH 08/49] updates the read the mesh tut --- doc/source/user_guide/tutorials/mesh/read_mesh.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh.rst b/doc/source/user_guide/tutorials/mesh/read_mesh.rst index 15d330239a..5590920acd 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh.rst @@ -123,6 +123,13 @@ to the entity their are defined at: # Print the element types print(my_el_types) +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_el_types = my_meshed_region_1.property_field(property_name="eltype") + print(my_el_types) .. _read_mesh_fluids_lsdyna: From 6be9e21af505a0f28d67edce96d418796927b462 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 16:34:10 +0100 Subject: [PATCH 09/49] add get_specific_part_mesh.rst and split_mesh.rst tutorials --- .../tutorials/mesh/get_specific_part_mesh.rst | 80 ++++++++++++++++++- .../user_guide/tutorials/mesh/index.rst | 12 +-- .../user_guide/tutorials/mesh/split_mesh.rst | 60 ++++++++++++++ 3 files changed, 143 insertions(+), 9 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index a51147e04b..74ab17db32 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -1,6 +1,80 @@ .. _tutorials_get_specific_part_mesh: -=============================== -Get a specific part of the mesh -=============================== +====================================== +Get a mesh split on on different parts +====================================== + +.. |MeshedRegion| replace:: :class:`MeshedRegion ` +.. |MeshesContainer| replace:: :class:`MeshesContainer ` +.. |DataSources| replace:: :class:`Model ` +.. |meshes_provider| replace:: :class:`mesh_provider ` + +This tutorial show how to get meshes split on a given space or time + +You have one operator that can be used to get your split mesh: |meshes_provider| + +Define the |DataSources| +------------------------ + +The |meshes_provider| operator need a |DataSources| object. + +In this part we will download a simulation result file available +in our ``Examples`` package. + +.. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path2 = examples.download_fluent_axial_comp()["flprj"] + # Create the DataSources object + my_data_sources = dpf.DataSources(result_path=result_file_path2) + +Use the |meshes_provider| operator +---------------------------------- + +Instanciate the |meshes_provider| operator. + +.. code-block:: python + + # Instanciate the meshes_provider operator + my_meshes_2 = ops.mesh.meshes_provider(data_sources=my_data_sources).eval() + # Print the meshes + print(my_meshes_2) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + result_file_path2 = examples.download_fluent_axial_comp()["flprj"] + my_data_sources = dpf.DataSources(result_path=result_file_path2) + my_meshes_2 = ops.mesh.meshes_provider(data_sources=my_data_sources).eval() + print(my_meshes_2) + +You can specify the mesh regions you want to get with the ``region_scoping`` argument. +A region corresponds to a zone for Fluid results or a part for LSDyna +results. + +The given meshes can be spatially or temporally varying, it depends on your result file. + +.. code-block:: python + + # Instanciate the meshes_provider operator specifing a region + my_meshes_3 = ops.mesh.meshes_provider(data_sources=my_data_sources, region_scoping=[3,12]).eval() + # Print the meshes + print(my_meshes_3) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_meshes_3 = ops.mesh.meshes_provider(data_sources=my_data_sources, region_scoping=[3,12]).eval() + print(my_meshes_3) diff --git a/doc/source/user_guide/tutorials/mesh/index.rst b/doc/source/user_guide/tutorials/mesh/index.rst index e760deb56e..0171735ebf 100644 --- a/doc/source/user_guide/tutorials/mesh/index.rst +++ b/doc/source/user_guide/tutorials/mesh/index.rst @@ -28,21 +28,21 @@ These tutorials explains how to explore different attributes of a given mesh wit This tutorial explains how to extract the models mesh from a result file - .. grid-item-card:: Read a mesh + .. grid-item-card:: Read and get specific information from a mesh :link: tutorials_read_mesh :link-type: ref :text-align: center This tutorial explains how to access the mesh data and metadata - (data about the elements, nodes, faces ...). + (data about the elements, nodes, faces, region, zone ...) + so it can be manipulated. - .. grid-item-card:: Get a specific part of a mesh - :link: tutorials_get_specific_part_mesh + .. grid-item-card:: Get a mesh split on different parts + :link: tutorials_split_mesh :link-type: ref :text-align: center - This tutorial shows how to to access the data about a specific part of a mesh - (data about a region, zone ...) so it can be manipulated. + This tutorial show how to get meshes split on a given space or time. .. grid-item-card:: Split a mesh :link: tutorials_split_mesh diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index a1ee1d76bf..12ee375abc 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -4,3 +4,63 @@ Split a mesh ============ +This tutorial show how to split a mesh into different meshes. + +.. |MeshedRegion| replace:: :class:`MeshedRegion ` +.. |MeshesContainer| replace:: :class:`MeshesContainer ` +.. |split_mesh| replace:: :class:`split_mesh ` + +The mesh object in DPF is a |MeshedRegion|. If you want to split your mesh you can store them in a |MeshesContainer|. + +You have one operator that can be used to split your mesh: |split_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. + +In this part we will download a simulation result file available +in our ``Examples`` package. + +.. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_1 = examples.find_multishells_rst() + # Create the model + my_model_1 = dpf.Model(data_sources=result_file_path_1) + # Get the mesh + my_meshed_region_1 = my_model_1.metadata.meshed_region + + +Use the |split_mesh| operator +----------------------------- + +The |split_mesh| operator divides a |MeshedRegion| based on a property. +Currently you can split a mesh by material or eltype. + +.. code-block:: python + + # Split the mesh by material + my_meshes_1 = ops..mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() + # Print the meshes + print(my_meshes_1) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + result_file_path_1 = examples.find_multishells_rst() + my_model_1 = dpf.Model(data_sources=result_file_path_1) + my_meshed_region_1 = my_model_1.metadata.meshed_region + my_meshes_1 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() + print(my_meshes_1) From e2111e0c1ebf4627b6844d4306ffbb16f74f4cbc Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 16:36:02 +0100 Subject: [PATCH 10/49] updates on thr get_specific_part_mesh.rst tutorial --- .../user_guide/tutorials/mesh/get_specific_part_mesh.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index 74ab17db32..b170e3bdc8 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -57,9 +57,8 @@ Instanciate the |meshes_provider| operator. my_meshes_2 = ops.mesh.meshes_provider(data_sources=my_data_sources).eval() print(my_meshes_2) -You can specify the mesh regions you want to get with the ``region_scoping`` argument. -A region corresponds to a zone for Fluid results or a part for LSDyna -results. +You can specify the mesh regions you want to get by giving the region id to the ``region_scoping`` argument. +A region corresponds to a zone for Fluid results or a part for LSDyna results. The given meshes can be spatially or temporally varying, it depends on your result file. From 29785f189371173512bf452846ec18e9aff7bc4e Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 18 Nov 2024 17:22:47 +0100 Subject: [PATCH 11/49] updates the create_a_mesh_from_scratch.rst tut --- .../mesh/create_a_mesh_from_scratch.rst | 280 +++++++++++++++++- 1 file changed, 279 insertions(+), 1 deletion(-) diff --git a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst index dc04bccd86..3cef59d0e9 100644 --- a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst +++ b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst @@ -21,10 +21,11 @@ Here we create a parallel piped mesh made of linear hexa elements. Import the necessary modules ---------------------------- -Import the ``ansys.dpf.core`` module, including the operators subpackage +Import the ``ansys.dpf.core`` module, including the operators subpackage and the numpy library .. code-block:: python + import numpy as np from ansys.dpf import core as dpf from ansys.dpf.core import operators as ops @@ -33,13 +34,290 @@ Define the mesh dimensions .. code-block:: python + # Define the mesh dimensions length = 0.1 width = 0.05 depth = 0.1 num_nodes_in_length = 10 num_nodes_in_width = 5 num_nodes_in_depth = 10 + # Create a MeshedRegion object my_meshed_region = dpf.MeshedRegion() +Define the connectivity function +-------------------------------- +To create a mesh we need to define the nodes connectivity. This means to define +the elements and nodes indices connected to each node. +Here we create a function that will find the connectivity of our entities. + +.. code-block:: python + + def search_sequence_numpy(arr, seq): + """Find a sequence in an array and return its index.""" + indexes = np.where(np.isclose(arr, seq[0])) + for index in np.nditer(indexes[0]): + if index % 3 == 0: + if np.allclose(arr[index + 1], seq[1]) and np.allclose(arr[index + 2], seq[2]): + return index + return -1 + +Add nodes +--------- + +Add nodes to the |MeshedRegion| object: + +.. code-block:: python + + node_id = 1 + for i, x in enumerate( + [float(i) * length / float(num_nodes_in_length) for i in range(0, num_nodes_in_length)] + ): + for j, y in enumerate( + [float(i) * width / float(num_nodes_in_width) for i in range(0, num_nodes_in_width)] + ): + for k, z in enumerate( + [float(i) * depth / float(num_nodes_in_depth) for i in range(0, num_nodes_in_depth)] + ): + my_meshed_region.nodes.add_node(node_id, [x, y, z]) + node_id += 1 + +Get the nodes coordinates field + +.. code-block:: python + + my_nodes_coordinates = my_meshed_region.nodes.coordinates_field + +Set the mesh node properties +---------------------------- + +Set the mesh unit: + +.. code-block:: python + + my_meshed_region.unit = "mm" + +Set the nodes coordinates: + +.. code-block:: python + + # Get the nodes coordinates data + my_nodes_coordinates_data = my_nodes_coordinates.data + # As we use the connectivity function we need to get the data as a list + my_nodes_coordinates_data_list = my_nodes_coordinates.data_as_list + # Get the nodes scoping + my_coordinates_scoping = my_nodes_coordinates.scoping + +Add the elements +---------------- + +.. code-block:: python + + element_id = 1 + for i, x in enumerate( + [float(i) * length / float(num_nodes_in_length) for i in range(num_nodes_in_length - 1)] + ): + for j, y in enumerate( + [float(i) * width / float(num_nodes_in_width) for i in range(num_nodes_in_width - 1)] + ): + for k, z in enumerate( + [float(i) * depth / float(num_nodes_in_depth) for i in range(num_nodes_in_depth - 1)] + ): + coord1 = np.array([x, y, z]) + connectivity = [] + for xx in [x, x + length / float(num_nodes_in_length)]: + for yy in [y, y + width / float(num_nodes_in_width)]: + for zz in [z, z + depth / float(num_nodes_in_depth)]: + data_index = search_sequence_numpy(my_nodes_coordinates_data_list, [xx, yy, zz]) + scoping_index = int(data_index / 3) # 3components + connectivity.append(scoping_index) + # rearrange connectivity + tmp = connectivity[2] + connectivity[2] = connectivity[3] + connectivity[3] = tmp + tmp = connectivity[6] + connectivity[6] = connectivity[7] + connectivity[7] = tmp + my_meshed_region.elements.add_solid_element(element_id, connectivity) + element_id += 1 +Plot the mesh +------------- + +.. code-block:: python + + my_meshed_region.plot() + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + import numpy as np + from ansys.dpf import core as dpf + from ansys.dpf.core import operators as ops + length = 0.1 + width = 0.05 + depth = 0.1 + num_nodes_in_length = 10 + num_nodes_in_width = 5 + num_nodes_in_depth = 10 + my_meshed_region = dpf.MeshedRegion() + def search_sequence_numpy(arr, seq): + """Find a sequence in an array and return its index.""" + indexes = np.where(np.isclose(arr, seq[0])) + for index in np.nditer(indexes[0]): + if index % 3 == 0: + if np.allclose(arr[index + 1], seq[1]) and np.allclose(arr[index + 2], seq[2]): + return index + return -1 + node_id = 1 + for i, x in enumerate( + [float(i) * length / float(num_nodes_in_length) for i in range(0, num_nodes_in_length)] + ): + for j, y in enumerate( + [float(i) * width / float(num_nodes_in_width) for i in range(0, num_nodes_in_width)] + ): + for k, z in enumerate( + [float(i) * depth / float(num_nodes_in_depth) for i in range(0, num_nodes_in_depth)] + ): + my_meshed_region.nodes.add_node(node_id, [x, y, z]) + node_id += 1 + my_nodes_coordinates = my_meshed_region.nodes.coordinates_field + my_meshed_region.unit = "mm" + my_nodes_coordinates_data = my_nodes_coordinates.data + my_nodes_coordinates_data_list = my_nodes_coordinates.data_as_list + my_coordinates_scoping = my_nodes_coordinates.scoping + element_id = 1 + for i, x in enumerate( + [float(i) * length / float(num_nodes_in_length) for i in range(num_nodes_in_length - 1)] + ): + for j, y in enumerate( + [float(i) * width / float(num_nodes_in_width) for i in range(num_nodes_in_width - 1)] + ): + for k, z in enumerate( + [float(i) * depth / float(num_nodes_in_depth) for i in range(num_nodes_in_depth - 1)] + ): + coord1 = np.array([x, y, z]) + connectivity = [] + for xx in [x, x + length / float(num_nodes_in_length)]: + for yy in [y, y + width / float(num_nodes_in_width)]: + for zz in [z, z + depth / float(num_nodes_in_depth)]: + data_index = search_sequence_numpy(my_nodes_coordinates_data_list, [xx, yy, zz]) + scoping_index = int(data_index / 3) # 3components + connectivity.append(scoping_index) + # rearrange connectivity + tmp = connectivity[2] + connectivity[2] = connectivity[3] + connectivity[3] = tmp + tmp = connectivity[6] + connectivity[6] = connectivity[7] + connectivity[7] = tmp + my_meshed_region.elements.add_solid_element(element_id, connectivity) + element_id += 1 + my_meshed_region.plot() + +Add data to the mesh +-------------------- + +Here we create a displacement field over time with three time sets: + +- For the first time set, the displacement on each node is the value of its x, y, and z coordinates. +- For the second time set, the displacement on each node is two times the value of its x, y, and z coordinates. +- For the third time set, the displacement on each node is three times the value of its x, y, and z coordinates. + +.. code-block:: python + + # Define the displacement data + num_nodes = my_meshed_region.nodes.n_nodes + time1_array = my_nodes_coordinates_data + time2_array = 2.0 * my_nodes_coordinates_data + time3_array = 3.0 * my_nodes_coordinates_data + + # Create the vector fields + time1_field = dpf.fields_factory.create_3d_vector_field(num_nodes) + time2_field = dpf.fields_factory.create_3d_vector_field(num_nodes) + time3_field = dpf.fields_factory.create_3d_vector_field(num_nodes) + + # Define the fields scoping + time1_field.scoping = my_nodes_coordinates.scoping + time2_field.scoping = my_nodes_coordinates.scoping + time3_field.scoping = my_nodes_coordinates.scoping + + # Define the fields data + time1_field.data = time1_array + time2_field.data = time2_array + time3_field.data = time3_array + + # Define the fields unit + time1_field.unit = my_meshed_region.unit + time2_field.unit = my_meshed_region.unit + time3_field.unit = my_meshed_region.unit + + +Create results over times in a fields container with its time frequency support: + +.. code-block:: python + + my_disp_fc = dpf.fields_container_factory.over_time_freq_fields_container( + {0.1: time1_field, 0.2: time2_field, 0.3: time3_field}, "s" + ) + +Check that the time frequency support has been built: + +.. code-block:: python + + print(my_disp_fc.time_freq_support) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + num_nodes = my_meshed_region.nodes.n_nodes + time1_array = my_nodes_coordinates_data + time2_array = 2.0 * my_nodes_coordinates_data + time3_array = 3.0 * my_nodes_coordinates_data + time1_field = dpf.fields_factory.create_3d_vector_field(num_nodes) + time2_field = dpf.fields_factory.create_3d_vector_field(num_nodes) + time3_field = dpf.fields_factory.create_3d_vector_field(num_nodes) + time1_field.scoping = my_nodes_coordinates.scoping + time2_field.scoping = my_nodes_coordinates.scoping + time3_field.scoping = my_nodes_coordinates.scoping + time1_field.data = time1_array + time2_field.data = time2_array + time3_field.data = time3_array + time1_field.unit = my_meshed_region.unit + time2_field.unit = my_meshed_region.unit + time3_field.unit = my_meshed_region.unit + my_disp_fc = dpf.fields_container_factory.over_time_freq_fields_container( + {0.1: time1_field, 0.2: time2_field, 0.3: time3_field}, "s" + ) + print(my_disp_fc.time_freq_support) + +Plot the data on the mesh +------------------------- + +Get the norm over time of the fields container: + +.. code-block:: python + + my_disp_norm = ops.math.norm_fc(fields_container=my_disp_fc).eval() + +Plot the displacement data on the mesh + +.. code-block:: python + + my_meshed_region.plot(my_disp_norm.get_field_by_time_complex_ids(1)) + my_meshed_region.plot(my_disp_norm.get_field_by_time_complex_ids(2)) + my_meshed_region.plot(my_disp_norm.get_field_by_time_complex_ids(3)) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + my_disp_norm = ops.math.norm_fc(fields_container=my_disp_fc).eval() + my_meshed_region.plot(my_disp_norm.get_field_by_time_id(1)) + my_meshed_region.plot(my_disp_norm.get_field_by_time_id(2)) + my_meshed_region.plot(my_disp_norm.get_field_by_time_id(3)) \ No newline at end of file From 58e03642c2088bc3da9a11614b6f18df04d9a608 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 19 Nov 2024 15:11:31 +0100 Subject: [PATCH 12/49] erases add and plot data parts from the create_a_mesh_from_scratch.rst tutorial --- .../mesh/create_a_mesh_from_scratch.rst | 107 +----------------- 1 file changed, 1 insertion(+), 106 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst index 3cef59d0e9..9bfc8f017f 100644 --- a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst +++ b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst @@ -215,109 +215,4 @@ Plot the mesh connectivity[7] = tmp my_meshed_region.elements.add_solid_element(element_id, connectivity) element_id += 1 - my_meshed_region.plot() - -Add data to the mesh --------------------- - -Here we create a displacement field over time with three time sets: - -- For the first time set, the displacement on each node is the value of its x, y, and z coordinates. -- For the second time set, the displacement on each node is two times the value of its x, y, and z coordinates. -- For the third time set, the displacement on each node is three times the value of its x, y, and z coordinates. - -.. code-block:: python - - # Define the displacement data - num_nodes = my_meshed_region.nodes.n_nodes - time1_array = my_nodes_coordinates_data - time2_array = 2.0 * my_nodes_coordinates_data - time3_array = 3.0 * my_nodes_coordinates_data - - # Create the vector fields - time1_field = dpf.fields_factory.create_3d_vector_field(num_nodes) - time2_field = dpf.fields_factory.create_3d_vector_field(num_nodes) - time3_field = dpf.fields_factory.create_3d_vector_field(num_nodes) - - # Define the fields scoping - time1_field.scoping = my_nodes_coordinates.scoping - time2_field.scoping = my_nodes_coordinates.scoping - time3_field.scoping = my_nodes_coordinates.scoping - - # Define the fields data - time1_field.data = time1_array - time2_field.data = time2_array - time3_field.data = time3_array - - # Define the fields unit - time1_field.unit = my_meshed_region.unit - time2_field.unit = my_meshed_region.unit - time3_field.unit = my_meshed_region.unit - - -Create results over times in a fields container with its time frequency support: - -.. code-block:: python - - my_disp_fc = dpf.fields_container_factory.over_time_freq_fields_container( - {0.1: time1_field, 0.2: time2_field, 0.3: time3_field}, "s" - ) - -Check that the time frequency support has been built: - -.. code-block:: python - - print(my_disp_fc.time_freq_support) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - num_nodes = my_meshed_region.nodes.n_nodes - time1_array = my_nodes_coordinates_data - time2_array = 2.0 * my_nodes_coordinates_data - time3_array = 3.0 * my_nodes_coordinates_data - time1_field = dpf.fields_factory.create_3d_vector_field(num_nodes) - time2_field = dpf.fields_factory.create_3d_vector_field(num_nodes) - time3_field = dpf.fields_factory.create_3d_vector_field(num_nodes) - time1_field.scoping = my_nodes_coordinates.scoping - time2_field.scoping = my_nodes_coordinates.scoping - time3_field.scoping = my_nodes_coordinates.scoping - time1_field.data = time1_array - time2_field.data = time2_array - time3_field.data = time3_array - time1_field.unit = my_meshed_region.unit - time2_field.unit = my_meshed_region.unit - time3_field.unit = my_meshed_region.unit - my_disp_fc = dpf.fields_container_factory.over_time_freq_fields_container( - {0.1: time1_field, 0.2: time2_field, 0.3: time3_field}, "s" - ) - print(my_disp_fc.time_freq_support) - -Plot the data on the mesh -------------------------- - -Get the norm over time of the fields container: - -.. code-block:: python - - my_disp_norm = ops.math.norm_fc(fields_container=my_disp_fc).eval() - -Plot the displacement data on the mesh - -.. code-block:: python - - my_meshed_region.plot(my_disp_norm.get_field_by_time_complex_ids(1)) - my_meshed_region.plot(my_disp_norm.get_field_by_time_complex_ids(2)) - my_meshed_region.plot(my_disp_norm.get_field_by_time_complex_ids(3)) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_disp_norm = ops.math.norm_fc(fields_container=my_disp_fc).eval() - my_meshed_region.plot(my_disp_norm.get_field_by_time_id(1)) - my_meshed_region.plot(my_disp_norm.get_field_by_time_id(2)) - my_meshed_region.plot(my_disp_norm.get_field_by_time_id(3)) \ No newline at end of file + my_meshed_region.plot() \ No newline at end of file From b5f536568859f5917a45f78c3ac83bdf0cf06cc0 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 19 Nov 2024 15:16:40 +0100 Subject: [PATCH 13/49] update references in get_mesh_from_result_file.rst tutorial --- .../user_guide/tutorials/mesh/get_mesh_from_result_file.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 9c22562627..65942946fc 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -9,7 +9,7 @@ Get a mesh from a result file .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |Model| replace:: :class:`Model ` .. |DataSources| replace:: :class:`Model ` -.. |mesh_provider| replace:: ` +.. |mesh_provider| replace:: :class:`mesh_provider ` 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. From 79d57f858ec078b36ca63c51cfbedd107bc4d0f8 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 19 Nov 2024 15:23:03 +0100 Subject: [PATCH 14/49] update references in read_mesh.rst tutorial --- doc/source/user_guide/tutorials/mesh/read_mesh.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh.rst b/doc/source/user_guide/tutorials/mesh/read_mesh.rst index 5590920acd..03fe0916a7 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh.rst @@ -70,7 +70,7 @@ The mesh information includes : Check all the information you can get at: |MeshedRegion|. When instantiating the nodes, element, faces and named selection you get the correspondent DPF objects: -|Nodes|,|Elements|,|Faces| and |Scoping|. For example: +|Nodes|, |Elements|, |Faces| and |Scoping|. For example: .. code-block:: python From f34dd4dd0d2152a928bfcba1f191cbdad3080f95 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 19 Nov 2024 16:14:58 +0100 Subject: [PATCH 15/49] add second approach to the split_mesh.rst tutorial --- .../user_guide/tutorials/mesh/split_mesh.rst | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index 12ee375abc..d62caaff38 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -9,10 +9,19 @@ This tutorial show how to split a mesh into different meshes. .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |MeshesContainer| replace:: :class:`MeshesContainer ` .. |split_mesh| replace:: :class:`split_mesh ` +.. |split_on_property_type| replace:: :class:`split_on_property_type ` +.. |from_scopings| replace:: :class:`from_scopings ` +.. |DataSources| replace:: :class:`Model ` +.. |Scoping| replace:: :class:`Scoping ` +.. |ScopingsContainer| replace:: :class:`ScopingsContainer ` -The mesh object in DPF is a |MeshedRegion|. If you want to split your mesh you can store them in a |MeshesContainer|. +The mesh object in DPF is a |MeshedRegion|. If you want to split your mesh you can store them in a |MeshedRegion|. -You have one operator that can be used to split your mesh: |split_mesh| +You have two approaches to split your mesh: + +1) Using the |split_mesh|, to split a already existing |MeshedRegion| into a MeshesContainer; +2) Split the scoping with the |split_on_property_type| operator and than creating the |MeshedRegion| + objects with the |from_scopings| operator. Define the mesh --------------- @@ -37,11 +46,10 @@ in our ``Examples`` package. # Get the mesh my_meshed_region_1 = my_model_1.metadata.meshed_region +1) First approach +----------------- -Use the |split_mesh| operator ------------------------------ - -The |split_mesh| operator divides a |MeshedRegion| based on a property. +Use the |split_mesh| operator to split a already existing |MeshedRegion| into a MeshesContainer based on a property. Currently you can split a mesh by material or eltype. .. code-block:: python @@ -64,3 +72,31 @@ Currently you can split a mesh by material or eltype. my_meshed_region_1 = my_model_1.metadata.meshed_region my_meshes_1 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() print(my_meshes_1) + +2) Second approach +------------------ + +Use the |split_on_property_type| operator to split the scoping and then creating the |MeshedRegion| +objects with the |from_scopings| operator. + +The |split_on_property_type| a given |Scoping| on given properties (elshape and/or material, since 2025R1 +it supports any scalar property field name contained in the mesh property fields) and returns a |ScopingsContainer| +with those split scopings. + +.. code-block:: python + + # Define the scoping split by material + split_scoping = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() + # Get the split meshes + my_meshes_2 = ops.mesh.from_scopings(scopings_container=split_scoping,mesh=my_meshed_region_1).eval() + # Print the meshes + print(my_meshes_2) + +.. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + split_scoping = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() + my_meshes_2 = ops.mesh.from_scopings(scopings_container=split_scoping,mesh=my_meshed_region_1).eval() + print(my_meshes_2) From 871f90d23a48a006677adfb46321050d25edfd63 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 19 Nov 2024 16:17:45 +0100 Subject: [PATCH 16/49] updates on get_specific_part_mesh.rst --- .../tutorials/mesh/get_specific_part_mesh.rst | 10 +++++----- doc/source/user_guide/tutorials/mesh/index.rst | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index b170e3bdc8..729523c6a3 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -1,15 +1,15 @@ .. _tutorials_get_specific_part_mesh: -====================================== -Get a mesh split on on different parts -====================================== +=================================== +Get a mesh split on different parts +=================================== .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |MeshesContainer| replace:: :class:`MeshesContainer ` .. |DataSources| replace:: :class:`Model ` .. |meshes_provider| replace:: :class:`mesh_provider ` -This tutorial show how to get meshes split on a given space or time +This tutorial show how to get meshes split on a given space or time for Fluent, CFX or LSDYNA result files. You have one operator that can be used to get your split mesh: |meshes_provider| @@ -64,7 +64,7 @@ The given meshes can be spatially or temporally varying, it depends on your resu .. code-block:: python - # Instanciate the meshes_provider operator specifing a region + # Instanciate the meshes_provider operator specifying a region my_meshes_3 = ops.mesh.meshes_provider(data_sources=my_data_sources, region_scoping=[3,12]).eval() # Print the meshes print(my_meshes_3) diff --git a/doc/source/user_guide/tutorials/mesh/index.rst b/doc/source/user_guide/tutorials/mesh/index.rst index 0171735ebf..e055706c5d 100644 --- a/doc/source/user_guide/tutorials/mesh/index.rst +++ b/doc/source/user_guide/tutorials/mesh/index.rst @@ -37,12 +37,13 @@ These tutorials explains how to explore different attributes of a given mesh wit (data about the elements, nodes, faces, region, zone ...) so it can be manipulated. - .. grid-item-card:: Get a mesh split on different parts + .. grid-item-card:: Extract a mesh in split parts :link: tutorials_split_mesh :link-type: ref :text-align: center - This tutorial show how to get meshes split on a given space or time. + This tutorial show how to get meshes split on a given space or time for Fluent, + CFX or LSDYNA result files. .. grid-item-card:: Split a mesh :link: tutorials_split_mesh From 56bd2907b022ef62434480e07c125c7b5e218acd Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 11:05:34 +0100 Subject: [PATCH 17/49] put a tab for each solver --- .../mesh/get_mesh_from_result_file.rst | 316 ++++++++++++++++-- 1 file changed, 282 insertions(+), 34 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 65942946fc..3bb854ce66 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -27,16 +27,63 @@ the :ref:`ref_tutorials_import_data` tutorial section. You have to create a |DataSources| object so the data can be accessed by PyDPF-Core APIs. -.. code-block:: python +.. tab-set:: + + .. tab-item:: MAPDL + + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_1 = examples.find_static_rst() + # Create the DataSources object + my_data_sources_1 = dpf.DataSources(result_path=result_file_path_1) + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + 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") + + .. tab-item:: Fluent + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the DataSources object + my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3) + + .. tab-item:: CFX + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the DataSources object + my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4) - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path = examples.find_static_rst() - # Create the DataSources object - my_data_sources = dpf.DataSources(result_path=result_file_path) Get the mesh from the result file --------------------------------- @@ -64,34 +111,145 @@ for it. Get the |MeshedRegion| by instantiating a |Model| object and accessing its metadata: -.. code-block:: python +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # Create the model + my_model_1 = dpf.Model(data_sources=my_data_sources_1) + # Get the mesh + my_meshed_region_1 = my_model_1.metadata.meshed_region + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Create the model + my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Get the mesh + my_meshed_region_2 = my_model_2.metadata.meshed_region + + .. tab-item:: Fluent - # Create the model - my_model = dpf.Model(data_sources=my_data_sources) - # Get the mesh - my_meshed_region_1 = my_model.metadata.meshed_region + .. code-block:: python + + # Create the model + my_model_3 = dpf.Model(data_sources=my_data_sources_3) + # Get the mesh + my_meshed_region_3 = my_model_3.metadata.meshed_region + + .. tab-item:: CFX + + .. code-block:: python + + # Create the model + my_model_4 = dpf.Model(data_sources=my_data_sources_4) + # Get the mesh + my_meshed_region_4 = my_model_4.metadata.meshed_region Printing the |MeshedRegion| displays the mesh dimensions (number of nodes and elements, unit and elements type): -.. code-block:: python +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # Print the meshed region + print(my_meshed_region_1) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_1 = examples.find_static_rst() + # Create the DataSources object + my_data_sources_1 = dpf.DataSources(result_path=result_file_path_1) + # Create the model + my_model_1 = dpf.Model(data_sources=my_data_sources_1) + # Get the mesh + my_meshed_region_1 = my_model_1.metadata.meshed_region + # Print the meshed region + print(my_meshed_region_1) + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Print the meshed region + print(my_meshed_region_2) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + 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") + # Create the model + my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Get the mesh + my_meshed_region_2 = my_model_2.metadata.meshed_region + # Print the meshed region + print(my_meshed_region_2) + + .. tab-item:: Fluent + + .. code-block:: python + + # Print the meshed region + print(my_meshed_region_3) - # Print the meshed region - print(my_meshed_region_1) + .. rst-class:: sphx-glr-script-out -.. rst-class:: sphx-glr-script-out + .. jupyter-execute:: + :hide-code: - .. jupyter-execute:: - :hide-code: + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the DataSources object + my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3) + # Create the model + my_model_3 = dpf.Model(data_sources=my_data_sources_3) + # Get the mesh + my_meshed_region_3 = my_model_3.metadata.meshed_region + # Print the meshed region + print(my_meshed_region_3) - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - result_file_path = examples.find_static_rst() - my_data_sources = dpf.DataSources(result_path=result_file_path) - my_model = dpf.Model(data_sources=my_data_sources) - my_meshed_region_1 = my_model.metadata.meshed_region - print(my_meshed_region_1) + .. tab-item:: CFX + + .. code-block:: python + + # Print the meshed region + print(my_meshed_region_4) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the DataSources object + my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4) + # Create the model + my_model_4 = dpf.Model(data_sources=my_data_sources_4) + # Get the mesh + my_meshed_region_4 = my_model_4.metadata.meshed_region + # Print the meshed region + print(my_meshed_region_4) .. _get_mesh_mesh_provider: @@ -101,15 +259,105 @@ Using the |mesh_provider| operator Get the |MeshedRegion| by instantiating the |mesh_provider| operator and instantiating it with a |DataSources| object as an argument: -.. code-block:: python +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # Get the mesh with the mesh_provider operator + my_meshed_region_12 = ops.mesh.mesh_provider(data_sources=my_data_sources_1).eval() + + .. tab-item:: LSDYNA + + .. code-block:: python - # Get the mesh with the mesh_provider operator - my_meshed_region_2 = ops.mesh.mesh_provider(data_sources=my_data_sources).eval() + # Get the mesh with the mesh_provider operator + my_meshed_region_22 = ops.mesh.mesh_provider(data_sources=my_data_sources_2).eval() + + .. tab-item:: Fluent + + .. code-block:: python + + # Get the mesh with the mesh_provider operator + my_meshed_region_32 = ops.mesh.mesh_provider(data_sources=my_data_sources_3).eval() + + .. tab-item:: CFX + + .. code-block:: python + + # Get the mesh with the mesh_provider operator + my_meshed_region_42 = ops.mesh.mesh_provider(data_sources=my_data_sources_4).eval() Printing the |MeshedRegion| displays the mesh dimensions (number of nodes and elements, unit and elements type): -.. code-block:: python +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # Print the meshed region + print(my_meshed_region_12) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the mesh with the mesh_provider operator + my_meshed_region_12 = ops.mesh.mesh_provider(data_sources=my_data_sources_1).eval() + # Print the meshed region + print(my_meshed_region_12) + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Print the meshed region + print(my_meshed_region_22) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the mesh with the mesh_provider operator + my_meshed_region_22 = ops.mesh.mesh_provider(data_sources=my_data_sources_2).eval() + # Print the meshed region + print(my_meshed_region_22) + + .. tab-item:: Fluent + + .. code-block:: python + + # Print the meshed region + print(my_meshed_region_32) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the mesh with the mesh_provider operator + my_meshed_region_32 = ops.mesh.mesh_provider(data_sources=my_data_sources_3).eval() + # Print the meshed region + print(my_meshed_region_32) + + .. tab-item:: CFX + + .. code-block:: python + + # Print the meshed region + print(my_meshed_region_42) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: - # Print the meshed region - print(my_meshed_region_2) \ No newline at end of file + # Get the mesh with the mesh_provider operator + my_meshed_region_42 = ops.mesh.mesh_provider(data_sources=my_data_sources_4).eval() + # Print the meshed region + print(my_meshed_region_42) \ No newline at end of file From 54476a96d28d5a00b4543210fac0582fe0a141ac Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 11:32:19 +0100 Subject: [PATCH 18/49] update --- .../user_guide/tutorials/mesh/get_mesh_from_result_file.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 3bb854ce66..c443aeb07f 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -20,7 +20,7 @@ This tutorial explains how to extract the models mesh from a result file. Import the result file ---------------------- -Here we we will download a result file available in our `Examples` package. +Here we we will download result files 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. From af705b2588bd5eccb5a581586f6fa33a4b39b5a8 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 11:45:49 +0100 Subject: [PATCH 19/49] put a tab for each solver in the get_specific_part_mesh.rst tutorial --- .../tutorials/mesh/get_specific_part_mesh.rst | 154 +++++++++++++----- 1 file changed, 115 insertions(+), 39 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index 729523c6a3..f2a8ddbe48 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -9,71 +9,147 @@ Get a mesh split on different parts .. |DataSources| replace:: :class:`Model ` .. |meshes_provider| replace:: :class:`mesh_provider ` -This tutorial show how to get meshes split on a given space or time for Fluent, CFX or LSDYNA result files. +This tutorial show how to get meshes split on a given space or time for Fluent or CFX result files. -You have one operator that can be used to get your split mesh: |meshes_provider| +You have one operator in this case: |meshes_provider| Define the |DataSources| ------------------------ -The |meshes_provider| operator need a |DataSources| object. +The |meshes_provider| operator needs a |DataSources| object. -In this part we will download a simulation result file available +In this part we will download simulation result files available in our ``Examples`` package. -.. code-block:: python +.. tab-set:: - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path2 = examples.download_fluent_axial_comp()["flprj"] - # Create the DataSources object - my_data_sources = dpf.DataSources(result_path=result_file_path2) + .. tab-item:: Fluent + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the DataSources object + my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3) + + .. tab-item:: CFX + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the DataSources object + my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4) Use the |meshes_provider| operator ---------------------------------- Instanciate the |meshes_provider| operator. -.. code-block:: python +.. tab-set:: + + .. tab-item:: Fluent + + .. code-block:: python + + # Instanciate the meshes_provider operator + my_meshes_31 = ops.mesh.meshes_provider(data_sources=my_data_sources_3).eval() + # Print the meshes + print(my_meshes_31) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the DataSources object + my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3) + # Instanciate the meshes_provider operator + my_meshes_31 = ops.mesh.meshes_provider(data_sources=my_data_sources_3).eval() + # Print the meshes + print(my_meshes_31) - # Instanciate the meshes_provider operator - my_meshes_2 = ops.mesh.meshes_provider(data_sources=my_data_sources).eval() - # Print the meshes - print(my_meshes_2) + .. tab-item:: CFX -.. rst-class:: sphx-glr-script-out + .. code-block:: python - .. jupyter-execute:: - :hide-code: + # Instanciate the meshes_provider operator + my_meshes_41 = ops.mesh.meshes_provider(data_sources=my_data_sources_4).eval() + # Print the meshes + print(my_meshes_41) - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - result_file_path2 = examples.download_fluent_axial_comp()["flprj"] - my_data_sources = dpf.DataSources(result_path=result_file_path2) - my_meshes_2 = ops.mesh.meshes_provider(data_sources=my_data_sources).eval() - print(my_meshes_2) + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the DataSources object + my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4) + # Instanciate the meshes_provider operator + my_meshes_41 = ops.mesh.meshes_provider(data_sources=my_data_sources_4).eval() + # Print the meshes + print(my_meshes_41) + +Scope the regions to be extracted +--------------------------------- You can specify the mesh regions you want to get by giving the region id to the ``region_scoping`` argument. -A region corresponds to a zone for Fluid results or a part for LSDyna results. +A region corresponds to a zone for Fluid results. The given meshes can be spatially or temporally varying, it depends on your result file. -.. code-block:: python +.. tab-set:: + + .. tab-item:: Fluent + + .. code-block:: python + + # Instanciate the meshes_provider operator and specify a region + my_meshes_32 = ops.mesh.meshes_provider(data_sources=my_data_sources_3, region_scoping=[3,12]).eval() + # Print the meshes + print(my_meshes_32) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Instanciate the meshes_provider operator specifying a region + my_meshes_32 = ops.mesh.meshes_provider(data_sources=my_data_sources_3, region_scoping=[3,12]).eval() + # Print the meshes + print(my_meshes_32) + + .. tab-item:: CFX - # Instanciate the meshes_provider operator specifying a region - my_meshes_3 = ops.mesh.meshes_provider(data_sources=my_data_sources, region_scoping=[3,12]).eval() - # Print the meshes - print(my_meshes_3) + .. code-block:: python -.. rst-class:: sphx-glr-script-out + # Instanciate the meshes_provider operator specifying a region + my_meshes_42 = ops.mesh.meshes_provider(data_sources=my_data_sources_4, region_scoping=[5,8]).eval() + # Print the meshes + print(my_meshes_42) - .. jupyter-execute:: - :hide-code: + .. rst-class:: sphx-glr-script-out - my_meshes_3 = ops.mesh.meshes_provider(data_sources=my_data_sources, region_scoping=[3,12]).eval() - print(my_meshes_3) + .. jupyter-execute:: + :hide-code: + # Instanciate the meshes_provider operator specifying a region + my_meshes_42 = ops.mesh.meshes_provider(data_sources=my_data_sources_4, region_scoping=[5,8]).eval() + # Print the meshes + print(my_meshes_42) From 9338b6e76bdee2ad21456862487d4d791e55eeb3 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 11:46:44 +0100 Subject: [PATCH 20/49] put a tab for each solver in the split_mesh.rst tutorial --- .../user_guide/tutorials/mesh/split_mesh.rst | 298 +++++++++++++++--- 1 file changed, 255 insertions(+), 43 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index d62caaff38..e78ae89fda 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -21,7 +21,7 @@ You have two approaches to split your mesh: 1) Using the |split_mesh|, to split a already existing |MeshedRegion| into a MeshesContainer; 2) Split the scoping with the |split_on_property_type| operator and than creating the |MeshedRegion| - objects with the |from_scopings| operator. + objects with the |from_scopings| operator. Define the mesh --------------- @@ -30,21 +30,75 @@ The mesh object in DPF is a |MeshedRegion|. You can obtain a |MeshedRegion| by c 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. -In this part we will download a simulation result file available +In this part we will download simulation result files available in our ``Examples`` package. -.. code-block:: python +.. tab-set:: - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path_1 = examples.find_multishells_rst() - # Create the model - my_model_1 = dpf.Model(data_sources=result_file_path_1) - # Get the mesh - my_meshed_region_1 = my_model_1.metadata.meshed_region + .. tab-item:: MAPDL + + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_1 = examples.find_static_rst() + # Create the model + my_model_1 = dpf.Model(data_sources=result_file_path_1) + # Get the mesh + my_meshed_region_1 = my_model_1.metadata.meshed_region + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + 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") + # Create the model + my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Get the mesh + my_meshed_region_2 = my_model_2.metadata.meshed_region + + .. tab-item:: Fluent + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the model + my_model_3 = dpf.Model(data_sources=result_file_path_3) + # Get the mesh + my_meshed_region_3 = my_model_3.metadata.meshed_region + + .. tab-item:: CFX + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the model + my_model_4 = dpf.Model(data_sources=result_file_path_4) + # Get the mesh + my_meshed_region_4 = my_model_4.metadata.meshed_region 1) First approach ----------------- @@ -52,51 +106,209 @@ in our ``Examples`` package. Use the |split_mesh| operator to split a already existing |MeshedRegion| into a MeshesContainer based on a property. Currently you can split a mesh by material or eltype. -.. code-block:: python +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # Split the mesh by material + my_meshes_11 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() + # Print the meshes + print(my_meshes_11) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + result_file_path_1 = examples.find_multishells_rst() + my_model_1 = dpf.Model(data_sources=result_file_path_1) + my_meshed_region_1 = my_model_1.metadata.meshed_region + my_meshes_11 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() + print(my_meshes_11) + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Split the mesh by material + my_meshes_21 = ops.mesh.split_mesh(mesh=my_meshed_region_2,property="mat").eval() + # Print the meshes + print(my_meshes_21) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + 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") + # Create the model + my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Get the mesh + my_meshed_region_2 = my_model_2.metadata.meshed_region + # Split the mesh by material + my_meshes_21 = ops.mesh.split_mesh(mesh=my_meshed_region_2,property="mat").eval() + # Print the meshes + print(my_meshes_21) + + .. tab-item:: Fluent + + .. code-block:: python - # Split the mesh by material - my_meshes_1 = ops..mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() - # Print the meshes - print(my_meshes_1) + # Split the mesh by material + my_meshes_31 = ops.mesh.split_mesh(mesh=my_meshed_region_3,property="mat").eval() + # Print the meshes + print(my_meshes_31) -.. rst-class:: sphx-glr-script-out + .. rst-class:: sphx-glr-script-out - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: + :hide-code: - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - result_file_path_1 = examples.find_multishells_rst() - my_model_1 = dpf.Model(data_sources=result_file_path_1) - my_meshed_region_1 = my_model_1.metadata.meshed_region - my_meshes_1 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() - print(my_meshes_1) + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the model + my_model_3 = dpf.Model(data_sources=result_file_path_3) + # Get the mesh + my_meshed_region_3 = my_model_3.metadata.meshed_region + # Split the mesh by material + my_meshes_31 = ops.mesh.split_mesh(mesh=my_meshed_region_3,property="mat").eval() + # Print the meshes + print(my_meshes_31) + + .. tab-item:: CFX + + .. code-block:: python + + # Split the mesh by material + my_meshes_41 = ops.mesh.split_mesh(mesh=my_meshed_region_4,property="mat").eval() + # Print the meshes + print(my_meshes_41) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the model + my_model_4 = dpf.Model(data_sources=result_file_path_4) + # Get the mesh + my_meshed_region_4 = my_model_4.metadata.meshed_region + # Split the mesh by material + my_meshes_41 = ops.mesh.split_mesh(mesh=my_meshed_region_4,property="mat").eval() + # Print the meshes + print(my_meshes_41) 2) Second approach ------------------ -Use the |split_on_property_type| operator to split the scoping and then creating the |MeshedRegion| +Use the |split_on_property_type| operator to split the scoping and then create the |MeshedRegion| objects with the |from_scopings| operator. The |split_on_property_type| a given |Scoping| on given properties (elshape and/or material, since 2025R1 it supports any scalar property field name contained in the mesh property fields) and returns a |ScopingsContainer| with those split scopings. -.. code-block:: python +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # Define the scoping split by material + split_scoping_1 = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() + # Get the split meshes + my_meshes_12 = ops.mesh.from_scopings(scopings_container=split_scoping_1,mesh=my_meshed_region_1).eval() + # Print the meshes + print(my_meshes_12) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the scoping split by material + split_scoping_1 = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() + # Get the split meshes + my_meshes_12 = ops.mesh.from_scopings(scopings_container=split_scoping_1,mesh=my_meshed_region_1).eval() + # Print the meshes + print(my_meshes_12) + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Define the scoping split by material + split_scoping_2 = ops.scoping.split_on_property_type(mesh=my_meshed_region_2, label1="mat").eval() + # Get the split meshes + my_meshes_22 = ops.mesh.from_scopings(scopings_container=split_scoping_2,mesh=my_meshed_region_2).eval() + # Print the meshes + print(my_meshes_22) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the scoping split by material + split_scoping_2 = ops.scoping.split_on_property_type(mesh=my_meshed_region_2, label1="mat").eval() + # Get the split meshes + my_meshes_22 = ops.mesh.from_scopings(scopings_container=split_scoping_2,mesh=my_meshed_region_2).eval() + # Print the meshes + print(my_meshes_22) + + .. tab-item:: Fluent + + .. code-block:: python + + # Define the scoping split by material + split_scoping_3 = ops.scoping.split_on_property_type(mesh=my_meshed_region_3, label1="mat").eval() + # Get the split meshes + my_meshes_32 = ops.mesh.from_scopings(scopings_container=split_scoping_3,mesh=my_meshed_region_3).eval() + # Print the meshes + print(my_meshes_32) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the scoping split by material + split_scoping_3 = ops.scoping.split_on_property_type(mesh=my_meshed_region_3, label1="mat").eval() + # Get the split meshes + my_meshes_32 = ops.mesh.from_scopings(scopings_container=split_scoping_3,mesh=my_meshed_region_3).eval() + # Print the meshes + print(my_meshes_32) + + .. tab-item:: CFX + + .. code-block:: python - # Define the scoping split by material - split_scoping = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() - # Get the split meshes - my_meshes_2 = ops.mesh.from_scopings(scopings_container=split_scoping,mesh=my_meshed_region_1).eval() - # Print the meshes - print(my_meshes_2) + # Define the scoping split by material + split_scoping_4 = ops.scoping.split_on_property_type(mesh=my_meshed_region_4, label1="mat").eval() + # Get the split meshes + my_meshes_42 = ops.mesh.from_scopings(scopings_container=split_scoping_4,mesh=my_meshed_region_4).eval() + # Print the meshes + print(my_meshes_42) -.. rst-class:: sphx-glr-script-out + .. rst-class:: sphx-glr-script-out - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: + :hide-code: - split_scoping = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() - my_meshes_2 = ops.mesh.from_scopings(scopings_container=split_scoping,mesh=my_meshed_region_1).eval() - print(my_meshes_2) + # Define the scoping split by material + split_scoping_4 = ops.scoping.split_on_property_type(mesh=my_meshed_region_4, label1="mat").eval() + # Get the split meshes + my_meshes_42 = ops.mesh.from_scopings(scopings_container=split_scoping_4,mesh=my_meshed_region_4).eval() + # Print the meshes + print(my_meshes_42) From 2e743e9c702ca9355024910dce3fca3ee48e0dcd Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 12:09:46 +0100 Subject: [PATCH 21/49] put a tab for each solver and update the read_mesh_metadata.rst tutorial --- .../tutorials/mesh/read_mesh_metadata.rst | 243 ++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst new file mode 100644 index 0000000000..c51d1d99c4 --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst @@ -0,0 +1,243 @@ +.. _ref_tutorials_read_mesh_metadata: + +====================== +Read the mesh metadata +====================== + +.. |MeshedRegion| replace:: :class:`MeshedRegion ` +.. |Model| replace:: :class:`Model ` +.. |DataSources| replace:: :class:`Model ` +.. |MeshInfo| replace:: :class:`MeshInfo ` + +This tutorial explains how to read a mesh metadata (data about the elements, nodes, faces, region, zone ...) +for LSDYNA, Fluent or CFX result files. + +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. + +We have the |MeshInfo| object to read metadata information before extracting the |MeshedRegion|. +You can obtain this object by creating a |Model| with a result file. + +Define the |Model| +------------------ + +Here we we will download result files 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. + +.. tab-set:: + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + 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") + # Create the model + my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Get the mesh + my_meshed_region_2 = my_model_2.metadata.meshed_region + + .. tab-item:: Fluent + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the model + my_model_3 = dpf.Model(data_sources=result_file_path_3) + # Get the mesh + my_meshed_region_3 = my_model_3.metadata.meshed_region + + .. tab-item:: CFX + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the model + my_model_4 = dpf.Model(data_sources=result_file_path_4) + # Get the mesh + my_meshed_region_4 = my_model_4.metadata.meshed_region + +Read the mesh metadata +---------------------- + +The |Model| is a helper designed to give shortcuts to access the analysis results +metadata, by opening a DataSources or a Streams, and to instanciate results provider +for it. + +From the |Model| you can access the |MeshedRegion| metadata information with the |MeshInfo| object. +The mesh metadata information includes : + +- Properties; +- Parts; +- Faces; +- Bodies; +- Zones; +- Number of nodes and elements; +- Elements types. + +Get the the mesh metadata information and print the available ones: + +.. tab-set:: + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Get the mesh metadata information + my_mesh_info_2 = my_model_2.metadata.mesh_info + # Print the mesh metadata information + print(my_mesh_info_2) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + 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") + # Create the model + my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Get the mesh + my_meshed_region_2 = my_model_2.metadata.meshed_region + # Get the mesh metadata information + my_mesh_info_2 = my_model_2.metadata.mesh_info + # Print the mesh metadata information + print(my_mesh_info_2) + + .. tab-item:: Fluent + + .. code-block:: python + + # Get the mesh metadata information + my_mesh_info_3 = my_model_3.metadata.mesh_info + # Print the mesh metadata information + print(my_mesh_info_3) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the model + my_model_3 = dpf.Model(data_sources=result_file_path_3) + # Get the mesh + my_meshed_region_3 = my_model_3.metadata.meshed_region + # Get the mesh metadata information + my_mesh_info_3 = my_model_3.metadata.mesh_info + # Print the mesh metadata information + print(my_mesh_info_3) + + .. tab-item:: CFX + + .. code-block:: python + + # Get the mesh metadata information + my_mesh_info_4 = my_model_4.metadata.mesh_info + # Print the mesh metadata information + print(my_mesh_info_4) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the model + my_model_4 = dpf.Model(data_sources=result_file_path_4) + # Get the mesh + my_meshed_region_4 = my_model_4.metadata.meshed_region + # Get the mesh metadata information + my_mesh_info_4 = my_model_4.metadata.mesh_info + # Print the mesh metadata information + print(my_mesh_info_4) + +You can extract each of those mesh information by manipulating the |MeshInfo| object properties. +For example we can check the part names (for the LSDYNA result file) or the cell zone names +(for the Fluent or CFX result files): + +.. tab-set:: + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Get the part names + my_cell_zones_2 = my_mesh_info_2.get_property("part_names") + print(my_cell_zones_2) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the part names + my_cell_zones_2 = my_mesh_info_2.get_property("part_names") + print(my_cell_zones_2) + + .. tab-item:: Fluent + + .. code-block:: python + + # Get the cell zone names + my_cell_zones_3 = my_mesh_info_3.get_property("cell_zone_names") + print(my_cell_zones_3) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the cell zone names + my_cell_zones_3 = my_mesh_info_3.get_property("cell_zone_names") + print(my_cell_zones_3) + + .. tab-item:: CFX + + .. code-block:: python + + # Get the cell zone names + my_cell_zones_4 = my_mesh_info_4.get_property("cell_zone_names") + print(my_cell_zones_4) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the cell zone names + my_cell_zones_4 = my_mesh_info_4.get_property("cell_zone_names") + print(my_cell_zones_4) + +For more information on reading a mesh from a LSDYNA, Fluent or CFX file check the examples sections: +:ref:`examples_lsdyna`, :ref:`fluids_examples` and :ref:`examples_cfx`. \ No newline at end of file From 57911810f41c1208ed900cefd7e517ac41bfe618 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 12:56:58 +0100 Subject: [PATCH 22/49] put a tab for each solver and update the explore_mesh.rst tutorial --- .../tutorials/mesh/explore_mesh.rst | 407 ++++++++++++++++++ .../user_guide/tutorials/mesh/read_mesh.rst | 222 ---------- 2 files changed, 407 insertions(+), 222 deletions(-) create mode 100644 doc/source/user_guide/tutorials/mesh/explore_mesh.rst delete mode 100644 doc/source/user_guide/tutorials/mesh/read_mesh.rst diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst new file mode 100644 index 0000000000..2d11c65452 --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst @@ -0,0 +1,407 @@ +.. _tutorials_explore_mesh: + +============== +Explore a mesh +============== + +.. |MeshedRegion| replace:: :class:`MeshedRegion ` +.. |Model| replace:: :class:`Model ` +.. |DataSources| replace:: :class:`Model ` +.. |MeshInfo| replace:: :class:`MeshInfo ` +.. |Nodes| replace:: :class:`Nodes ` +.. |Elements| replace:: :class:`Elements ` +.. |Faces| replace:: :class:`Faces ` +.. |Scoping| replace:: :class:`Scoping ` +.. |PropertyField| replace:: :class:`PropertyField ` + +This tutorial explains how to access the mesh data and metadata (data about the elements, nodes, faces, region, zone ...) +so it can be manipulated. + +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. + +There is a general method to read the |MeshedRegion| by manipulating +the methods of this object. + +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. + +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. + +.. tab-set:: + + .. tab-item:: MAPDL + + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_1 = examples.find_static_rst() + # Create the model + my_model_1 = dpf.Model(data_sources=result_file_path_1) + # Get the mesh + my_meshed_region_1 = my_model_1.metadata.meshed_region + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + 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") + # Create the model + my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Get the mesh + my_meshed_region_2 = my_model_2.metadata.meshed_region + + .. tab-item:: Fluent + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the model + my_model_3 = dpf.Model(data_sources=result_file_path_3) + # Get the mesh + my_meshed_region_3 = my_model_3.metadata.meshed_region + + .. tab-item:: CFX + + .. code-block:: python + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the model + my_model_4 = dpf.Model(data_sources=result_file_path_4) + # Get the mesh + my_meshed_region_4 = my_model_4.metadata.meshed_region + +Read the mesh +------------- + +From the |MeshedRegion| you can access its information by manipulating this object properties. +The mesh information includes : + +- Unit; +- Nodes, elements and faces; +- Named selections; +- Properties. + +Check all the information you can get at: |MeshedRegion|. + +Access the mesh nodes, element, faces and named selection +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When instantiating the nodes, element, faces and named selection you get the correspondent DPF objects: +|Nodes|, |Elements|, |Faces| and |Scoping|. For example: + +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # Get the mesh elements + my_nodes_1 = my_meshed_region_1.nodes + # Print the nodes + print(my_nodes_1) + print("Object type: ",type(my_nodes_1)) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops + # Define the result file + result_file_path_1 = examples.find_static_rst() + # Create the model + my_model_1 = dpf.Model(data_sources=result_file_path_1) + # Get the mesh + my_meshed_region_1 = my_model_1.metadata.meshed_region + # Get the mesh elements + my_nodes_1 = my_meshed_region_1.nodes + # Print the nodes + print(my_nodes_1) + print("Object type: ",type(my_nodes_1)) + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Get the mesh elements + my_nodes_2 = my_meshed_region_2.nodes + # Print the nodes + print(my_nodes_2) + print("Object type: ",type(my_nodes_2)) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + 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") + # Create the model + my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Get the mesh + my_meshed_region_2 = my_model_2.metadata.meshed_region + # Get the mesh elements + my_nodes_2 = my_meshed_region_2.nodes + # Print the nodes + print(my_nodes_2) + print("Object type: ",type(my_nodes_2)) + + .. tab-item:: Fluent + + .. code-block:: python + + # Get the mesh elements + my_nodes_3 = my_meshed_region_3.nodes + # Print the nodes + print(my_nodes_3) + print("Object type: ",type(my_nodes_3)) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the model + my_model_3 = dpf.Model(data_sources=result_file_path_3) + # Get the mesh + my_meshed_region_3 = my_model_3.metadata.meshed_region + # Get the mesh elements + my_nodes_3 = my_meshed_region_3.nodes + # Print the nodes + print(my_nodes_3) + print("Object type: ",type(my_nodes_3)) + + .. tab-item:: CFX + + .. code-block:: python + + # Get the mesh elements + my_nodes_4 = my_meshed_region_4.nodes + # Print the nodes + print(my_nodes_4) + print("Object type: ",type(my_nodes_4)) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Define the result file + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the model + my_model_4 = dpf.Model(data_sources=result_file_path_4) + # Get the mesh + my_meshed_region_4 = my_model_4.metadata.meshed_region + # Get the mesh elements + my_nodes_4 = my_meshed_region_4.nodes + # Print the nodes + print(my_nodes_4) + print("Object type: ",type(my_nodes_4)) + +Access the mesh properties +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When handling properties you can check which are the available ones and also +chose those you want to extract. + +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # Get the available properties + my_available_props_1 = my_meshed_region_1.available_property_fields + # Print the available properties + print(my_available_props_1) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the available properties + my_available_props_1 = my_meshed_region_1.available_property_fields + # Print the available properties + print(my_available_props_1) + + .. tab-item:: LSDYNA + + .. code-block:: python + + # Get the available properties + my_available_props_2 = my_meshed_region_2.available_property_fields + # Print the available properties + print(my_available_props_2) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the available properties + my_available_props_2 = my_meshed_region_2.available_property_fields + # Print the available properties + print(my_available_props_2) + + .. tab-item:: Fluent + + .. code-block:: python + + # Get the available properties + my_available_props_3 = my_meshed_region_3.available_property_fields + # Print the available properties + print(my_available_props_3) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the available properties + my_available_props_3 = my_meshed_region_3.available_property_fields + # Print the available properties + print(my_available_props_3) + + .. tab-item:: CFX + + .. code-block:: python + + # Get the available properties + my_available_props_4 = my_meshed_region_4.available_property_fields + # Print the available properties + print(my_available_props_4) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # Get the available properties + my_available_props_4 = my_meshed_region_4.available_property_fields + # Print the available properties + print(my_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: + +.. tab-set:: + + .. tab-item:: MAPDL + + .. code-block:: python + + # 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) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # 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) + + + .. tab-item:: LSDYNA + + .. code-block:: python + + # 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) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # 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) + + + .. tab-item:: Fluent + + .. code-block:: python + + # 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) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # 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) + + .. tab-item:: CFX + + .. code-block:: python + + # 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) + + .. rst-class:: sphx-glr-script-out + + .. jupyter-execute:: + :hide-code: + + # 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) \ No newline at end of file diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh.rst b/doc/source/user_guide/tutorials/mesh/read_mesh.rst deleted file mode 100644 index 03fe0916a7..0000000000 --- a/doc/source/user_guide/tutorials/mesh/read_mesh.rst +++ /dev/null @@ -1,222 +0,0 @@ -.. _tutorials_read_mesh: - -==================================== -Read the mesh definition information -==================================== - -.. |MeshedRegion| replace:: :class:`MeshedRegion ` -.. |Model| replace:: :class:`Model ` -.. |DataSources| replace:: :class:`Model ` -.. |MeshInfo| replace:: :class:`MeshInfo ` -.. |Nodes| replace:: :class:`Nodes ` -.. |Elements| replace:: :class:`Elements ` -.. |Faces| replace:: :class:`Faces ` -.. |Scoping| replace:: :class:`Scoping ` -.. |PropertyField| replace:: :class:`PropertyField ` - -This tutorial explains how to access and read a 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. - -There is a general method to read the |MeshedRegion| by manipulating -the methods of this object (see :ref: `read_mesh_general` ). - -Nevertheless, if you have a mesh from a LSDYNA, Fluent or CFX file we have a -special object to read more specific metadata information by -exploring the |MeshInfo| object (see :ref: `read_mesh_fluids_lsdyna`). - -.. _read_mesh_general: - -Read a |MeshedRegion| ---------------------- - -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. - -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. - -.. code-block:: python - - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path_1 = examples.find_static_rst() - # Create the model - my_model_1 = dpf.Model(data_sources=result_file_path_1) - # Get the mesh - my_meshed_region_1 = my_model_1.metadata.meshed_region - -Read the mesh -^^^^^^^^^^^^^ - -From the |MeshedRegion| you can access its information by manipulating this object properties. -The mesh information includes : - -- Unit; -- Nodes, elements and faces; -- Named selections; -- Properties. - -Check all the information you can get at: |MeshedRegion|. - -When instantiating the nodes, element, faces and named selection you get the correspondent DPF objects: -|Nodes|, |Elements|, |Faces| and |Scoping|. For example: - -.. code-block:: python - - # Get the mesh elements - my_nodes = my_meshed_region_1.nodes - # Print the nodes - print(my_nodes) - print(type(my_nodes)) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - result_file_path_1 = examples.find_static_rst() - my_model_1 = dpf.Model(data_sources=result_file_path_1) - my_meshed_region_1 = my_model_1.metadata.meshed_region - my_nodes = my_meshed_region_1.nodes - print(my_nodes) - print(type(my_nodes)) - -When handling properties you can check which are the available ones and then -chose those you want to extract. - -.. code-block:: python - - # Get the available properties - my_available_props = my_meshed_region_1.available_property_fields - # Print the available properties - print(my_available_props) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_available_props = my_meshed_region_1.available_property_fields - print(my_available_props) - -When extracting those properties you get a |PropertyField| with that information. Their data is mapped -to the entity their are defined at: - -.. code-block:: python - - # Get the element types on the mesh - my_el_types = my_meshed_region_1.property_field(property_name="eltype") - # Print the element types - print(my_el_types) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_el_types = my_meshed_region_1.property_field(property_name="eltype") - print(my_el_types) - -.. _read_mesh_fluids_lsdyna: - -Read the mesh of a LSDYNA, Fluent or CFX file ---------------------------------------------- - -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. - -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. - -.. code-block:: python - - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path_2 = examples.download_fluent_axial_comp()["flprj"] - # Create the model - my_model_2 = dpf.Model(data_sources=result_file_path_2) - # Get the mesh - my_meshed_region_2 = my_model.metadata.meshed_region - -Read the mesh -^^^^^^^^^^^^^ - -The |Model| is a helper designed to give shortcuts to access the analysis results -metadata, by opening a DataSources or a Streams, and to instanciate results provider -for it. - -From the |Model| you can access the |MeshedRegion| metadata information. The mesh metadata information -includes : - -- Properties; -- Parts; -- Faces; -- Bodies; -- Zones; -- Number of nodes and elements; -- Elements types. - -Get the the mesh metadata information and print the available ones: - -.. code-block:: python - - # Get the mesh metadata information - my_mesh_info = my_model_2.metadata.mesh_info - # Print the mesh metadata information - print(my_mesh_info) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - result_file_path_2 = examples.download_fluent_axial_comp()["flprj"] - my_model_2 = dpf.Model(data_sources=result_file_path_2) - my_meshed_region_2 = my_model_2.metadata.meshed_region - my_mesh_info = my_model_2.metadata.mesh_info - print(my_mesh_info) - -You can access each of those mesh information's by manipulating the |MeshInfo| object properties. -For example we can check the cell zone names: - -.. code-block:: python - - # Get the cell zone names - my_cell_zones = my_mesh_info.get_property("cell_zone_names") - print(my_cell_zones) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_cell_zones = my_mesh_info.get_property("cell_zone_names") - print(my_cell_zones) - -For more information on reading a mesh from a LSDYNA, Fluent or CFX file check the examples sections: -:ref:`fluids_examples` and :ref:`examples_cfx` From 1f7af61d7f9e91850aa3726faeadb9c5d2ffc56a Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 13:02:10 +0100 Subject: [PATCH 23/49] put badge for each solver in the main page cards --- .../user_guide/tutorials/mesh/index.rst | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/index.rst b/doc/source/user_guide/tutorials/mesh/index.rst index e055706c5d..677fb54bdc 100644 --- a/doc/source/user_guide/tutorials/mesh/index.rst +++ b/doc/source/user_guide/tutorials/mesh/index.rst @@ -27,9 +27,24 @@ These tutorials explains how to explore different attributes of a given mesh wit :text-align: center This tutorial explains how to extract the models mesh from a result file + +++ + :bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` - .. grid-item-card:: Read and get specific information from a mesh - :link: tutorials_read_mesh + .. grid-item-card:: Read a mesh metadata + :link: ref_tutorials_read_mesh_metadata + :link-type: ref + :text-align: center + + This tutorial explains how to read a mesh metadata + (data about the elements, nodes, faces, region, zone ...) before + extracting the mesh. + + +++ + :bdg-success:`LSDYNA`:bdg-info:`Fluent` :bdg-light:`CFX` + + + .. grid-item-card:: Explore a mesh + :link: tutorials_explore_mesh :link-type: ref :text-align: center @@ -37,13 +52,19 @@ These tutorials explains how to explore different attributes of a given mesh wit (data about the elements, nodes, faces, region, zone ...) so it can be manipulated. + +++ + :bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` + .. grid-item-card:: Extract a mesh in split parts - :link: tutorials_split_mesh + :link: tutorials_get_specific_part_mesh :link-type: ref :text-align: center This tutorial show how to get meshes split on a given space or time for Fluent, - CFX or LSDYNA result files. + or CFX result files. + + +++ + :bdg-info:`Fluent` :bdg-light:`CFX` .. grid-item-card:: Split a mesh :link: tutorials_split_mesh @@ -52,12 +73,16 @@ These tutorials explains how to explore different attributes of a given mesh wit This tutorial show how to split a mesh into different meshes. + +++ + :bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` + .. toctree:: :maxdepth: 2 :hidden: create_a_mesh_from_scratch.rst get_mesh_from_result_file.rst - read_mesh.rst + read_mesh_metadata.rst + explore_mesh.rst get_specific_part_mesh.rst split_mesh.rst From 189b30829c1054274c06043bf77845094bf2211d Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 13:07:11 +0100 Subject: [PATCH 24/49] put badge for each solver in the beginning of the tutorials --- doc/source/user_guide/tutorials/mesh/explore_mesh.rst | 2 ++ .../user_guide/tutorials/mesh/get_mesh_from_result_file.rst | 2 ++ doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst | 2 ++ doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst | 2 ++ doc/source/user_guide/tutorials/mesh/split_mesh.rst | 2 ++ 5 files changed, 10 insertions(+) diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst index 2d11c65452..0fc303b283 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst @@ -4,6 +4,8 @@ Explore a mesh ============== +:bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` + .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |Model| replace:: :class:`Model ` .. |DataSources| replace:: :class:`Model ` diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index c443aeb07f..603707ebfd 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -4,6 +4,8 @@ Get a mesh from a result file ============================= +:bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` + .. |Field| replace:: :class:`Field` .. |FieldsContainer| replace:: :class:`FieldsContainer` .. |MeshedRegion| replace:: :class:`MeshedRegion ` diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index f2a8ddbe48..ce31dae5f8 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -4,6 +4,8 @@ Get a mesh split on different parts =================================== +:bdg-info:`Fluent` :bdg-light:`CFX` + .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |MeshesContainer| replace:: :class:`MeshesContainer ` .. |DataSources| replace:: :class:`Model ` diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst index c51d1d99c4..dbf99ff87d 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst @@ -4,6 +4,8 @@ Read the mesh metadata ====================== +:bdg-success:`LSDYNA`:bdg-info:`Fluent` :bdg-light:`CFX` + .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |Model| replace:: :class:`Model ` .. |DataSources| replace:: :class:`Model ` diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index e78ae89fda..0d3a415db2 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -4,6 +4,8 @@ Split a mesh ============ +:bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` + This tutorial show how to split a mesh into different meshes. .. |MeshedRegion| replace:: :class:`MeshedRegion ` From 298f134e6f5d8bd58c2764d4aebaee674c84bfbf Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 13:12:49 +0100 Subject: [PATCH 25/49] update title read_mesh_metadata.rst --- doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst index dbf99ff87d..db8b0a675a 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst @@ -1,8 +1,8 @@ .. _ref_tutorials_read_mesh_metadata: -====================== -Read the mesh metadata -====================== +==================== +Read a mesh metadata +==================== :bdg-success:`LSDYNA`:bdg-info:`Fluent` :bdg-light:`CFX` From 4e6e04357aa0dbef957017d76d8b8c3c22a057ce Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 13:16:28 +0100 Subject: [PATCH 26/49] update title get_specific_part_mesh.rst --- .../user_guide/tutorials/mesh/get_specific_part_mesh.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index ce31dae5f8..0d7d628970 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -1,8 +1,8 @@ .. _tutorials_get_specific_part_mesh: -=================================== -Get a mesh split on different parts -=================================== +============================= +Extract a mesh in split parts +============================= :bdg-info:`Fluent` :bdg-light:`CFX` From 56cbec3a911012636973495f4adea2017d029cca Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 20 Nov 2024 13:56:45 +0100 Subject: [PATCH 27/49] update substitution text --- .../user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst | 2 +- .../user_guide/tutorials/mesh/get_mesh_from_result_file.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst index 9bfc8f017f..8e7f5c815c 100644 --- a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst +++ b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst @@ -5,7 +5,7 @@ Create a mesh from scratch ========================== .. |Field| replace:: :class:`Field` -.. |FieldsContainer| replace:: :class:`FieldsContainer` +.. |FieldsContainer| replace:: :class:`FieldsContainer` .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |Model| replace:: :class:`Model ` diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 603707ebfd..8596a7996a 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -7,7 +7,7 @@ Get a mesh from a result file :bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` .. |Field| replace:: :class:`Field` -.. |FieldsContainer| replace:: :class:`FieldsContainer` +.. |FieldsContainer| replace:: :class:`FieldsContainer` .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |Model| replace:: :class:`Model ` .. |DataSources| replace:: :class:`Model ` From f1a93762dbdcaa200b3ef3b26428ca7bb3954e06 Mon Sep 17 00:00:00 2001 From: Luisa Felix Salles Date: Thu, 21 Nov 2024 16:54:51 +0100 Subject: [PATCH 28/49] Update doc/source/user_guide/tutorials/mesh/explore_mesh.rst --- doc/source/user_guide/tutorials/mesh/explore_mesh.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst index 0fc303b283..5056ffd4dc 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst @@ -19,9 +19,6 @@ Explore a mesh This tutorial explains how to access the mesh data and metadata (data about the elements, nodes, faces, region, zone ...) so it can be manipulated. -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. There is a general method to read the |MeshedRegion| by manipulating the methods of this object. From 8b5b5f9d82541c764f8cecf4a28154bf8f0f6d36 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Fri, 22 Nov 2024 11:47:16 +0100 Subject: [PATCH 29/49] use only the jupyter sphinx extension --- .../mesh/create_a_mesh_from_scratch.rst | 87 +------- .../tutorials/mesh/explore_mesh.rst | 190 ++---------------- .../mesh/get_mesh_from_result_file.rst | 150 ++------------ .../tutorials/mesh/get_specific_part_mesh.rst | 64 +----- .../tutorials/mesh/read_mesh_metadata.rst | 101 +--------- .../user_guide/tutorials/mesh/split_mesh.rst | 139 ++----------- 6 files changed, 73 insertions(+), 658 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst index 8e7f5c815c..821bac0250 100644 --- a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst +++ b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst @@ -23,7 +23,7 @@ Import the necessary modules Import the ``ansys.dpf.core`` module, including the operators subpackage and the numpy library -.. code-block:: python +.. jupyter-execute:: import numpy as np from ansys.dpf import core as dpf @@ -32,7 +32,7 @@ Import the ``ansys.dpf.core`` module, including the operators subpackage and the Define the mesh dimensions -------------------------- -.. code-block:: python +.. jupyter-execute:: # Define the mesh dimensions length = 0.1 @@ -52,7 +52,7 @@ the elements and nodes indices connected to each node. Here we create a function that will find the connectivity of our entities. -.. code-block:: python +.. jupyter-execute:: def search_sequence_numpy(arr, seq): """Find a sequence in an array and return its index.""" @@ -68,7 +68,7 @@ Add nodes Add nodes to the |MeshedRegion| object: -.. code-block:: python +.. jupyter-execute:: node_id = 1 for i, x in enumerate( @@ -85,7 +85,7 @@ Add nodes to the |MeshedRegion| object: Get the nodes coordinates field -.. code-block:: python +.. jupyter-execute:: my_nodes_coordinates = my_meshed_region.nodes.coordinates_field @@ -94,13 +94,13 @@ Set the mesh node properties Set the mesh unit: -.. code-block:: python +.. jupyter-execute:: my_meshed_region.unit = "mm" Set the nodes coordinates: -.. code-block:: python +.. jupyter-execute:: # Get the nodes coordinates data my_nodes_coordinates_data = my_nodes_coordinates.data @@ -112,7 +112,7 @@ Set the nodes coordinates: Add the elements ---------------- -.. code-block:: python +.. jupyter-execute:: element_id = 1 for i, x in enumerate( @@ -144,75 +144,6 @@ Add the elements Plot the mesh ------------- -.. code-block:: python +.. jupyter-execute:: - my_meshed_region.plot() - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - import numpy as np - from ansys.dpf import core as dpf - from ansys.dpf.core import operators as ops - length = 0.1 - width = 0.05 - depth = 0.1 - num_nodes_in_length = 10 - num_nodes_in_width = 5 - num_nodes_in_depth = 10 - my_meshed_region = dpf.MeshedRegion() - def search_sequence_numpy(arr, seq): - """Find a sequence in an array and return its index.""" - indexes = np.where(np.isclose(arr, seq[0])) - for index in np.nditer(indexes[0]): - if index % 3 == 0: - if np.allclose(arr[index + 1], seq[1]) and np.allclose(arr[index + 2], seq[2]): - return index - return -1 - node_id = 1 - for i, x in enumerate( - [float(i) * length / float(num_nodes_in_length) for i in range(0, num_nodes_in_length)] - ): - for j, y in enumerate( - [float(i) * width / float(num_nodes_in_width) for i in range(0, num_nodes_in_width)] - ): - for k, z in enumerate( - [float(i) * depth / float(num_nodes_in_depth) for i in range(0, num_nodes_in_depth)] - ): - my_meshed_region.nodes.add_node(node_id, [x, y, z]) - node_id += 1 - my_nodes_coordinates = my_meshed_region.nodes.coordinates_field - my_meshed_region.unit = "mm" - my_nodes_coordinates_data = my_nodes_coordinates.data - my_nodes_coordinates_data_list = my_nodes_coordinates.data_as_list - my_coordinates_scoping = my_nodes_coordinates.scoping - element_id = 1 - for i, x in enumerate( - [float(i) * length / float(num_nodes_in_length) for i in range(num_nodes_in_length - 1)] - ): - for j, y in enumerate( - [float(i) * width / float(num_nodes_in_width) for i in range(num_nodes_in_width - 1)] - ): - for k, z in enumerate( - [float(i) * depth / float(num_nodes_in_depth) for i in range(num_nodes_in_depth - 1)] - ): - coord1 = np.array([x, y, z]) - connectivity = [] - for xx in [x, x + length / float(num_nodes_in_length)]: - for yy in [y, y + width / float(num_nodes_in_width)]: - for zz in [z, z + depth / float(num_nodes_in_depth)]: - data_index = search_sequence_numpy(my_nodes_coordinates_data_list, [xx, yy, zz]) - scoping_index = int(data_index / 3) # 3components - connectivity.append(scoping_index) - # rearrange connectivity - tmp = connectivity[2] - connectivity[2] = connectivity[3] - connectivity[3] = tmp - tmp = connectivity[6] - connectivity[6] = connectivity[7] - connectivity[7] = tmp - my_meshed_region.elements.add_solid_element(element_id, connectivity) - element_id += 1 my_meshed_region.plot() \ No newline at end of file diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst index 5056ffd4dc..f51a2a458d 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst @@ -38,8 +38,7 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. tab-item:: MAPDL - - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -54,7 +53,7 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -73,7 +72,7 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -88,7 +87,7 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -124,7 +123,7 @@ When instantiating the nodes, element, faces and named selection you get the cor .. tab-item:: MAPDL - .. code-block:: python + .. jupyter-execute:: # Get the mesh elements my_nodes_1 = my_meshed_region_1.nodes @@ -132,30 +131,9 @@ When instantiating the nodes, element, faces and named selection you get the cor print(my_nodes_1) print("Object type: ",type(my_nodes_1)) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path_1 = examples.find_static_rst() - # Create the model - my_model_1 = dpf.Model(data_sources=result_file_path_1) - # Get the mesh - my_meshed_region_1 = my_model_1.metadata.meshed_region - # Get the mesh elements - my_nodes_1 = my_meshed_region_1.nodes - # Print the nodes - print(my_nodes_1) - print("Object type: ",type(my_nodes_1)) - .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Get the mesh elements my_nodes_2 = my_meshed_region_2.nodes @@ -163,30 +141,9 @@ When instantiating the nodes, element, faces and named selection you get the cor print(my_nodes_2) print("Object type: ",type(my_nodes_2)) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Define the result file - 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") - # Create the model - my_model_2 = dpf.Model(data_sources=my_data_sources_2) - # Get the mesh - my_meshed_region_2 = my_model_2.metadata.meshed_region - # Get the mesh elements - my_nodes_2 = my_meshed_region_2.nodes - # Print the nodes - print(my_nodes_2) - print("Object type: ",type(my_nodes_2)) - .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Get the mesh elements my_nodes_3 = my_meshed_region_3.nodes @@ -194,26 +151,9 @@ When instantiating the nodes, element, faces and named selection you get the cor print(my_nodes_3) print("Object type: ",type(my_nodes_3)) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Define the result file - result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] - # Create the model - my_model_3 = dpf.Model(data_sources=result_file_path_3) - # Get the mesh - my_meshed_region_3 = my_model_3.metadata.meshed_region - # Get the mesh elements - my_nodes_3 = my_meshed_region_3.nodes - # Print the nodes - print(my_nodes_3) - print("Object type: ",type(my_nodes_3)) - .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Get the mesh elements my_nodes_4 = my_meshed_region_4.nodes @@ -221,23 +161,6 @@ When instantiating the nodes, element, faces and named selection you get the cor print(my_nodes_4) print("Object type: ",type(my_nodes_4)) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Define the result file - result_file_path_4 = examples.download_cfx_mixing_elbow() - # Create the model - my_model_4 = dpf.Model(data_sources=result_file_path_4) - # Get the mesh - my_meshed_region_4 = my_model_4.metadata.meshed_region - # Get the mesh elements - my_nodes_4 = my_meshed_region_4.nodes - # Print the nodes - print(my_nodes_4) - print("Object type: ",type(my_nodes_4)) - Access the mesh properties ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -248,17 +171,7 @@ chose those you want to extract. .. tab-item:: MAPDL - .. code-block:: python - - # Get the available properties - my_available_props_1 = my_meshed_region_1.available_property_fields - # Print the available properties - print(my_available_props_1) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the available properties my_available_props_1 = my_meshed_region_1.available_property_fields @@ -267,17 +180,7 @@ chose those you want to extract. .. tab-item:: LSDYNA - .. code-block:: python - - # Get the available properties - my_available_props_2 = my_meshed_region_2.available_property_fields - # Print the available properties - print(my_available_props_2) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the available properties my_available_props_2 = my_meshed_region_2.available_property_fields @@ -286,17 +189,7 @@ chose those you want to extract. .. tab-item:: Fluent - .. code-block:: python - - # Get the available properties - my_available_props_3 = my_meshed_region_3.available_property_fields - # Print the available properties - print(my_available_props_3) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the available properties my_available_props_3 = my_meshed_region_3.available_property_fields @@ -305,17 +198,7 @@ chose those you want to extract. .. tab-item:: CFX - .. code-block:: python - - # Get the available properties - my_available_props_4 = my_meshed_region_4.available_property_fields - # Print the available properties - print(my_available_props_4) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the available properties my_available_props_4 = my_meshed_region_4.available_property_fields @@ -329,17 +212,7 @@ to the entity they are defined at: .. tab-item:: MAPDL - .. code-block:: python - - # 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) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the element types on the mesh my_el_types_1 = my_meshed_region_1.property_field(property_name="eltype") @@ -349,37 +222,16 @@ to the entity they are defined at: .. tab-item:: LSDYNA - .. code-block:: python - - # 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) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. 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) - .. tab-item:: Fluent - .. code-block:: python - - # 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) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the element types on the mesh my_el_types_3 = my_meshed_region_3.property_field(property_name="eltype") @@ -388,17 +240,7 @@ to the entity they are defined at: .. tab-item:: CFX - .. code-block:: python - - # 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) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the element types on the mesh my_el_types_4 = my_meshed_region_4.property_field(property_name="eltype") diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 8596a7996a..1ee28c3913 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -33,8 +33,7 @@ PyDPF-Core APIs. .. tab-item:: MAPDL - - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -47,7 +46,7 @@ PyDPF-Core APIs. .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -62,7 +61,7 @@ PyDPF-Core APIs. .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -75,7 +74,7 @@ PyDPF-Core APIs. .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -117,7 +116,7 @@ Get the |MeshedRegion| by instantiating a |Model| object and accessing its metad .. tab-item:: MAPDL - .. code-block:: python + .. jupyter-execute:: # Create the model my_model_1 = dpf.Model(data_sources=my_data_sources_1) @@ -126,7 +125,7 @@ Get the |MeshedRegion| by instantiating a |Model| object and accessing its metad .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Create the model my_model_2 = dpf.Model(data_sources=my_data_sources_2) @@ -135,7 +134,7 @@ Get the |MeshedRegion| by instantiating a |Model| object and accessing its metad .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Create the model my_model_3 = dpf.Model(data_sources=my_data_sources_3) @@ -144,7 +143,7 @@ Get the |MeshedRegion| by instantiating a |Model| object and accessing its metad .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Create the model my_model_4 = dpf.Model(data_sources=my_data_sources_4) @@ -158,101 +157,32 @@ unit and elements type): .. tab-item:: MAPDL - .. code-block:: python - - # Print the meshed region - print(my_meshed_region_1) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path_1 = examples.find_static_rst() - # Create the DataSources object - my_data_sources_1 = dpf.DataSources(result_path=result_file_path_1) - # Create the model - my_model_1 = dpf.Model(data_sources=my_data_sources_1) - # Get the mesh - my_meshed_region_1 = my_model_1.metadata.meshed_region # Print the meshed region print(my_meshed_region_1) .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Print the meshed region print(my_meshed_region_2) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Define the result file - 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") - # Create the model - my_model_2 = dpf.Model(data_sources=my_data_sources_2) - # Get the mesh - my_meshed_region_2 = my_model_2.metadata.meshed_region - # Print the meshed region - print(my_meshed_region_2) - .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Print the meshed region print(my_meshed_region_3) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Define the result file - result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] - # Create the DataSources object - my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3) - # Create the model - my_model_3 = dpf.Model(data_sources=my_data_sources_3) - # Get the mesh - my_meshed_region_3 = my_model_3.metadata.meshed_region - # Print the meshed region - print(my_meshed_region_3) - .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Print the meshed region print(my_meshed_region_4) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Define the result file - result_file_path_4 = examples.download_cfx_mixing_elbow() - # Create the DataSources object - my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4) - # Create the model - my_model_4 = dpf.Model(data_sources=my_data_sources_4) - # Get the mesh - my_meshed_region_4 = my_model_4.metadata.meshed_region - # Print the meshed region - print(my_meshed_region_4) - .. _get_mesh_mesh_provider: Using the |mesh_provider| operator @@ -265,28 +195,28 @@ Get the |MeshedRegion| by instantiating the |mesh_provider| operator and instant .. tab-item:: MAPDL - .. code-block:: python + .. jupyter-execute:: # Get the mesh with the mesh_provider operator my_meshed_region_12 = ops.mesh.mesh_provider(data_sources=my_data_sources_1).eval() .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Get the mesh with the mesh_provider operator my_meshed_region_22 = ops.mesh.mesh_provider(data_sources=my_data_sources_2).eval() .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Get the mesh with the mesh_provider operator my_meshed_region_32 = ops.mesh.mesh_provider(data_sources=my_data_sources_3).eval() .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Get the mesh with the mesh_provider operator my_meshed_region_42 = ops.mesh.mesh_provider(data_sources=my_data_sources_4).eval() @@ -298,68 +228,28 @@ unit and elements type): .. tab-item:: MAPDL - .. code-block:: python - - # Print the meshed region - print(my_meshed_region_12) - - .. rst-class:: sphx-glr-script-out + .. jupyter-execute:: - .. jupyter-execute:: - :hide-code: - - # Get the mesh with the mesh_provider operator - my_meshed_region_12 = ops.mesh.mesh_provider(data_sources=my_data_sources_1).eval() # Print the meshed region print(my_meshed_region_12) .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Print the meshed region print(my_meshed_region_22) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Get the mesh with the mesh_provider operator - my_meshed_region_22 = ops.mesh.mesh_provider(data_sources=my_data_sources_2).eval() - # Print the meshed region - print(my_meshed_region_22) - .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Print the meshed region print(my_meshed_region_32) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Get the mesh with the mesh_provider operator - my_meshed_region_32 = ops.mesh.mesh_provider(data_sources=my_data_sources_3).eval() - # Print the meshed region - print(my_meshed_region_32) - .. tab-item:: CFX - .. code-block:: python - - # Print the meshed region - print(my_meshed_region_42) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: - # Get the mesh with the mesh_provider operator - my_meshed_region_42 = ops.mesh.mesh_provider(data_sources=my_data_sources_4).eval() # Print the meshed region print(my_meshed_region_42) \ No newline at end of file diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index 0d7d628970..0c56a48df9 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -27,7 +27,7 @@ in our ``Examples`` package. .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -40,7 +40,7 @@ in our ``Examples`` package. .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -60,49 +60,17 @@ Instanciate the |meshes_provider| operator. .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Instanciate the meshes_provider operator my_meshes_31 = ops.mesh.meshes_provider(data_sources=my_data_sources_3).eval() # Print the meshes print(my_meshes_31) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] - # Create the DataSources object - my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3) - # Instanciate the meshes_provider operator - my_meshes_31 = ops.mesh.meshes_provider(data_sources=my_data_sources_3).eval() - # Print the meshes - print(my_meshes_31) - .. tab-item:: CFX - .. code-block:: python - - # Instanciate the meshes_provider operator - my_meshes_41 = ops.mesh.meshes_provider(data_sources=my_data_sources_4).eval() - # Print the meshes - print(my_meshes_41) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: - # Define the result file - result_file_path_4 = examples.download_cfx_mixing_elbow() - # Create the DataSources object - my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4) # Instanciate the meshes_provider operator my_meshes_41 = ops.mesh.meshes_provider(data_sources=my_data_sources_4).eval() # Print the meshes @@ -120,36 +88,16 @@ The given meshes can be spatially or temporally varying, it depends on your resu .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Instanciate the meshes_provider operator and specify a region my_meshes_32 = ops.mesh.meshes_provider(data_sources=my_data_sources_3, region_scoping=[3,12]).eval() # Print the meshes print(my_meshes_32) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Instanciate the meshes_provider operator specifying a region - my_meshes_32 = ops.mesh.meshes_provider(data_sources=my_data_sources_3, region_scoping=[3,12]).eval() - # Print the meshes - print(my_meshes_32) - .. tab-item:: CFX - .. code-block:: python - - # Instanciate the meshes_provider operator specifying a region - my_meshes_42 = ops.mesh.meshes_provider(data_sources=my_data_sources_4, region_scoping=[5,8]).eval() - # Print the meshes - print(my_meshes_42) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Instanciate the meshes_provider operator specifying a region my_meshes_42 = ops.mesh.meshes_provider(data_sources=my_data_sources_4, region_scoping=[5,8]).eval() diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst index db8b0a675a..3be24daee6 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst @@ -32,7 +32,7 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -51,7 +51,7 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -66,7 +66,7 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -103,82 +103,26 @@ Get the the mesh metadata information and print the available ones: .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Get the mesh metadata information my_mesh_info_2 = my_model_2.metadata.mesh_info # Print the mesh metadata information print(my_mesh_info_2) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - 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") - # Create the model - my_model_2 = dpf.Model(data_sources=my_data_sources_2) - # Get the mesh - my_meshed_region_2 = my_model_2.metadata.meshed_region - # Get the mesh metadata information - my_mesh_info_2 = my_model_2.metadata.mesh_info - # Print the mesh metadata information - print(my_mesh_info_2) - .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Get the mesh metadata information my_mesh_info_3 = my_model_3.metadata.mesh_info # Print the mesh metadata information print(my_mesh_info_3) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Define the result file - result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] - # Create the model - my_model_3 = dpf.Model(data_sources=result_file_path_3) - # Get the mesh - my_meshed_region_3 = my_model_3.metadata.meshed_region - # Get the mesh metadata information - my_mesh_info_3 = my_model_3.metadata.mesh_info - # Print the mesh metadata information - print(my_mesh_info_3) - .. tab-item:: CFX - .. code-block:: python - - # Get the mesh metadata information - my_mesh_info_4 = my_model_4.metadata.mesh_info - # Print the mesh metadata information - print(my_mesh_info_4) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: - # Define the result file - result_file_path_4 = examples.download_cfx_mixing_elbow() - # Create the model - my_model_4 = dpf.Model(data_sources=result_file_path_4) - # Get the mesh - my_meshed_region_4 = my_model_4.metadata.meshed_region # Get the mesh metadata information my_mesh_info_4 = my_model_4.metadata.mesh_info # Print the mesh metadata information @@ -192,16 +136,7 @@ For example we can check the part names (for the LSDYNA result file) or the cell .. tab-item:: LSDYNA - .. code-block:: python - - # Get the part names - my_cell_zones_2 = my_mesh_info_2.get_property("part_names") - print(my_cell_zones_2) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the part names my_cell_zones_2 = my_mesh_info_2.get_property("part_names") @@ -209,16 +144,7 @@ For example we can check the part names (for the LSDYNA result file) or the cell .. tab-item:: Fluent - .. code-block:: python - - # Get the cell zone names - my_cell_zones_3 = my_mesh_info_3.get_property("cell_zone_names") - print(my_cell_zones_3) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the cell zone names my_cell_zones_3 = my_mesh_info_3.get_property("cell_zone_names") @@ -226,16 +152,7 @@ For example we can check the part names (for the LSDYNA result file) or the cell .. tab-item:: CFX - .. code-block:: python - - # Get the cell zone names - my_cell_zones_4 = my_mesh_info_4.get_property("cell_zone_names") - print(my_cell_zones_4) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Get the cell zone names my_cell_zones_4 = my_mesh_info_4.get_property("cell_zone_names") diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index 0d3a415db2..c70c5d7b46 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -39,15 +39,14 @@ in our ``Examples`` package. .. tab-item:: MAPDL - - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf from ansys.dpf.core import examples from ansys.dpf.core import operators as ops # Define the result file - result_file_path_1 = examples.find_static_rst() + result_file_path_1 = examples.find_multishells_rst() # Create the model my_model_1 = dpf.Model(data_sources=result_file_path_1) # Get the mesh @@ -55,7 +54,7 @@ in our ``Examples`` package. .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -74,7 +73,7 @@ in our ``Examples`` package. .. tab-item:: Fluent - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -89,7 +88,7 @@ in our ``Examples`` package. .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage from ansys.dpf import core as dpf @@ -112,75 +111,26 @@ Currently you can split a mesh by material or eltype. .. tab-item:: MAPDL - .. code-block:: python + .. jupyter-execute:: # Split the mesh by material my_meshes_11 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() # Print the meshes print(my_meshes_11) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - result_file_path_1 = examples.find_multishells_rst() - my_model_1 = dpf.Model(data_sources=result_file_path_1) - my_meshed_region_1 = my_model_1.metadata.meshed_region - my_meshes_11 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() - print(my_meshes_11) - .. tab-item:: LSDYNA - .. code-block:: python + .. jupyter-execute:: # Split the mesh by material my_meshes_21 = ops.mesh.split_mesh(mesh=my_meshed_region_2,property="mat").eval() # Print the meshes print(my_meshes_21) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - 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") - # Create the model - my_model_2 = dpf.Model(data_sources=my_data_sources_2) - # Get the mesh - my_meshed_region_2 = my_model_2.metadata.meshed_region - # Split the mesh by material - my_meshes_21 = ops.mesh.split_mesh(mesh=my_meshed_region_2,property="mat").eval() - # Print the meshes - print(my_meshes_21) - .. tab-item:: Fluent - .. code-block:: python - - # Split the mesh by material - my_meshes_31 = ops.mesh.split_mesh(mesh=my_meshed_region_3,property="mat").eval() - # Print the meshes - print(my_meshes_31) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: - # Define the result file - result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] - # Create the model - my_model_3 = dpf.Model(data_sources=result_file_path_3) - # Get the mesh - my_meshed_region_3 = my_model_3.metadata.meshed_region # Split the mesh by material my_meshes_31 = ops.mesh.split_mesh(mesh=my_meshed_region_3,property="mat").eval() # Print the meshes @@ -188,28 +138,13 @@ Currently you can split a mesh by material or eltype. .. tab-item:: CFX - .. code-block:: python + .. jupyter-execute:: # Split the mesh by material my_meshes_41 = ops.mesh.split_mesh(mesh=my_meshed_region_4,property="mat").eval() # Print the meshes print(my_meshes_41) - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - # Define the result file - result_file_path_4 = examples.download_cfx_mixing_elbow() - # Create the model - my_model_4 = dpf.Model(data_sources=result_file_path_4) - # Get the mesh - my_meshed_region_4 = my_model_4.metadata.meshed_region - # Split the mesh by material - my_meshes_41 = ops.mesh.split_mesh(mesh=my_meshed_region_4,property="mat").eval() - # Print the meshes - print(my_meshes_41) 2) Second approach ------------------ @@ -225,19 +160,7 @@ with those split scopings. .. tab-item:: MAPDL - .. code-block:: python - - # Define the scoping split by material - split_scoping_1 = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() - # Get the split meshes - my_meshes_12 = ops.mesh.from_scopings(scopings_container=split_scoping_1,mesh=my_meshed_region_1).eval() - # Print the meshes - print(my_meshes_12) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Define the scoping split by material split_scoping_1 = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() @@ -248,19 +171,7 @@ with those split scopings. .. tab-item:: LSDYNA - .. code-block:: python - - # Define the scoping split by material - split_scoping_2 = ops.scoping.split_on_property_type(mesh=my_meshed_region_2, label1="mat").eval() - # Get the split meshes - my_meshes_22 = ops.mesh.from_scopings(scopings_container=split_scoping_2,mesh=my_meshed_region_2).eval() - # Print the meshes - print(my_meshes_22) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Define the scoping split by material split_scoping_2 = ops.scoping.split_on_property_type(mesh=my_meshed_region_2, label1="mat").eval() @@ -271,19 +182,7 @@ with those split scopings. .. tab-item:: Fluent - .. code-block:: python - - # Define the scoping split by material - split_scoping_3 = ops.scoping.split_on_property_type(mesh=my_meshed_region_3, label1="mat").eval() - # Get the split meshes - my_meshes_32 = ops.mesh.from_scopings(scopings_container=split_scoping_3,mesh=my_meshed_region_3).eval() - # Print the meshes - print(my_meshes_32) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Define the scoping split by material split_scoping_3 = ops.scoping.split_on_property_type(mesh=my_meshed_region_3, label1="mat").eval() @@ -294,19 +193,7 @@ with those split scopings. .. tab-item:: CFX - .. code-block:: python - - # Define the scoping split by material - split_scoping_4 = ops.scoping.split_on_property_type(mesh=my_meshed_region_4, label1="mat").eval() - # Get the split meshes - my_meshes_42 = ops.mesh.from_scopings(scopings_container=split_scoping_4,mesh=my_meshed_region_4).eval() - # Print the meshes - print(my_meshes_42) - - .. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: + .. jupyter-execute:: # Define the scoping split by material split_scoping_4 = ops.scoping.split_on_property_type(mesh=my_meshed_region_4, label1="mat").eval() From b9da160c8d6d28c13016957e10c38789ba79e601 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Fri, 22 Nov 2024 11:52:21 +0100 Subject: [PATCH 30/49] updates the examples package references --- doc/source/user_guide/tutorials/mesh/explore_mesh.rst | 3 ++- .../user_guide/tutorials/mesh/get_mesh_from_result_file.rst | 3 ++- .../user_guide/tutorials/mesh/get_specific_part_mesh.rst | 3 ++- doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst | 3 ++- doc/source/user_guide/tutorials/mesh/split_mesh.rst | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst index f51a2a458d..e89feefe89 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst @@ -15,6 +15,7 @@ Explore a mesh .. |Faces| replace:: :class:`Faces ` .. |Scoping| replace:: :class:`Scoping ` .. |PropertyField| replace:: :class:`PropertyField ` +.. |Examples| replace:: :mod:`Examples` This tutorial explains how to access the mesh data and metadata (data about the elements, nodes, faces, region, zone ...) so it can be manipulated. @@ -30,7 +31,7 @@ The mesh object in DPF is a |MeshedRegion|. You can obtain a |MeshedRegion| by c 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. -Here we we will download a result file available in our `Examples` package. +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. diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 1ee28c3913..3203ed680c 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -12,6 +12,7 @@ Get a mesh from a result file .. |Model| replace:: :class:`Model ` .. |DataSources| replace:: :class:`Model ` .. |mesh_provider| replace:: :class:`mesh_provider ` +.. |Examples| replace:: :mod:`Examples` 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. @@ -22,7 +23,7 @@ This tutorial explains how to extract the models mesh from a result file. Import the result file ---------------------- -Here we we will download result files available in our `Examples` package. +Here we we will download result files 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. diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index 0c56a48df9..ae70c33740 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -10,6 +10,7 @@ Extract a mesh in split parts .. |MeshesContainer| replace:: :class:`MeshesContainer ` .. |DataSources| replace:: :class:`Model ` .. |meshes_provider| replace:: :class:`mesh_provider ` +.. |Examples| replace:: :mod:`Examples` This tutorial show how to get meshes split on a given space or time for Fluent or CFX result files. @@ -21,7 +22,7 @@ Define the |DataSources| The |meshes_provider| operator needs a |DataSources| object. In this part we will download simulation result files available -in our ``Examples`` package. +in our |Examples| package. .. tab-set:: diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst index 3be24daee6..4b87c80874 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst @@ -10,6 +10,7 @@ Read a mesh metadata .. |Model| replace:: :class:`Model ` .. |DataSources| replace:: :class:`Model ` .. |MeshInfo| replace:: :class:`MeshInfo ` +.. |Examples| replace:: :mod:`Examples` This tutorial explains how to read a mesh metadata (data about the elements, nodes, faces, region, zone ...) for LSDYNA, Fluent or CFX result files. @@ -24,7 +25,7 @@ You can obtain this object by creating a |Model| with a result file. Define the |Model| ------------------ -Here we we will download result files available in our `Examples` package. +Here we we will download result files 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. diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index c70c5d7b46..7dcd46d047 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -16,6 +16,7 @@ This tutorial show how to split a mesh into different meshes. .. |DataSources| replace:: :class:`Model ` .. |Scoping| replace:: :class:`Scoping ` .. |ScopingsContainer| replace:: :class:`ScopingsContainer ` +.. |Examples| replace:: :mod:`Examples` The mesh object in DPF is a |MeshedRegion|. If you want to split your mesh you can store them in a |MeshedRegion|. @@ -33,7 +34,7 @@ own by scratch or by getting it from a result file. For more information check t :ref:`tutorials_create_a_mesh_from_scratch` and :ref:`tutorials_get_mesh_from_result_file` tutorials. In this part we will download simulation result files available -in our ``Examples`` package. +in our |Examples| package. .. tab-set:: From f03e48e14f63993af85a0c815d4ace8720a011f0 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 3 Dec 2024 16:10:11 +0100 Subject: [PATCH 31/49] update badges in the index.rst --- doc/source/user_guide/tutorials/mesh/index.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/index.rst b/doc/source/user_guide/tutorials/mesh/index.rst index 677fb54bdc..f7d7297f44 100644 --- a/doc/source/user_guide/tutorials/mesh/index.rst +++ b/doc/source/user_guide/tutorials/mesh/index.rst @@ -28,7 +28,7 @@ These tutorials explains how to explore different attributes of a given mesh wit This tutorial explains how to extract the models mesh from a result file +++ - :bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` + :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. grid-item-card:: Read a mesh metadata :link: ref_tutorials_read_mesh_metadata @@ -40,7 +40,7 @@ These tutorials explains how to explore different attributes of a given mesh wit extracting the mesh. +++ - :bdg-success:`LSDYNA`:bdg-info:`Fluent` :bdg-light:`CFX` + :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. grid-item-card:: Explore a mesh @@ -53,7 +53,7 @@ These tutorials explains how to explore different attributes of a given mesh wit so it can be manipulated. +++ - :bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` + :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. grid-item-card:: Extract a mesh in split parts :link: tutorials_get_specific_part_mesh @@ -64,7 +64,7 @@ These tutorials explains how to explore different attributes of a given mesh wit or CFX result files. +++ - :bdg-info:`Fluent` :bdg-light:`CFX` + :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. grid-item-card:: Split a mesh :link: tutorials_split_mesh @@ -74,7 +74,7 @@ These tutorials explains how to explore different attributes of a given mesh wit This tutorial show how to split a mesh into different meshes. +++ - :bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` + :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. toctree:: :maxdepth: 2 From 5c43ae47fed316f01150e3a1b53d9c622738b7fc Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 3 Dec 2024 16:30:12 +0100 Subject: [PATCH 32/49] change the section name --- doc/source/user_guide/tutorials/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/tutorials/index.rst b/doc/source/user_guide/tutorials/index.rst index 3918a6b80e..7e9490d4cf 100644 --- a/doc/source/user_guide/tutorials/index.rst +++ b/doc/source/user_guide/tutorials/index.rst @@ -65,7 +65,7 @@ of our package background so you can understand how to work with it. Understand how to represent data in DPF: either from manual input either form result files. - .. grid-item-card:: Mesh analysis + .. grid-item-card:: Mesh exploration :link: ref_tutorials_mesh :link-type: ref :text-align: center From 947f6461dcf84bc24774c21a14e938f036f61382 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Tue, 3 Dec 2024 16:32:26 +0100 Subject: [PATCH 33/49] add badges in each tutorial --- doc/source/user_guide/tutorials/mesh/explore_mesh.rst | 2 +- .../user_guide/tutorials/mesh/get_mesh_from_result_file.rst | 2 +- doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst | 2 +- doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst | 2 +- doc/source/user_guide/tutorials/mesh/split_mesh.rst | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst index e89feefe89..f5688484a6 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst @@ -4,7 +4,7 @@ Explore a mesh ============== -:bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` +:bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |Model| replace:: :class:`Model ` diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 3203ed680c..06445f8195 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -4,7 +4,7 @@ Get a mesh from a result file ============================= -:bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` +:bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. |Field| replace:: :class:`Field` .. |FieldsContainer| replace:: :class:`FieldsContainer` diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst index ae70c33740..00991fa5d5 100644 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst @@ -4,7 +4,7 @@ Extract a mesh in split parts ============================= -:bdg-info:`Fluent` :bdg-light:`CFX` +:bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |MeshesContainer| replace:: :class:`MeshesContainer ` diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst index 4b87c80874..1a02e41fa6 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst @@ -4,7 +4,7 @@ Read a mesh metadata ==================== -:bdg-success:`LSDYNA`:bdg-info:`Fluent` :bdg-light:`CFX` +:bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |Model| replace:: :class:`Model ` diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index 7dcd46d047..0277726fbb 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -4,7 +4,7 @@ Split a mesh ============ -:bdg-warning:`MAPDL` :bdg-success:`LSDYNA` :bdg-info:`Fluent` :bdg-light:`CFX` +:bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` This tutorial show how to split a mesh into different meshes. From e666e27e3a714349f4ca8e14946d6a076ebe51b5 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 4 Dec 2024 16:52:20 +0100 Subject: [PATCH 34/49] update2 the create_a_mesh_from_scratch.rst tutorial to the tutorials guidelines --- .../mesh/create_a_mesh_from_scratch.rst | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst index 821bac0250..a592c0d038 100644 --- a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst +++ b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst @@ -1,32 +1,35 @@ -.. _tutorials_create_a_mesh_from_scratch: +.. _ref_tutorials_create_a_mesh_from_scratch: ========================== Create a mesh from scratch ========================== -.. |Field| replace:: :class:`Field` -.. |FieldsContainer| replace:: :class:`FieldsContainer` -.. |MeshedRegion| replace:: :class:`MeshedRegion ` -.. |Model| replace:: :class:`Model ` +.. include:: ../../../links_and_refs.rst -The mesh object in DPF is a |MeshedRegion|. You can create your own |MeshedRegion| object to use DPF operators -with your own data. The ability to use scripting to create any DPF entity means +This tutorial demonstrates how to build a |MeshedRegion| from the scratch. + +The mesh object in DPF is a |MeshedRegion|. You can create your own |MeshedRegion| object and use it +with DPF operators. The ability to use scripting to create any DPF entity means that you are not dependent on result files and can connect the DPF environment with any Python tool. -This tutorial demonstrates how to build a |MeshedRegion| from the scratch. +Here, we create a parallel piped mesh made of linear hexa elements. -Here we create a parallel piped mesh made of linear hexa elements. +:jupyter-download-script:`Download tutorial as Python script` +:jupyter-download-notebook:`Download tutorial as Jupyter notebook` Import the necessary modules ---------------------------- -Import the ``ansys.dpf.core`` module, including the operators subpackage and the numpy library +Import the ``ansys.dpf.core`` module, including the operators module and the numpy library. .. jupyter-execute:: + # Import the numpy library import numpy as np + # Import the ``ansys.dpf.core`` module from ansys.dpf import core as dpf + # Import the operators module from ansys.dpf.core import operators as ops Define the mesh dimensions @@ -47,10 +50,10 @@ Define the mesh dimensions Define the connectivity function -------------------------------- -To create a mesh we need to define the nodes connectivity. This means to define -the elements and nodes indices connected to each node. +To create a mesh you must define the nodes connectivity. This means to define +the nodes ids connected to each node. -Here we create a function that will find the connectivity of our entities. +Here, we create a function that will find this connectivity. .. jupyter-execute:: @@ -66,7 +69,7 @@ Here we create a function that will find the connectivity of our entities. Add nodes --------- -Add nodes to the |MeshedRegion| object: +Add |Nodes| to the |MeshedRegion| object. .. jupyter-execute:: @@ -83,22 +86,22 @@ Add nodes to the |MeshedRegion| object: my_meshed_region.nodes.add_node(node_id, [x, y, z]) node_id += 1 -Get the nodes coordinates field +Get the nodes coordinates field. .. jupyter-execute:: my_nodes_coordinates = my_meshed_region.nodes.coordinates_field -Set the mesh node properties ----------------------------- +Set the mesh properties +----------------------- -Set the mesh unit: +Set the mesh unit. .. jupyter-execute:: my_meshed_region.unit = "mm" -Set the nodes coordinates: +Set the nodes coordinates. .. jupyter-execute:: @@ -106,11 +109,12 @@ Set the nodes coordinates: my_nodes_coordinates_data = my_nodes_coordinates.data # As we use the connectivity function we need to get the data as a list my_nodes_coordinates_data_list = my_nodes_coordinates.data_as_list - # Get the nodes scoping + # Set the nodes scoping my_coordinates_scoping = my_nodes_coordinates.scoping -Add the elements ----------------- +Add elements +------------ +Add |Elements| to the |MeshedRegion| object. .. jupyter-execute:: @@ -141,9 +145,14 @@ Add the elements connectivity[7] = tmp my_meshed_region.elements.add_solid_element(element_id, connectivity) element_id += 1 + Plot the mesh ------------- +You can check the mesh we just created with a plot. For more information on how to plot a mesh see +the :ref:`ref_tutorials_plotting_meshes` tutorial. + .. jupyter-execute:: + # Plot the mesh my_meshed_region.plot() \ No newline at end of file From 98d4a978a722db0626905d7184c8244c1f6cd92c Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 4 Dec 2024 16:53:42 +0100 Subject: [PATCH 35/49] update the explore_mesh.rst to the tutorials guidelines --- .../tutorials/mesh/explore_mesh.rst | 210 ++++++++++-------- 1 file changed, 118 insertions(+), 92 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst index f5688484a6..f23f748d5c 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst @@ -1,4 +1,4 @@ -.. _tutorials_explore_mesh: +.. _ref_tutorials_explore_mesh: ============== Explore a mesh @@ -6,34 +6,24 @@ Explore a mesh :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` -.. |MeshedRegion| replace:: :class:`MeshedRegion ` -.. |Model| replace:: :class:`Model ` -.. |DataSources| replace:: :class:`Model ` -.. |MeshInfo| replace:: :class:`MeshInfo ` -.. |Nodes| replace:: :class:`Nodes ` -.. |Elements| replace:: :class:`Elements ` -.. |Faces| replace:: :class:`Faces ` -.. |Scoping| replace:: :class:`Scoping ` +.. include:: ../../../links_and_refs.rst .. |PropertyField| replace:: :class:`PropertyField ` -.. |Examples| replace:: :mod:`Examples` +.. |element_types| replace:: :class:`list of available element types in a DPF mesh` -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` +:jupyter-download-notebook:`Download tutorial as Jupyter notebook` 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:: @@ -41,84 +31,94 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. 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:: @@ -126,47 +126,60 @@ When instantiating the nodes, element, faces and named selection you get the cor .. 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,9 +238,10 @@ 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 @@ -226,24 +249,27 @@ to the entity they are defined at: .. 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) \ No newline at end of file + el_types_4 = meshed_region_4.property_field(property_name="eltype") + + # Print the element types by element + print(el_types_4) \ No newline at end of file From ccc731bfce1d25bcd1ff9e825cb23f18126650f9 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 4 Dec 2024 16:54:35 +0100 Subject: [PATCH 36/49] update the extract_mesh_in_split_parts.rst to the tutorials guidelines --- .../mesh/extract_mesh_in_split_parts.rst | 118 ++++++++++++++++++ .../tutorials/mesh/get_specific_part_mesh.rst | 106 ---------------- 2 files changed, 118 insertions(+), 106 deletions(-) create mode 100644 doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst delete mode 100644 doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst diff --git a/doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst b/doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst new file mode 100644 index 0000000000..4f25fc36ec --- /dev/null +++ b/doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst @@ -0,0 +1,118 @@ +.. _ref_tutorials_extract_mesh_in_split_parts: + +============================= +Extract a mesh in split parts +============================= + +:bdg-fluent:`Fluent` :bdg-cfx:`CFX` + +.. include:: ../../../links_and_refs.rst +.. |MeshesContainer| replace:: :class:`MeshesContainer ` +.. |meshes_provider| replace:: :class:`mesh_provider ` + +This tutorial shows how to extract meshes split on a given space or time from a result file. + +To accomplish this goal, you must use the |meshes_provider| operator. + +:jupyter-download-script:`Download tutorial as Python script` +:jupyter-download-notebook:`Download tutorial as Jupyter notebook` + +Define the |DataSources| +------------------------ + +We must create a |DataSources| object so the |meshes_provider| operator can access the mesh. This object +manages paths to their files. + +For this tutorial, you can use a result file available in the |Examples| module. +For more information about how to import your own result file in DPF, see the :ref:`ref_tutorials_import_data` +tutorial section. + +.. tab-set:: + + .. tab-item:: Fluent + + .. jupyter-execute:: + + # 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 path + result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] + # Create the DataSources object + ds_3 = dpf.DataSources(result_path=result_file_path_3) + + .. tab-item:: CFX + + .. jupyter-execute:: + + # 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 path + result_file_path_4 = examples.download_cfx_mixing_elbow() + # Create the DataSources object + ds_4 = dpf.DataSources(result_path=result_file_path_4) + +Extract the mesh in split parts +------------------------------- + +Instanciate and evaluate the |meshes_provider| operator. +The split meshes are given in a |MeshesContainer| and can be spatially or temporally varying. + +.. tab-set:: + + .. tab-item:: Fluent + + .. jupyter-execute:: + + # Instanciate the meshes_provider operator + meshes_31 = ops.mesh.meshes_provider(data_sources=ds_3).eval() + + # Print the meshes + print(meshes_31) + + .. tab-item:: CFX + + .. jupyter-execute:: + + # Instanciate the meshes_provider operator + meshes_41 = ops.mesh.meshes_provider(data_sources=ds_4).eval() + + # Print the meshes + print(meshes_41) + +Scope the mesh regions to be extracted in split parts +----------------------------------------------------- + +A region corresponds to a zone for Fluid and CFX results. You can specify the mesh regions you want to get by giving +the zones ids to the ``region_scoping`` argument. + +.. tab-set:: + + .. tab-item:: Fluent + + .. jupyter-execute:: + + # Instanciate the meshes_provider operator and specify a region + meshes_32 = ops.mesh.meshes_provider(data_sources=ds_3, region_scoping=[3,12]).eval() + + # Print the meshes + print(meshes_32) + + .. tab-item:: CFX + + .. jupyter-execute:: + + # Instanciate the meshes_provider operator specifying a region + meshes_42 = ops.mesh.meshes_provider(data_sources=ds_4, region_scoping=[5,8]).eval() + + # Print the meshes + print(meshes_42) diff --git a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst b/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst deleted file mode 100644 index 00991fa5d5..0000000000 --- a/doc/source/user_guide/tutorials/mesh/get_specific_part_mesh.rst +++ /dev/null @@ -1,106 +0,0 @@ -.. _tutorials_get_specific_part_mesh: - -============================= -Extract a mesh in split parts -============================= - -:bdg-fluent:`Fluent` :bdg-cfx:`CFX` - -.. |MeshedRegion| replace:: :class:`MeshedRegion ` -.. |MeshesContainer| replace:: :class:`MeshesContainer ` -.. |DataSources| replace:: :class:`Model ` -.. |meshes_provider| replace:: :class:`mesh_provider ` -.. |Examples| replace:: :mod:`Examples` - -This tutorial show how to get meshes split on a given space or time for Fluent or CFX result files. - -You have one operator in this case: |meshes_provider| - -Define the |DataSources| ------------------------- - -The |meshes_provider| operator needs a |DataSources| object. - -In this part we will download simulation result files available -in our |Examples| package. - -.. tab-set:: - - .. tab-item:: Fluent - - .. jupyter-execute:: - - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] - # Create the DataSources object - my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3) - - .. tab-item:: CFX - - .. jupyter-execute:: - - # Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - # Define the result file - result_file_path_4 = examples.download_cfx_mixing_elbow() - # Create the DataSources object - my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4) - -Use the |meshes_provider| operator ----------------------------------- - -Instanciate the |meshes_provider| operator. - -.. tab-set:: - - .. tab-item:: Fluent - - .. jupyter-execute:: - - # Instanciate the meshes_provider operator - my_meshes_31 = ops.mesh.meshes_provider(data_sources=my_data_sources_3).eval() - # Print the meshes - print(my_meshes_31) - - .. tab-item:: CFX - - .. jupyter-execute:: - - # Instanciate the meshes_provider operator - my_meshes_41 = ops.mesh.meshes_provider(data_sources=my_data_sources_4).eval() - # Print the meshes - print(my_meshes_41) - -Scope the regions to be extracted ---------------------------------- - -You can specify the mesh regions you want to get by giving the region id to the ``region_scoping`` argument. -A region corresponds to a zone for Fluid results. - -The given meshes can be spatially or temporally varying, it depends on your result file. - -.. tab-set:: - - .. tab-item:: Fluent - - .. jupyter-execute:: - - # Instanciate the meshes_provider operator and specify a region - my_meshes_32 = ops.mesh.meshes_provider(data_sources=my_data_sources_3, region_scoping=[3,12]).eval() - # Print the meshes - print(my_meshes_32) - - .. tab-item:: CFX - - .. jupyter-execute:: - - # Instanciate the meshes_provider operator specifying a region - my_meshes_42 = ops.mesh.meshes_provider(data_sources=my_data_sources_4, region_scoping=[5,8]).eval() - # Print the meshes - print(my_meshes_42) From 882c3a265badb40af7e119d47ed999e359e3c0df Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 4 Dec 2024 16:54:49 +0100 Subject: [PATCH 37/49] update the get_mesh_from_result_file.rst to the tutorials guidelines --- .../mesh/get_mesh_from_result_file.rst | 165 ++++++++++-------- 1 file changed, 89 insertions(+), 76 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst index 06445f8195..801f1e925a 100644 --- a/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst +++ b/doc/source/user_guide/tutorials/mesh/get_mesh_from_result_file.rst @@ -1,4 +1,4 @@ -.. _tutorials_get_mesh_from_result_file: +.. _ref_tutorials_get_mesh_from_result_file: ============================= Get a mesh from a result file @@ -6,29 +6,27 @@ Get a mesh from a result file :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` -.. |Field| replace:: :class:`Field` -.. |FieldsContainer| replace:: :class:`FieldsContainer` -.. |MeshedRegion| replace:: :class:`MeshedRegion ` -.. |Model| replace:: :class:`Model ` -.. |DataSources| replace:: :class:`Model ` +.. include:: ../../../links_and_refs.rst + .. |mesh_provider| replace:: :class:`mesh_provider ` -.. |Examples| replace:: :mod:`Examples` -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. +This tutorial explains how to extract a mesh from a result file. -This tutorial explains how to extract the models mesh from a result file. +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. +:jupyter-download-script:`Download tutorial as Python script` +:jupyter-download-notebook:`Download tutorial as Jupyter notebook` Import the result file ---------------------- -Here we we will download result files 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. +First, import a result file. For this tutorial, you can use one available in the |Examples| module. +For more information about how to import your own result file in DPF, see the :ref:`ref_tutorials_import_data` +tutorials section. -You have to create a |DataSources| object so the data can be accessed by -PyDPF-Core APIs. +Here, we create a |DataSources| object so the data can be directly accessed by different +PyDPF-Core APIs. This object manages paths to their files. .. tab-set:: @@ -36,71 +34,81 @@ PyDPF-Core APIs. .. 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 DataSources object - my_data_sources_1 = dpf.DataSources(result_path=result_file_path_1) + ds_1 = dpf.DataSources(result_path=result_file_path_1) .. 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") .. 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 DataSources object - my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3) + ds_3 = dpf.DataSources(result_path=result_file_path_3) .. 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 DataSources object - my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4) + ds_4 = dpf.DataSources(result_path=result_file_path_4) Get the mesh from the result file --------------------------------- -You can Get the mesh from the result file by two methods: +You can get the mesh from a result file by two methods: -- :ref:`get_mesh_model` -- :ref:`get_mesh_mesh_provider` +- :ref:`Using the DPF Model `; +- :ref:`Using the mesh_provider operator `. .. note:: - The |Model| extracts a large amount of information by default (results, mesh and analysis data). + A |Model| extracts a large amount of information by default (results, mesh and analysis data). If using this helper takes a long time for processing the code, mind using a |DataSources| object - and instantiating operators directly with it. Check the ":ref:`get_mesh_mesh_provider`" for more - information on how to get a mesh from a result file. + and instantiating operators directly with it. .. _get_mesh_model: @@ -108,10 +116,9 @@ Using the DPF |Model| ^^^^^^^^^^^^^^^^^^^^^ The |Model| is a helper designed to give shortcuts to access the analysis results -metadata, by opening a DataSources or a Streams, and to instanciate results provider -for it. +metadata and to instanciate results providers by opening a |DataSources| or a Streams. -Get the |MeshedRegion| by instantiating a |Model| object and accessing its metadata: +Get the |MeshedRegion| by instantiating a |Model| object and accessing its metadata. .. tab-set:: @@ -119,40 +126,43 @@ Get the |MeshedRegion| by instantiating a |Model| object and accessing its metad .. jupyter-execute:: - # Create the model - my_model_1 = dpf.Model(data_sources=my_data_sources_1) + # Create the Model + model_1 = dpf.Model(data_sources=ds_1) # Get the mesh - my_meshed_region_1 = my_model_1.metadata.meshed_region + meshed_region_11 = model_1.metadata.meshed_region .. tab-item:: LSDYNA .. jupyter-execute:: - # Create the model - my_model_2 = dpf.Model(data_sources=my_data_sources_2) + # Create the Model + model_2 = dpf.Model(data_sources=ds_2) # Get the mesh - my_meshed_region_2 = my_model_2.metadata.meshed_region + meshed_region_21 = model_2.metadata.meshed_region .. tab-item:: Fluent .. jupyter-execute:: - # Create the model - my_model_3 = dpf.Model(data_sources=my_data_sources_3) + # Create the Model + model_3 = dpf.Model(data_sources=ds_3) # Get the mesh - my_meshed_region_3 = my_model_3.metadata.meshed_region + meshed_region_31 = model_3.metadata.meshed_region .. tab-item:: CFX .. jupyter-execute:: - # Create the model - my_model_4 = dpf.Model(data_sources=my_data_sources_4) + # Create the Model + model_4 = dpf.Model(data_sources=ds_4) # Get the mesh - my_meshed_region_4 = my_model_4.metadata.meshed_region + meshed_region_41 = model_4.metadata.meshed_region -Printing the |MeshedRegion| displays the mesh dimensions (number of nodes and elements, -unit and elements type): +Printing the |MeshedRegion| displays the mesh dimensions: + +- Number of nodes and elements; +- Unit; +- Elements type. .. tab-set:: @@ -160,37 +170,37 @@ unit and elements type): .. jupyter-execute:: - # Print the meshed region - print(my_meshed_region_1) + # Print the MeshedRegion + print(meshed_region_11) .. tab-item:: LSDYNA .. jupyter-execute:: - # Print the meshed region - print(my_meshed_region_2) + # Print the MeshedRegion + print(meshed_region_21) .. tab-item:: Fluent .. jupyter-execute:: - # Print the meshed region - print(my_meshed_region_3) + # Print the MeshedRegion + print(meshed_region_31) .. tab-item:: CFX .. jupyter-execute:: - # Print the meshed region - print(my_meshed_region_4) + # Print the MeshedRegion + print(meshed_region_41) .. _get_mesh_mesh_provider: Using the |mesh_provider| operator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Get the |MeshedRegion| by instantiating the |mesh_provider| operator and instantiating it with a -|DataSources| object as an argument: +Get the |MeshedRegion| by instantiating the |mesh_provider| operator with the +|DataSources| object as an argument. .. tab-set:: @@ -199,31 +209,34 @@ Get the |MeshedRegion| by instantiating the |mesh_provider| operator and instant .. jupyter-execute:: # Get the mesh with the mesh_provider operator - my_meshed_region_12 = ops.mesh.mesh_provider(data_sources=my_data_sources_1).eval() + meshed_region_12 = ops.mesh.mesh_provider(data_sources=ds_1).eval() .. tab-item:: LSDYNA .. jupyter-execute:: # Get the mesh with the mesh_provider operator - my_meshed_region_22 = ops.mesh.mesh_provider(data_sources=my_data_sources_2).eval() + meshed_region_22 = ops.mesh.mesh_provider(data_sources=ds_2).eval() .. tab-item:: Fluent .. jupyter-execute:: # Get the mesh with the mesh_provider operator - my_meshed_region_32 = ops.mesh.mesh_provider(data_sources=my_data_sources_3).eval() + meshed_region_32 = ops.mesh.mesh_provider(data_sources=ds_3).eval() .. tab-item:: CFX .. jupyter-execute:: # Get the mesh with the mesh_provider operator - my_meshed_region_42 = ops.mesh.mesh_provider(data_sources=my_data_sources_4).eval() + meshed_region_42 = ops.mesh.mesh_provider(data_sources=ds_4).eval() + +Printing the |MeshedRegion| displays the mesh dimensions: -Printing the |MeshedRegion| displays the mesh dimensions (number of nodes and elements, -unit and elements type): +- Number of nodes and elements; +- Unit; +- Elements type. .. tab-set:: @@ -231,26 +244,26 @@ unit and elements type): .. jupyter-execute:: - # Print the meshed region - print(my_meshed_region_12) + # Print the MeshedRegion + print(meshed_region_12) .. tab-item:: LSDYNA .. jupyter-execute:: - # Print the meshed region - print(my_meshed_region_22) + # Print the MeshedRegion + print(meshed_region_22) .. tab-item:: Fluent .. jupyter-execute:: - # Print the meshed region - print(my_meshed_region_32) + # Print the MeshedRegion + print(meshed_region_32) .. tab-item:: CFX .. jupyter-execute:: - # Print the meshed region - print(my_meshed_region_42) \ No newline at end of file + # Print the MeshedRegion + print(meshed_region_42) \ No newline at end of file From cc3325cce11993a8f8292080f28f3b5af0ee5305 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 4 Dec 2024 16:55:04 +0100 Subject: [PATCH 38/49] update the read_mesh_metadata.rst to the tutorials guidelines --- .../tutorials/mesh/read_mesh_metadata.rst | 144 ++++++++++-------- 1 file changed, 82 insertions(+), 62 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst index 1a02e41fa6..46b6de0551 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst @@ -6,28 +6,20 @@ Read a mesh metadata :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` -.. |MeshedRegion| replace:: :class:`MeshedRegion ` -.. |Model| replace:: :class:`Model ` -.. |DataSources| replace:: :class:`Model ` -.. |MeshInfo| replace:: :class:`MeshInfo ` -.. |Examples| replace:: :mod:`Examples` +.. include:: ../../../links_and_refs.rst This tutorial explains how to read a mesh metadata (data about the elements, nodes, faces, region, zone ...) -for LSDYNA, Fluent or CFX result files. +before extracting the mesh from a result file. -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. +:jupyter-download-script:`Download tutorial as Python script` +:jupyter-download-notebook:`Download tutorial as Jupyter notebook` -We have the |MeshInfo| object to read metadata information before extracting the |MeshedRegion|. -You can obtain this object by creating a |Model| with a result file. +Get the result file +------------------- -Define the |Model| ------------------- - -Here we we will download result files 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. +First, import a result file. For this tutorial, you can use one available in the |Examples| module. +For more information about how to import your own result file in DPF, see the :ref:`ref_tutorials_import_data` +tutorial section. .. tab-set:: @@ -35,59 +27,77 @@ the :ref:`ref_tutorials_import_data` tutorial section. .. 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 - 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") - # Create the model - my_model_2 = dpf.Model(data_sources=my_data_sources_2) - # Get the mesh - my_meshed_region_2 = my_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 - 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) - # Get the mesh - my_meshed_region_3 = my_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 - 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) - # Get the mesh - my_meshed_region_4 = my_model_4.metadata.meshed_region + +Create the |Model| +------------------ + +Create a |Model| object with the result file. The |Model| is a helper designed to give shortcuts to +access the analysis results metadata and to instanciate results providers by opening a |DataSources| or a Streams. + +.. tab-set:: + + .. tab-item:: LSDYNA + + .. jupyter-execute:: + + # Create the DataSources object + 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 + model_2 = dpf.Model(data_sources=ds_2) + + .. tab-item:: Fluent + + .. jupyter-execute:: + + # Create the Model + model_3 = dpf.Model(data_sources=result_file_path_3) + + .. tab-item:: CFX + + .. jupyter-execute:: + + # Create the Model + model_4 = dpf.Model(data_sources=result_file_path_4) Read the mesh metadata ---------------------- -The |Model| is a helper designed to give shortcuts to access the analysis results -metadata, by opening a DataSources or a Streams, and to instanciate results provider -for it. +You can access the mesh metadata with the |MeshInfo| object. It reads the metadata information before extracting +the MeshedRegion from the result file. -From the |Model| you can access the |MeshedRegion| metadata information with the |MeshInfo| object. The mesh metadata information includes : - Properties; @@ -98,7 +108,7 @@ The mesh metadata information includes : - Number of nodes and elements; - Elements types. -Get the the mesh metadata information and print the available ones: +Get the the mesh metadata information and print the available ones. .. tab-set:: @@ -107,30 +117,34 @@ Get the the mesh metadata information and print the available ones: .. jupyter-execute:: # Get the mesh metadata information - my_mesh_info_2 = my_model_2.metadata.mesh_info + mesh_info_2 = model_2.metadata.mesh_info + # Print the mesh metadata information - print(my_mesh_info_2) + print(mesh_info_2) .. tab-item:: Fluent .. jupyter-execute:: # Get the mesh metadata information - my_mesh_info_3 = my_model_3.metadata.mesh_info + mesh_info_3 = model_3.metadata.mesh_info + # Print the mesh metadata information - print(my_mesh_info_3) + print(mesh_info_3) .. tab-item:: CFX .. jupyter-execute:: # Get the mesh metadata information - my_mesh_info_4 = my_model_4.metadata.mesh_info + mesh_info_4 = model_4.metadata.mesh_info + # Print the mesh metadata information - print(my_mesh_info_4) + print(mesh_info_4) You can extract each of those mesh information by manipulating the |MeshInfo| object properties. -For example we can check the part names (for the LSDYNA result file) or the cell zone names + +For example, we can check the part names (for the LSDYNA result file) or the cell zone names (for the Fluent or CFX result files): .. tab-set:: @@ -140,24 +154,30 @@ For example we can check the part names (for the LSDYNA result file) or the cell .. jupyter-execute:: # Get the part names - my_cell_zones_2 = my_mesh_info_2.get_property("part_names") - print(my_cell_zones_2) + cell_zones_2 = mesh_info_2.get_property("part_names") + + # Print the part names + print(cell_zones_2) .. tab-item:: Fluent .. jupyter-execute:: # Get the cell zone names - my_cell_zones_3 = my_mesh_info_3.get_property("cell_zone_names") - print(my_cell_zones_3) + cell_zones_3 = mesh_info_3.get_property("cell_zone_names") + + # Print the cell zone names + print(cell_zones_3) .. tab-item:: CFX .. jupyter-execute:: # Get the cell zone names - my_cell_zones_4 = my_mesh_info_4.get_property("cell_zone_names") - print(my_cell_zones_4) + cell_zones_4 = mesh_info_4.get_property("cell_zone_names") + + # Print the cell zone names + print(cell_zones_4) -For more information on reading a mesh from a LSDYNA, Fluent or CFX file check the examples sections: -:ref:`examples_lsdyna`, :ref:`fluids_examples` and :ref:`examples_cfx`. \ No newline at end of file +For more information on reading a mesh from a LSDYNA, Fluent or CFX file check the :ref:`examples_lsdyna`, +:ref:`fluids_examples` and :ref:`examples_cfx` examples sections. \ No newline at end of file From e7086601284b035a77b179d0c6d544defabe1bb2 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 4 Dec 2024 16:55:19 +0100 Subject: [PATCH 39/49] update the split_mesh.rst to the tutorials guidelines --- .../user_guide/tutorials/mesh/split_mesh.rst | 153 ++++++++++-------- 1 file changed, 88 insertions(+), 65 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index 0277726fbb..44390cdb85 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -1,4 +1,4 @@ -.. _tutorials_split_mesh: +.. _ref_tutorials_split_mesh: ============ Split a mesh @@ -6,35 +6,34 @@ Split a mesh :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` -This tutorial show how to split a mesh into different meshes. +.. include:: ../../../links_and_refs.rst -.. |MeshedRegion| replace:: :class:`MeshedRegion ` .. |MeshesContainer| replace:: :class:`MeshesContainer ` .. |split_mesh| replace:: :class:`split_mesh ` .. |split_on_property_type| replace:: :class:`split_on_property_type ` .. |from_scopings| replace:: :class:`from_scopings ` -.. |DataSources| replace:: :class:`Model ` -.. |Scoping| replace:: :class:`Scoping ` .. |ScopingsContainer| replace:: :class:`ScopingsContainer ` -.. |Examples| replace:: :mod:`Examples` +.. |PropertyField| replace:: :class:`PropertyField ` -The mesh object in DPF is a |MeshedRegion|. If you want to split your mesh you can store them in a |MeshedRegion|. +This tutorial shows how to split a mesh on a give property. -You have two approaches to split your mesh: +There are two approaches to accomplish this goal: -1) Using the |split_mesh|, to split a already existing |MeshedRegion| into a MeshesContainer; -2) Split the scoping with the |split_on_property_type| operator and than creating the |MeshedRegion| - objects with the |from_scopings| operator. +- :ref:`Use the split_mesh operator to split a already existing MeshedRegion`; +- :ref:`Split the mesh scoping and create the split MeshedRegion objects `. + +:jupyter-download-script:`Download tutorial as Python script` +:jupyter-download-notebook:`Download tutorial as Jupyter notebook` 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. +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 +information check the :ref:`ref_tutorials_create_a_mesh_from_scratch` and :ref:`ref_tutorials_get_mesh_from_result_file` +tutorials. -In this part we will download simulation result files available -in our |Examples| package. +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:: @@ -42,72 +41,90 @@ in our |Examples| package. .. 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_multishells_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 + +.. _ref_first_approach_split_mesh: -1) First approach ------------------ +First approach +-------------- -Use the |split_mesh| operator to split a already existing |MeshedRegion| into a MeshesContainer based on a property. +Use the |split_mesh| operator to split an already existing |MeshedRegion| based on a property. Currently you can split a mesh by material or eltype. +When you split a |MeshedRegion| the split parts are stored in the DPF collection called |MeshesContainer|. + +Here, we split the |MeshedRegion| by material. + .. tab-set:: .. tab-item:: MAPDL @@ -115,47 +132,53 @@ Currently you can split a mesh by material or eltype. .. jupyter-execute:: # Split the mesh by material - my_meshes_11 = ops.mesh.split_mesh(mesh=my_meshed_region_1,property="mat").eval() + meshes_11 = ops.mesh.split_mesh(mesh=meshed_region_1,property="mat").eval() + # Print the meshes - print(my_meshes_11) + print(meshes_11) .. tab-item:: LSDYNA .. jupyter-execute:: # Split the mesh by material - my_meshes_21 = ops.mesh.split_mesh(mesh=my_meshed_region_2,property="mat").eval() + meshes_21 = ops.mesh.split_mesh(mesh=meshed_region_2,property="mat").eval() + # Print the meshes - print(my_meshes_21) + print(meshes_21) .. tab-item:: Fluent .. jupyter-execute:: # Split the mesh by material - my_meshes_31 = ops.mesh.split_mesh(mesh=my_meshed_region_3,property="mat").eval() + meshes_31 = ops.mesh.split_mesh(mesh=meshed_region_3,property="mat").eval() + # Print the meshes - print(my_meshes_31) + print(meshes_31) .. tab-item:: CFX .. jupyter-execute:: # Split the mesh by material - my_meshes_41 = ops.mesh.split_mesh(mesh=my_meshed_region_4,property="mat").eval() + meshes_41 = ops.mesh.split_mesh(mesh=meshed_region_4,property="mat").eval() # Print the meshes - print(my_meshes_41) + print(meshes_41) + +.. _ref_second_approach_split_mesh: +Second approach +--------------- -2) Second approach ------------------- +First, use the |split_on_property_type| operator to split the mesh scoping. This operator splits a |Scoping| on given +properties (elshape and/or material, since 2025R1 it supports any scalar property field name contained in the mesh +property fields) and returns a |ScopingsContainer| with those split scopings. -Use the |split_on_property_type| operator to split the scoping and then create the |MeshedRegion| -objects with the |from_scopings| operator. +Finally, create the split |MeshedRegion| objects with the |from_scopings| operator. The split parts are stored +in the DPF collection called |MeshesContainer|. -The |split_on_property_type| a given |Scoping| on given properties (elshape and/or material, since 2025R1 -it supports any scalar property field name contained in the mesh property fields) and returns a |ScopingsContainer| -with those split scopings. +Here, we split the mesh scoping by material. .. tab-set:: @@ -164,41 +187,41 @@ with those split scopings. .. jupyter-execute:: # Define the scoping split by material - split_scoping_1 = ops.scoping.split_on_property_type(mesh=my_meshed_region_1, label1="mat").eval() + split_scoping_1 = ops.scoping.split_on_property_type(mesh=meshed_region_1, label1="mat").eval() # Get the split meshes - my_meshes_12 = ops.mesh.from_scopings(scopings_container=split_scoping_1,mesh=my_meshed_region_1).eval() + meshes_12 = ops.mesh.from_scopings(scopings_container=split_scoping_1,mesh=meshed_region_1).eval() # Print the meshes - print(my_meshes_12) + print(meshes_12) .. tab-item:: LSDYNA .. jupyter-execute:: # Define the scoping split by material - split_scoping_2 = ops.scoping.split_on_property_type(mesh=my_meshed_region_2, label1="mat").eval() + split_scoping_2 = ops.scoping.split_on_property_type(mesh=meshed_region_2, label1="mat").eval() # Get the split meshes - my_meshes_22 = ops.mesh.from_scopings(scopings_container=split_scoping_2,mesh=my_meshed_region_2).eval() + meshes_22 = ops.mesh.from_scopings(scopings_container=split_scoping_2,mesh=meshed_region_2).eval() # Print the meshes - print(my_meshes_22) + print(meshes_22) .. tab-item:: Fluent .. jupyter-execute:: # Define the scoping split by material - split_scoping_3 = ops.scoping.split_on_property_type(mesh=my_meshed_region_3, label1="mat").eval() + split_scoping_3 = ops.scoping.split_on_property_type(mesh=meshed_region_3, label1="mat").eval() # Get the split meshes - my_meshes_32 = ops.mesh.from_scopings(scopings_container=split_scoping_3,mesh=my_meshed_region_3).eval() + meshes_32 = ops.mesh.from_scopings(scopings_container=split_scoping_3,mesh=meshed_region_3).eval() # Print the meshes - print(my_meshes_32) + print(meshes_32) .. tab-item:: CFX .. jupyter-execute:: # Define the scoping split by material - split_scoping_4 = ops.scoping.split_on_property_type(mesh=my_meshed_region_4, label1="mat").eval() + split_scoping_4 = ops.scoping.split_on_property_type(mesh=meshed_region_4, label1="mat").eval() # Get the split meshes - my_meshes_42 = ops.mesh.from_scopings(scopings_container=split_scoping_4,mesh=my_meshed_region_4).eval() + meshes_42 = ops.mesh.from_scopings(scopings_container=split_scoping_4,mesh=meshed_region_4).eval() # Print the meshes - print(my_meshes_42) + print(meshes_42) From ea88101c3a3362c70dbf60acbdaae0c83b5f7461 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Wed, 4 Dec 2024 16:55:34 +0100 Subject: [PATCH 40/49] update the index page of the mesh tutorials section --- .../user_guide/tutorials/mesh/index.rst | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/index.rst b/doc/source/user_guide/tutorials/mesh/index.rst index f7d7297f44..bf0791ac94 100644 --- a/doc/source/user_guide/tutorials/mesh/index.rst +++ b/doc/source/user_guide/tutorials/mesh/index.rst @@ -15,18 +15,19 @@ These tutorials explains how to explore different attributes of a given mesh wit :margin: 2 .. grid-item-card:: Create a mesh from scratch - :link: tutorials_create_a_mesh_from_scratch + :link: ref_tutorials_create_a_mesh_from_scratch :link-type: ref :text-align: center - This tutorial demonstrates how to build a mesh from the scratch + This tutorial demonstrates how to build a mesh from the scratch. .. grid-item-card:: Get a mesh from a result file - :link: tutorials_get_mesh_from_result_file + :link: ref_tutorials_get_mesh_from_result_file :link-type: ref :text-align: center - This tutorial explains how to extract the models mesh from a result file + This tutorial explains how to extract a mesh from a result file. + +++ :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` @@ -37,41 +38,39 @@ These tutorials explains how to explore different attributes of a given mesh wit This tutorial explains how to read a mesh metadata (data about the elements, nodes, faces, region, zone ...) before - extracting the mesh. + extracting the mesh from a result file. +++ :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. grid-item-card:: Explore a mesh - :link: tutorials_explore_mesh + :link: ref_tutorials_explore_mesh :link-type: ref :text-align: center - This tutorial explains how to access the mesh data and metadata - (data about the elements, nodes, faces, region, zone ...) + This tutorial explains how to access a mesh data and metadata so it can be manipulated. +++ :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. grid-item-card:: Extract a mesh in split parts - :link: tutorials_get_specific_part_mesh + :link: ref_tutorials_extract_mesh_in_split_parts :link-type: ref :text-align: center - This tutorial show how to get meshes split on a given space or time for Fluent, - or CFX result files. + This tutorial shows how to extract meshes split on a given space or time from a result file. +++ :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. grid-item-card:: Split a mesh - :link: tutorials_split_mesh + :link: ref_tutorials_split_mesh :link-type: ref :text-align: center - This tutorial show how to split a mesh into different meshes. + This tutorial shows how to split a mesh on a given property. +++ :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` @@ -84,5 +83,5 @@ These tutorials explains how to explore different attributes of a given mesh wit get_mesh_from_result_file.rst read_mesh_metadata.rst explore_mesh.rst - get_specific_part_mesh.rst + extract_mesh_in_split_parts.rst split_mesh.rst From 5684f6ae5af351c62167a25653b8567ff5a92356 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 16 Dec 2024 10:26:19 +0100 Subject: [PATCH 41/49] changes the name of the explore_mesh_metadata.rst tutorial --- ...{read_mesh_metadata.rst => explore_mesh_metadata.rst} | 8 ++++---- doc/source/user_guide/tutorials/mesh/index.rst | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) rename doc/source/user_guide/tutorials/mesh/{read_mesh_metadata.rst => explore_mesh_metadata.rst} (97%) diff --git a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst similarity index 97% rename from doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst rename to doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst index 46b6de0551..0c1fdc29be 100644 --- a/doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst @@ -1,8 +1,8 @@ -.. _ref_tutorials_read_mesh_metadata: +.. _ref_tutorials_explore_mesh_metadata: -==================== -Read a mesh metadata -==================== +======================= +Explore a mesh metadata +======================= :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` diff --git a/doc/source/user_guide/tutorials/mesh/index.rst b/doc/source/user_guide/tutorials/mesh/index.rst index bf0791ac94..cfe2cf85af 100644 --- a/doc/source/user_guide/tutorials/mesh/index.rst +++ b/doc/source/user_guide/tutorials/mesh/index.rst @@ -31,13 +31,12 @@ These tutorials explains how to explore different attributes of a given mesh wit +++ :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` - .. grid-item-card:: Read a mesh metadata - :link: ref_tutorials_read_mesh_metadata + .. grid-item-card:: Explore a mesh metadata + :link: ref_tutorials_explore_mesh_metadata :link-type: ref :text-align: center - This tutorial explains how to read a mesh metadata - (data about the elements, nodes, faces, region, zone ...) before + This tutorial explains how to explore a mesh metadata before extracting the mesh from a result file. +++ @@ -81,7 +80,7 @@ These tutorials explains how to explore different attributes of a given mesh wit create_a_mesh_from_scratch.rst get_mesh_from_result_file.rst - read_mesh_metadata.rst + explore_mesh_metadata.rst explore_mesh.rst extract_mesh_in_split_parts.rst split_mesh.rst From a7c26d6065100ae60167bc83b27755e1cfa93646 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 16 Dec 2024 11:03:02 +0100 Subject: [PATCH 42/49] add explanation on the MeshesContainer labels when you use the split_mesh operator on the split_mesh.rst tutorial --- doc/source/user_guide/tutorials/mesh/split_mesh.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index 44390cdb85..a44034703a 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -122,6 +122,10 @@ Use the |split_mesh| operator to split an already existing |MeshedRegion| based Currently you can split a mesh by material or eltype. When you split a |MeshedRegion| the split parts are stored in the DPF collection called |MeshesContainer|. +Th |MeshesContainer| have a two different labels for each |MeshedRegion|: + +- A "body" label; +- A label with the property used to split the mesh. Here, the "mat" label. Here, we split the |MeshedRegion| by material. From 11a44f446f3489db70570286be72359c352b7688 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 16 Dec 2024 11:39:24 +0100 Subject: [PATCH 43/49] add more explanation for each approach on the split_mesh.rst tutorial --- .../user_guide/tutorials/mesh/split_mesh.rst | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/split_mesh.rst b/doc/source/user_guide/tutorials/mesh/split_mesh.rst index a44034703a..0190eac643 100644 --- a/doc/source/user_guide/tutorials/mesh/split_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/split_mesh.rst @@ -118,14 +118,14 @@ For more information see the :ref:`ref_tutorials_get_mesh_from_result_file` tuto First approach -------------- -Use the |split_mesh| operator to split an already existing |MeshedRegion| based on a property. -Currently you can split a mesh by material or eltype. +This approach consist of splitting an already existing |MeshedRegion| based on a given property. To accomplish +that goal, you must use the |split_mesh| operator. Currently you can split a mesh by material or eltype. -When you split a |MeshedRegion| the split parts are stored in the DPF collection called |MeshesContainer|. -Th |MeshesContainer| have a two different labels for each |MeshedRegion|: +The split mesh parts are stored in the DPF collection called |MeshesContainer|, where they are ordered by *labels*. +When you use the |split_mesh| operator, each split mesh part has two different *labels*: -- A "body" label; -- A label with the property used to split the mesh. Here, the "mat" label. +- A "body" *label*; +- A *label* with the property used to split the mesh. Here, we split the |MeshedRegion| by material. @@ -175,14 +175,23 @@ Here, we split the |MeshedRegion| by material. Second approach --------------- -First, use the |split_on_property_type| operator to split the mesh scoping. This operator splits a |Scoping| on given -properties (elshape and/or material, since 2025R1 it supports any scalar property field name contained in the mesh -property fields) and returns a |ScopingsContainer| with those split scopings. +This approach consists of splitting the |Scoping| of a given |MeshedRegion| based on a given property and then creating +a new |MeshedRegion| for each split |Scoping|. -Finally, create the split |MeshedRegion| objects with the |from_scopings| operator. The split parts are stored -in the DPF collection called |MeshesContainer|. +To accomplish this goal you must follow these steps: -Here, we split the mesh scoping by material. +#. Use the |split_on_property_type| operator to split the mesh |Scoping|. + This operator splits a |Scoping| on a given property (elshape and/or material, since 2025R1 it supports any + scalar property field name contained in the mesh property fields). The split |Scoping| is stored in the DPF + collection called |ScopingsContainer|, where they are ordered by *labels*. In this case, you get *labels* with + the property used to split the |Scoping|. + +#. Create the split |MeshedRegion| objects using the |from_scopings| operator for the |Scoping| of interest. + The split parts are stored in the DPF collection called |MeshesContainer| where they are also ordered by *labels*. + These *labels* are corresponding to the "mat" labels gotten with the |split_on_property_type| operator. + +Here, we split the mesh scoping by material and create a |MeshedRegion| for all the split |Scoping| in the +|ScopingsContainer|. .. tab-set:: From 425656609a77f46f0e93f753ccf9be09f6a62439 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 16 Dec 2024 14:44:05 +0100 Subject: [PATCH 44/49] add more explanation on the metadata info on the explore_mesh.rst tutorial --- .../tutorials/mesh/explore_mesh.rst | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst index f23f748d5c..033a04bce9 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh.rst @@ -9,6 +9,7 @@ Explore a mesh .. include:: ../../../links_and_refs.rst .. |PropertyField| replace:: :class:`PropertyField ` .. |element_types| replace:: :class:`list of available element types in a DPF mesh` +.. |StringField| replace:: :class:`StringField ` This tutorial explains how to access a mesh data and metadata so it can be manipulated. @@ -111,14 +112,14 @@ The mesh data includes : - Unit; - Nodes, elements and faces; -- Named selections. +- Named selections: . -Check all the types of data you can get from a mesh at |MeshedRegion|. - -When instantiating nodes, elements, faces and named selections you get the correspondent DPF objects: +When instantiating nodes, elements, faces and named selections you get the corresponding DPF objects: |Nodes|, |Elements|, |Faces| and |Scoping|. -Here, we get the mesh nodes. +For more information of other types of data you can get from a mesh, see the API reference of the |MeshedRegion| class. + +In this tutorial, we explore the data about the mesh nodes. .. tab-set:: @@ -179,7 +180,9 @@ Explore the mesh metadata You can access the mesh metadata by manipulating the |MeshedRegion| object properties. -You can check which ones are available. +The mesh metadata information describes the mesh composition. + +You can access which metadata information is available for a given result file. .. tab-set:: @@ -228,7 +231,9 @@ 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 +Here, we extract the element types for the mesh elements. + +The element type is given as a number. See the |element_types| to find the corresponding element name. .. tab-set:: @@ -272,4 +277,7 @@ corresponding element name. el_types_4 = meshed_region_4.property_field(property_name="eltype") # Print the element types by element - print(el_types_4) \ No newline at end of file + print(el_types_4) + +For more information about how to explore a mesh metadata before extracting it from a result file, see the +:ref:``tutorial. \ No newline at end of file From b44ea3d6226876fb6fdac72c83d1027602edf974 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 16 Dec 2024 14:44:26 +0100 Subject: [PATCH 45/49] add more explanation on the metadata info on the explore_mesh_metadata.rst tutorial --- .../tutorials/mesh/explore_mesh_metadata.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst index 0c1fdc29be..33e7426360 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst @@ -7,6 +7,8 @@ Explore a mesh metadata :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. include:: ../../../links_and_refs.rst +.. |PropertyField| replace:: :class:`PropertyField ` +.. |StringField| replace:: :class:`StringField ` This tutorial explains how to read a mesh metadata (data about the elements, nodes, faces, region, zone ...) before extracting the mesh from a result file. @@ -92,13 +94,15 @@ access the analysis results metadata and to instanciate results providers by ope # Create the Model model_4 = dpf.Model(data_sources=result_file_path_4) -Read the mesh metadata ----------------------- +Explore the mesh metadata +------------------------- You can access the mesh metadata with the |MeshInfo| object. It reads the metadata information before extracting -the MeshedRegion from the result file. +the |MeshedRegion| from the result file. -The mesh metadata information includes : +The mesh metadata information is stored in a |PropertyField| or in a |StringField|. They contain information +that describes the mesh composition and their data is mapped to the entity they are defined at. +The mesh metadata information information can be: - Properties; - Parts; @@ -108,7 +112,7 @@ The mesh metadata information includes : - Number of nodes and elements; - Elements types. -Get the the mesh metadata information and print the available ones. +You can access which metadata information is available for a given result file. .. tab-set:: @@ -142,7 +146,7 @@ Get the the mesh metadata information and print the available ones. # Print the mesh metadata information print(mesh_info_4) -You can extract each of those mesh information by manipulating the |MeshInfo| object properties. +You can also extract each of those mesh metadata information by manipulating the |MeshInfo| object properties. For example, we can check the part names (for the LSDYNA result file) or the cell zone names (for the Fluent or CFX result files): From 69b9c1b4cfeb0ebe0f6e9a067422385d0f5cf2bf Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 16 Dec 2024 16:03:29 +0100 Subject: [PATCH 46/49] updates on the text of create_a_mesh_from_scratch.rst turorial --- .../user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst index a592c0d038..25f0e16711 100644 --- a/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst +++ b/doc/source/user_guide/tutorials/mesh/create_a_mesh_from_scratch.rst @@ -13,7 +13,7 @@ with DPF operators. The ability to use scripting to create any DPF entity means that you are not dependent on result files and can connect the DPF environment with any Python tool. -Here, we create a parallel piped mesh made of linear hexa elements. +In this tutorial, we create a parallel piped mesh made of linear hexa elements. :jupyter-download-script:`Download tutorial as Python script` :jupyter-download-notebook:`Download tutorial as Jupyter notebook` @@ -51,7 +51,7 @@ Define the connectivity function -------------------------------- To create a mesh you must define the nodes connectivity. This means to define -the nodes ids connected to each node. +the nodes ids connected to each element. Here, we create a function that will find this connectivity. From 4f3b349a94c9f2912419b07b4afc4926cad3fad1 Mon Sep 17 00:00:00 2001 From: Luisa Felix Salles Date: Mon, 16 Dec 2024 16:17:10 +0100 Subject: [PATCH 47/49] Update doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst --- .../user_guide/tutorials/mesh/explore_mesh_metadata.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst b/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst index 33e7426360..71da5eafee 100644 --- a/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst +++ b/doc/source/user_guide/tutorials/mesh/explore_mesh_metadata.rst @@ -13,8 +13,8 @@ Explore a mesh metadata This tutorial explains how to read a mesh metadata (data about the elements, nodes, faces, region, zone ...) before extracting the mesh from a result file. -:jupyter-download-script:`Download tutorial as Python script` -:jupyter-download-notebook:`Download tutorial as Jupyter notebook` +:jupyter-download-script:`Download tutorial as Python script` +:jupyter-download-notebook:`Download tutorial as Jupyter notebook` Get the result file ------------------- From ae30d919bad2d7f96f271bf4a737a611d9e0fc98 Mon Sep 17 00:00:00 2001 From: Luisa Felix Salles Date: Wed, 18 Dec 2024 16:16:18 +0100 Subject: [PATCH 48/49] Update doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst --- .../user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst b/doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst index 4f25fc36ec..deab5ecb57 100644 --- a/doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst +++ b/doc/source/user_guide/tutorials/mesh/extract_mesh_in_split_parts.rst @@ -8,7 +8,7 @@ Extract a mesh in split parts .. include:: ../../../links_and_refs.rst .. |MeshesContainer| replace:: :class:`MeshesContainer ` -.. |meshes_provider| replace:: :class:`mesh_provider ` +.. |meshes_provider| replace:: :class:`meshes_provider ` This tutorial shows how to extract meshes split on a given space or time from a result file. From 8ba9f0a1a676a8c45347b096f0a9de96431d8491 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Fri, 20 Dec 2024 12:00:42 +0100 Subject: [PATCH 49/49] delete file basic_tutorial.rst --- .../user_guide/tutorials/basic_tutorial.rst | 241 ------------------ 1 file changed, 241 deletions(-) delete mode 100644 doc/source/user_guide/tutorials/basic_tutorial.rst diff --git a/doc/source/user_guide/tutorials/basic_tutorial.rst b/doc/source/user_guide/tutorials/basic_tutorial.rst deleted file mode 100644 index 11b7097676..0000000000 --- a/doc/source/user_guide/tutorials/basic_tutorial.rst +++ /dev/null @@ -1,241 +0,0 @@ -.. _ref_tutorials_basic: - -================== -The basic tutorial -================== - -This tutorial guides throughout the basic concepts and features of the PyDPF-Core tool. -It helps to have a Python interpreter for hands-on experience, but all code examples are -executed, so the tutorial can be read off-line as well. - -For a complete description of all the objects and modules, see the :ref:`API reference ` section. - -This page is divided in two sections: - -.. grid:: 1 1 2 2 - :gutter: 2 - :padding: 2 - :margin: 2 - - .. grid-item-card:: Overview - :link: tutorials_overview - :link-type: ref - :text-align: center - - Learn the different ways to interact with data by calling PyDPF-Core commands and operators. - - .. grid-item-card:: Postprocessing main steps - :link: tutorials_main_steps - :link-type: ref - :text-align: center - - How to do a basic prost-processing by transforming simulation data into output - data that can be used to visualize and analyze results - -.. _tutorials_overview: - -Overview --------- - - - -.. _tutorials_main_steps: - -Postprocessing main steps -------------------------- - -There are five main steps to transform simulation data into output data that can -be used to visualize and analyze simulation results: - -.. grid:: - :gutter: 2 - :padding: 2 - :margin: 2 - - .. grid-item-card:: 1 - :link: tutorials_main_steps_1 - :link-type: ref - :text-align: center - - Importing and opening results files - - .. grid-item-card:: 2 - :link: tutorials_main_steps_2 - :link-type: ref - :text-align: center - - Access and extract results - - .. grid-item-card:: 3 - :link: tutorials_main_steps_3 - :link-type: ref - :text-align: center - - Transform available data - - .. grid-item-card:: 4 - :link: tutorials_main_steps_4 - :link-type: ref - :text-align: center - - Visualize the data - - .. grid-item-card:: 5 - :link: tutorials_main_steps_5 - :link-type: ref - :text-align: center - - Extract data - -.. _tutorials_main_steps_1: - -1- Importing and opening results files -************************************** - -First, import the DPF-Core module as ``dpf`` and import the included examples file - -.. code-block:: python - - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - -`DataSources' is a class that manages paths to their files. Use this object to declare -data inputs for DPF and define their locations. - -.. code-block:: python - - # Define the DataSources object - my_data_sources = dpf.DataSources(result_path=examples.find_simple_bar()) - - -The model is a helper designed to give shortcuts to access the analysis results -metadata, by opening a DataSources or a Streams, and to instanciate results provider for it. - -Printing the model displays: - - - Analysis type - - Available results - - Size of the mesh - - Number of results - -.. code-block:: python - - # Define the Model object - my_model = dpf.Model(data_sources=my_data_sources) - print(my_model) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - from ansys.dpf import core as dpf - from ansys.dpf.core import examples - from ansys.dpf.core import operators as ops - my_data_sources = dpf.DataSources(result_path=examples.find_simple_bar()) - my_model = dpf.Model(data_sources=my_data_sources) - print(my_model) - -.. _tutorials_main_steps_2: - -2- Access and extract results -***************************** - -We see in the model that a displacement result is available. You can access this result by: - -.. code-block:: python - - # Define the displacement results through the models property `results` - my_displacements = my_model.results.displacement.eval() - print(my_displacements) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_displacements = my_model.results.displacement.eval() - print(my_displacements) - -The displacement data can be extract by: - -.. code-block:: python - - # Extract the data of the displacement field - my_displacements_0 = my_displacements[0].data - print(my_displacements_0) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_displacements_0 = my_displacements[0].data - print(my_displacements_0) - -.. _tutorials_main_steps_3: - -3- Transform available data -*************************** - -Several transformations can be made with the data. They can be a single operation, -by using only one operator, or they can represent a succession of operations, by defining a -workflow with chained operators. - -Here we star by computing the displacements norm. - -.. code-block:: python - - # Define the norm operator (here for a fields container) for the displacement - my_norm = ops.math.norm_fc(fields_container=my_displacements).eval() - print(my_norm[0].data) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_norm = ops.math.norm_fc(fields_container=my_displacements).eval() - print(my_norm[0].data) - -Then we compute the maximum values of the normalised displacement - -.. code-block:: python - - # Define the maximum operator and chain it to the norm operator - my_max= ops.min_max.min_max_fc(fields_container=my_norm).outputs.field_max() - print(my_max) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_max = ops.min_max.min_max_fc(fields_container=my_norm).outputs.field_max() - print(my_max) - -.. _tutorials_main_steps_4: - -4- Visualize the data -********************* - -Plot the transformed displacement results - -.. code-block:: python - - # Define the support of the plot (here we plot the displacement over the mesh) - my_model.metadata.meshed_region.plot(field_or_fields_container=my_displacements) - -.. rst-class:: sphx-glr-script-out - - .. jupyter-execute:: - :hide-code: - - my_model.metadata.meshed_region.plot(field_or_fields_container=my_displacements) - -.. _tutorials_main_steps_5: - -5- Extract the data -******************* -