diff --git a/doc/source/user_guide/how-to/index.rst b/doc/source/user_guide/how-to/index.rst index 821a728ae17..99729c54994 100644 --- a/doc/source/user_guide/how-to/index.rst +++ b/doc/source/user_guide/how-to/index.rst @@ -1,10 +1,12 @@ .. _ref_how_to: Enriching DPF capabilities ----------------------------------------- +++++++++++++++++++++++++++ -.. grid:: 3 +.. grid:: 2 :gutter: 2 + :padding: 2 + :margin: 2 .. grid-item-card:: Create custom operators and plugins :link: user_guide_custom_operators @@ -12,7 +14,7 @@ Enriching DPF capabilities :text-align: center .. image:: ../images/drawings/plugin-logo.png - :width: 50% + :width: 25% .. grid-item-card:: Switch between local and remote server @@ -21,7 +23,7 @@ Enriching DPF capabilities :text-align: center .. image:: ../images/drawings/remote_machines.png - + :width: 25% .. grid-item-card:: Access Entry and Premium capabilities :link: user_guide_server_context @@ -29,7 +31,7 @@ Enriching DPF capabilities :text-align: center .. image:: ../images/drawings/entry_premium.png - + :width: 25% .. grid-item-card:: Configure DPF plugins load :link: user_guide_xmlfiles diff --git a/doc/source/user_guide/troubleshooting/index.rst b/doc/source/user_guide/troubleshooting/index.rst index ee6250df72c..dad8872370a 100644 --- a/doc/source/user_guide/troubleshooting/index.rst +++ b/doc/source/user_guide/troubleshooting/index.rst @@ -3,8 +3,10 @@ Troubleshooting --------------- -.. grid:: 3 +.. grid:: 2 :gutter: 2 + :padding: 2 + :margin: 2 .. grid-item-card:: Server issues :link: ref_server_issues diff --git a/doc/source/user_guide/tutorials/index.rst b/doc/source/user_guide/tutorials/index.rst index 5e3d5f9fc52..c461254bfc3 100644 --- a/doc/source/user_guide/tutorials/index.rst +++ b/doc/source/user_guide/tutorials/index.rst @@ -3,94 +3,373 @@ Tutorials --------- +What you need to know ++++++++++++++++++++++ -The following tutorials show in details how to use basic features of PyDPF-Core -for each usage main step. +These tutorials go through the steps required to access, analyze, +and transform simulation data using PyDPF-Core. -:bdg-dark-line:`Define simulation data` :octicon:`arrow-right;1em` :bdg-dark-line:`Store input data in DPF` :octicon:`arrow-right;1em` :bdg-dark-line:`Transform available data` :octicon:`arrow-right;1em` :bdg-dark-line:`Extract data` +Tutorials are more substantive and complex than examples. They are designed to teach how to perform a task and understand +the underlying concepts, providing detailed explanations at each stage, whereas examples showcase end-to-end specific processes. -**Define input data** +DPF interacts with data stored in DPF data structures. +These DPF data structures are generated automatically when reading data from results file (`ref_to_section`) but they can also be generated from scratch (`ref_to_section`) when no supported result file is available. +Overview +++++++++ -.. grid:: 3 +There are four main steps to transform simulation data into output data that can +be used to visualize and analyze simulation results: - .. grid-item-card:: Data Sources - :link: ref_tutorials_model - :link-type: ref - :text-align: center +.. grid:: + :gutter: 0 - .. grid-item-card:: DPF model - :link: ref_tutorials_model - :link-type: ref - :text-align: center + .. grid-item:: + :child-direction: row -**Load data** + .. button-ref:: initial_topic + :ref-type: ref + :color: primary + :shadow: + :expand: + Importing and opening results files -.. grid:: 3 + :octicon:`arrow-right;1em` - .. grid-item-card:: Data arrays - :link: ref_tutorials_model - :link-type: ref - :text-align: center + .. button-ref:: disp_results + :ref-type: ref + :color: primary + :shadow: + :expand: - Fields + Access and extract results - PropertyField + :octicon:`arrow-right;1em` - StringField + .. button-ref:: disp_results + :ref-type: ref + :color: primary + :shadow: - CustomTypeField + Transform available data - .. grid-item-card:: Data maps - :link: ref_tutorials_model - :link-type: ref - :text-align: center + :octicon:`arrow-right;1em` - GenericDataContainer + .. button-ref:: disp_results + :ref-type: ref + :color: primary + :shadow: - DataTree + Visualize the data - .. grid-item-card:: Collections - :link: ref_tutorials_model - :link-type: ref - :text-align: center + :octicon:`arrow-right;1em` - LabelSpace + .. button-ref:: disp_results + :ref-type: ref + :color: primary + :shadow: - FieldsContainer + Extract data - MeshContainer +The following tutorial go through each of these steps in a basic manipulation. More advanced +approaches can be accessed with the listed buttons. Each tutorial presents code snippets specific +to each supported file format. -**Transform data** +.. centered:: Importing and opening results files +.. grid:: + :gutter: 5 + :padding: 2 -.. grid:: 3 + .. grid-item:: + :columns: 7 + :class: sd-shadow-sm - .. grid-item-card:: Process creation - :link: ref_tutorials_model - :link-type: ref - :text-align: center + .. code-block:: python - Operators + # First, import the DPF-Core module as ``dpf`` and import the included + # examples file + from ansys.dpf import core as dpf + from ansys.dpf.core import examples + from ansys.dpf.core import operators as ops - Workflow + # `DataSources' is a class that manages paths to their files. + # Use this object to declare data inputs for DPF and define their locations. + my_data_sources = dpf.DataSources(result_path=examples.find_simple_bar()) - .. grid-item-card:: Results visualization - :link: ref_tutorials_model - :link-type: ref - :text-align: center + # 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. - Plotter + my_model = dpf.Model(data_sources=my_data_sources) + print(my_model) - Animator + .. rst-class:: sphx-glr-script-out -**Export data** + .. exec_code:: + :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) -.. grid:: 3 + .. grid-item:: + :columns: 1 - .. grid-item-card:: Serialization - :link: ref_tutorials_model - :link-type: ref - :text-align: center \ No newline at end of file + .. grid-item:: + :columns: 4 + :class: sd-shadow-sm + + .. centered:: :octicon:`pin;1em` + + .. button-ref:: ref_tutorials_model + :ref-type: ref + :color: secondary + :shadow: + :expand: + + I have one file. + + .. button-ref:: disp_results + :ref-type: ref + :color: secondary + :shadow: + :expand: + + I have more than one file + + .. button-ref:: ref_tutorials_model + :ref-type: ref + :color: secondary + :shadow: + :expand: + + I don’t know my file(s) type(s) + + +.. centered:: **Access and extract results** + +.. grid:: 2 + :gutter: 5 + :padding: 2 + + .. grid-item:: + :columns: 7 + :class: sd-shadow-sm + + .. code-block:: python + + # We see that we have a displacement result + # 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 + + .. exec_code:: + :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) + my_displacements = my_model.results.displacement.eval() + print(my_displacements) + + .. 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 + + .. exec_code:: + :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) + my_displacements = my_model.results.displacement.eval() + my_displacements_0 = my_displacements[0].data + print(my_displacements_0) + + .. grid-item:: + :columns: 1 + + .. grid-item:: + :columns: 4 + :class: sd-shadow-sm + + .. centered:: More specific tutorials + + .. button-ref:: ref_tutorials_model + :ref-type: ref + :color: secondary + :shadow: + :expand: + + Narrow down data + + .. button-ref:: ref_tutorials_model + :ref-type: ref + :color: secondary + :shadow: + :expand: + + Extract and explore results data + + .. button-ref:: ref_tutorials_model + :ref-type: ref + :color: secondary + :shadow: + :expand: + + Extract and explore results metadata + +.. centered:: **Transform data** + +.. grid:: 2 + :gutter: 5 + :padding: 2 + + .. grid-item:: + :columns: 7 + :class: sd-shadow-sm + + .. code-block:: python + + # Compute the norm of the displacement + # 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 + + .. exec_code:: + :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) + my_displacements = my_model.results.displacement.eval() + my_displacements_0 = my_displacements[0].data + my_norm = ops.math.norm_fc(fields_container=my_displacements).eval() + print(my_norm[0].data) + + .. code-block:: python + + # Compute the maximum of the normalised displacement + # 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 + + .. exec_code:: + :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) + my_displacements = my_model.results.displacement.eval() + my_displacements_0 = my_displacements[0].data + my_norm = ops.math.norm_fc(fields_container=my_displacements).eval() + my_max = ops.min_max.min_max_fc(fields_container=my_norm).outputs.field_max() + print(my_max) + + .. grid-item:: + :columns: 1 + + .. grid-item:: + :columns: 4 + :class: sd-shadow-sm + + .. centered:: More specific tutorials + + .. button-ref:: ref_tutorials_model + :ref-type: ref + :shadow: + :expand: + :class: sd-bg-secondary + :color: secondary + + Using operators + + .. button-ref:: disp_results + :ref-type: ref + :class: sd-bg-secondary + :shadow: + :expand: + + Create a workflow + +.. centered:: **Visualize data** + +.. grid:: 2 + :gutter: 5 + :padding: 2 + + .. grid-item:: + :columns: 7 + :class: sd-shadow-sm + + .. code-block:: python + + # Plot the displacement + # Define the support of the plot (here we plot the displacement over the mesh) + my_plot = my_model.metadata.meshed_region.plot(field_or_fields_container=my_displacements) + print(my_plot) + + .. rst-class:: sphx-glr-script-out + + .. exec_code:: + :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) + my_displacements = my_model.results.displacement.eval() + my_displacements_0 = my_displacements[0].data + my_norm_operator = dpf.operators.math.norm_fc(fields_container=my_displacements).eval() + my_max_operator = dpf.operators.min_max.min_max_fc(fields_container=my_norm_operator).eval() + # my_plot = my_model.metadata.meshed_region.plot(field_or_fields_container=my_displacements) + # print(my_plot) + + .. grid-item:: + :columns: 1 + + .. grid-item:: + :columns: 4 + :class: sd-shadow-sm + + .. centered:: More specific tutorials + + .. button-ref:: ref_tutorials_model + :ref-type: ref + :class: sd-btn-secondary + :shadow: + :expand: + + Plotting + + .. button-ref:: disp_results + :ref-type: ref + :color: secondary + :shadow: + :expand: + + Animation \ No newline at end of file