Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1f46ba8
Remove the "language and usage" tutorial section
PProfizi May 27, 2025
a495b5a
Remove the "manipulate physics data" tutorial section
PProfizi May 27, 2025
c3411cc
Rework the tutorials sections
PProfizi May 27, 2025
6309ed4
Add the data_arrays.rst tutorial (WIP)
PProfizi May 28, 2025
d876c37
Revert "Rework the tutorials sections"
luisaFelixSalles Jul 24, 2025
4db0240
Revert "Remove the "manipulate physics data" tutorial section"
luisaFelixSalles Jul 24, 2025
97f309d
Revert "Remove the "language and usage" tutorial section"
luisaFelixSalles Jul 24, 2025
0af816b
Add data array tutorial on the section index page
luisaFelixSalles Jul 24, 2025
9e0b239
Merge branch 'doc/new-tutorials-section' into tutorials/data_structur…
luisaFelixSalles Jul 24, 2025
390c314
Merge branch 'doc/new-tutorials-section' into tutorials/data_structur…
PProfizi Jul 25, 2025
2ec3a52
WIP
PProfizi Jul 25, 2025
4de3496
Mark tutorial on collections as coming soon
PProfizi Jul 25, 2025
f0c026c
Update the Model description
PProfizi Jul 25, 2025
7670a9a
Update the introduction
PProfizi Jul 25, 2025
96dc374
Update the note of field data
PProfizi Jul 25, 2025
238c3c3
remove the section on scoping
PProfizi Jul 25, 2025
6be652b
Fix title consistency
PProfizi Jul 25, 2025
b50dc11
Remove last step from 01-main-steps.rst
PProfizi Jul 25, 2025
a5093e3
Update create fields based on result files
PProfizi Jul 25, 2025
e2a5db0
Fix typehinting of field.dimensionality
PProfizi Jul 25, 2025
716a446
Update the "from scratch" section
PProfizi Jul 25, 2025
f082ae2
Fix the fields_factory.create_matrix_field by having the Dimensionali…
PProfizi Jul 28, 2025
588427d
Remove useless checks on PropertyField.location and StringField.location
PProfizi Jul 28, 2025
8a359ac
Fix check in PropertyField.location and StringField.location getter
PProfizi Jul 28, 2025
f32573f
Fix some typehints
PProfizi Jul 28, 2025
69438fd
Refactor and typehint fields_factory.py
PProfizi Jul 28, 2025
b18b4d0
Update field creation sections
PProfizi Jul 28, 2025
1c3f68e
Fix index card
PProfizi Jul 28, 2025
5edcb40
Update field metadata section in data_arrays.rst
PProfizi Jul 28, 2025
e2d628d
Merge branch 'doc/new-tutorials-section' into tutorials/data_structur…
PProfizi Jul 28, 2025
226bb55
Correct reference to te tutorial on the section card
luisaFelixSalles Jul 28, 2025
9c531b5
Update doc/source/user_guide/tutorials/data_structures/data_arrays.rst
PProfizi Jul 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
542 changes: 542 additions & 0 deletions doc/source/user_guide/tutorials/data_structures/data_arrays.rst

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions doc/source/user_guide/tutorials/data_structures/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@ These tutorials explains how these structures work and how you can manipulate da
:padding: 2
:margin: 2

.. grid-item-card:: DPF raw data storage structures
:link: ref_tutorials
.. grid-item-card:: Data arrays - Fields
:link: ref_tutorials_data_arrays
:link-type: ref
:text-align: center

This tutorial shows how to create and work with some DPF data arrays:
Field, StringField and PropertyField
This tutorial shows how to create and work with data arrays in PyDPF-Core.


.. grid-item-card:: DPF collections
:link: ref_tutorials_language_and_usage
:link-type: ref
:text-align: center
:class-header: sd-bg-light sd-text-dark
:class-footer: sd-bg-light sd-text-dark

This tutorial shows how to create and work with some DPF collections:
FieldsContainer, MeshesContainer and ScopingContainer
FieldsContainer, MeshesContainer and ScopingsContainer

+++
Coming soon

.. toctree::
:maxdepth: 2
:hidden:

data_arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@ inputs for PyDPF-Core APIs.
Use a |Model|
-------------

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.
The :class:`Model <ansys.dpf.core.model.Model>` class creates and evaluates common readers for the files it is given,
such as a mesh provider, a result info provider, and a streams provider.
It provides dynamically built methods to extract the results available in the files, as well as many shortcuts
to facilitate exploration of the available data.

To create a |Model| you can provide to the *'data_sources'* argument.:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Postprocessing main steps
-------------------------

There are five main steps to transform simulation data into output data that can
There are four main steps to transform simulation data into output data that can
be used to visualize and analyze simulation results:

.. grid::
Expand Down Expand Up @@ -39,17 +39,10 @@ be used to visualize and analyze simulation results:

Visualize the data

.. grid-item-card:: 5
:link: tutorials_main_steps_5
:link-type: ref
:text-align: center

Export data

.. _tutorials_main_steps_1:

1- Importing and opening results files
**************************************
1- Import and open results files
********************************

First, import the DPF-Core module as ``dpf`` and import the included examples file

Expand All @@ -68,8 +61,10 @@ data inputs for DPF and define their locations.
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.
The :class:`Model <ansys.dpf.core.model.Model>` class creates and evaluates common readers for the files it is given,
such as a mesh provider, a result info provider, and a streams provider.
It provides dynamically built methods to extract the results available in the files, as well as many shortcuts
to facilitate exploration of the available data.

Printing the model displays:

Expand Down Expand Up @@ -192,8 +187,3 @@ Plot the transformed displacement results
:hide-code:

my_model.metadata.meshed_region.plot(field_or_fields_container=my_displacements)

.. _tutorials_main_steps_5:

5- Extract the data
*******************
2 changes: 2 additions & 0 deletions src/ansys/dpf/core/dimensionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def __init__(self, dim_vec=None, nature: natures = natures.vector):
self.dim = [3, 3]
elif self.nature == natures.scalar:
self.dim = [1]
elif self.nature == natures.matrix:
self.dim = [3, 3]

def is_1d_dim(self):
"""Check if dimensionality is 1."""
Expand Down
7 changes: 4 additions & 3 deletions src/ansys/dpf/core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from ansys.dpf.gate.errors import DPFServerException

if TYPE_CHECKING: # pragma: nocover
from ansys.dpf.core.dimensionality import Dimensionality
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.meshed_region import MeshedRegion
from ansys.dpf.core.results import Result
Expand Down Expand Up @@ -442,7 +443,7 @@ def get_entity_data_by_id(self, id: int) -> dpf_array.DPFArray:
data.shape = (data.size // n_comp, n_comp)
return data

def append(self, data, scopingid):
def append(self, data: float | list[float] | np.ndarray[np.float64], scopingid: int):
"""Append data to the Field."""
if isinstance(data, list):
if isinstance(data[0], list):
Expand Down Expand Up @@ -520,7 +521,7 @@ def to_nodal(self):
def plot(
self,
shell_layers: eshell_layers = None,
deform_by: Union[Field, Result, Operator] = None,
deform_by: Field | Result | Operator = None,
scale_factor: float = 1.0,
meshed_region: MeshedRegion = None,
**kwargs,
Expand Down Expand Up @@ -675,7 +676,7 @@ def dimensionality(self):
return self.field_definition.dimensionality

@dimensionality.setter
def dimensionality(self, value):
def dimensionality(self, value: Dimensionality):
fielddef = self.field_definition
fielddef.dimensionality = value
self.field_definition = fielddef
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/field_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def shell_layers(self, value):
self._api.csfield_definition_set_shell_layers(self, value)

@dimensionality.setter
def dimensionality(self, value):
def dimensionality(self, value: Dimensionality):
if not isinstance(value, Dimensionality):
raise TypeError("the dimensionality needs to be of type Dimensionality")
self._api.csfield_definition_set_dimensionality(
Expand Down
Loading
Loading