Skip to content

Commit

Permalink
Merge branch 'master' into feat/change-tox-environments-logic
Browse files Browse the repository at this point in the history
  • Loading branch information
moe-ad authored Jan 14, 2025
2 parents 1a823c6 + c2e57d6 commit 1d73e48
Show file tree
Hide file tree
Showing 29 changed files with 4,548 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pydpf-post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
shell: bash
working-directory: pydpf-post/tests
run: |
pytest $DEBUG --reruns 2 .
pytest $DEBUG --maxfail=5 --reruns 2 .
if: always()
timeout-minutes: 60

Expand Down
14 changes: 7 additions & 7 deletions doc/source/_static/dpf_operators.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/source/getting_started/dpf_server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ simulation workflow.
The DPF Server is packaged within the **Ansys installer** in Ansys 2021 R1 and later.

It is also available as a standalone package that contains all the necessary files to run, enabling DPF capabilities.
The standalone DPF Server is available on the `DPF Pre-Release page <https://download.ansys.com/Others/DPF%20Pre-Release>`_ of the Ansys Customer Portal.
The standalone DPF Server is available on the `DPF Pre-Release page <https://download-archive.ansys.com/Others/DPF%20Pre-Release>`_ of the Ansys Customer Portal.
The first standalone version of DPF Server available is 6.0 (2023 R2).

The sections on this page describe how to install and use a standalone DPF Server.
Expand Down
2 changes: 1 addition & 1 deletion doc/source/operator_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ DPF operators allow you to manipulate and transform simulation data.


For Ansys 2023 R2 and later, the DPF Server licensing logic for operators in DPF depends on the active
`server context<https://dpf.docs.pyansys.com/version/stable/api/ansys.dpf.core.server_context.html#ansys.dpf.core.server_context.ServerContext>`_.
`server context <https://dpf.docs.pyansys.com/version/stable/api/ansys.dpf.core.server_context.html#ansys.dpf.core.server_context.ServerContext>`_.

The available contexts are **Premium** and **Entry**.
Licensed operators are marked as such in the documentation using the ``license`` property.
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements_install.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
importlib-metadata==8.5.0
numpy==2.1.3
numpy==2.2.1
packaging==24.2
psutil==6.1.1
tqdm==4.67.1
43 changes: 38 additions & 5 deletions src/ansys/dpf/core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ class Field(_FieldBase):
The field's scoping defines the order of the data, for example: the first ID in the
``scoping`` identifies to which entity the first ``entity data`` belongs.
For more information, see the `Fields container and fields
<https://dpf.docs.pyansys.com/version/stable/user_guide/fields_container.html>`_
documentation section.
The minimum requirement for a well defined field is for it to have a dimensionality
(scalar, three components vector, six components symmetrical matrix, and so on), a location
("Nodal", "Elemental", "ElementalNodal", "TimeFreq"), a data vector, and a scoping with IDs.
You can also set the number of shell layers. If the field has one elementary data by entity
(elementary data size equals the number of components for "Nodal" or "Elemental" field for example),
then the data vector can be set directly. If a more complex field is required
("ElementalNodal" field for example), the data can be set entity by entity.
For more information, see `Fields container and fields
<https://dpf.docs.pyansys.com/version/stable/user_guide/fields_container.html>`_.
Parameters
Expand Down Expand Up @@ -81,12 +88,38 @@ class Field(_FieldBase):
--------
Create a field from scratch.
>>> from ansys.dpf.core import fields_factory
>>> from ansys.dpf.core import locations
>>> from ansys.dpf import core as dpf
>>> field_with_classic_api = dpf.Field()
>>> field_with_classic_api.location = locations.nodal
>>> field_with_factory = fields_factory.create_scalar_field(10)
Create a symmetrical matrix elemental field from scratch.
>>> from ansys.dpf import core as dpf
>>> num_entities = 2
>>> my_field = dpf.Field(num_entities, dpf.natures.symmatrix, locations.elemental)
>>> my_scoping = dpf.Scoping(location=locations.elemental, ids=[1, 2])
>>> my_field.scoping = my_scoping
Add all the data at once.
>>> from ansys.dpf import core as dpf
>>> my_data = [1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0]
>>> my_field.data = my_data
Add data entity by entity.
>>> from ansys.dpf import core as dpf
>>> my_elem_data = [1.0,1.0,1.0,0.0,0.0,0.0]
>>> my_field.append(my_elem_data, scopingid=1)
>>> my_field.append(my_elem_data, scopingid=2)
Create a nodal scalar field using the fields factory.
>>> from ansys.dpf.core import fields_factory
>>> from ansys.dpf import core as dpf
>>> my_scalar_field = fields_factory.create_scalar_field(num_entities=2, location=locations.nodal)
>>> my_scalar_field.data = [1.0, 3.0]
Extract a displacement field from a transient result file.
Expand Down
68 changes: 41 additions & 27 deletions src/ansys/dpf/core/mesh_scoping_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,87 +23,101 @@
"""
mesh_scoping_factory.
Contains functions to simplify creating mesh scopings.
Contains functions to simplify creating a mesh scoping.
"""

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING: # pragma: nocover
from ansys.dpf.core.server_types import AnyServerType
from ansys.dpf.core.scoping import IdVectorType
from ansys.dpf.core.model import Model

from ansys.dpf.core import Scoping
from ansys.dpf.core.common import locations


def nodal_scoping(node_ids, server=None):
"""Create a specific nodal :class:`ansys.dpf.core.Scoping` associated with a mesh.
def nodal_scoping(node_ids: IdVectorType, server: AnyServerType = None) -> Scoping:
"""Create a nodal :class:`ansys.dpf.core.Scoping` defining a list of node IDs.
Parameters
----------
node_ids : list[int]
List of IDs for the nodes.
server : DpfServer, optional
node_ids:
List of node IDs.
server:
Server with the channel connected to the remote or local instance.
The default is ``None``, in which case an attempt is made to use the
global server.
Returns
-------
scoping : Scoping
scoping:
A nodal scoping containing the node IDs provided.
"""
scoping = Scoping(server=server, ids=node_ids, location=locations.nodal)
return scoping


def elemental_scoping(element_ids, server=None):
"""Create a specific elemental :class:`ansys.dpf.core.Scoping` associated with a mesh.
def elemental_scoping(element_ids: IdVectorType, server: AnyServerType = None) -> Scoping:
"""Create an elemental :class:`ansys.dpf.core.Scoping` defining a list of element IDs.
Parameters
----------
element_ids : list[int]
List of IDs for the elements.
server : DpfServer, optional
element_ids:
List of element IDs.
server:
Server with the channel connected to the remote or local instance.
The default is ``None``, in which case an attempt is made to use the
global server.
Returns
-------
scoping : Scoping
scoping:
An elemental scoping containing the element IDs provided.
"""
scoping = Scoping(server=server, ids=element_ids, location=locations.elemental)
return scoping


def face_scoping(face_ids, server=None):
"""Create a specific face :class:`ansys.dpf.core.Scoping` associated with a mesh.
def face_scoping(face_ids: IdVectorType, server: AnyServerType = None) -> Scoping:
"""Create a face :class:`ansys.dpf.core.Scoping`defining a list of face IDs.
Parameters
----------
face_ids : list[int]
List of IDs for the faces.
server : DpfServer, optional
face_ids:
List of face IDs.
server:
Server with the channel connected to the remote or local instance.
The default is ``None``, in which case an attempt is made to use the
global server.
Returns
-------
scoping : Scoping
scoping:
A face scoping containing the face IDs provided.
"""
scoping = Scoping(server=server, ids=face_ids, location=locations.faces)
return scoping


def named_selection_scoping(named_selection_name, model, server=None):
"""Create a specific :class:`ansys.dpf.core.Scoping` associated with a specified model's mesh.
def named_selection_scoping(
named_selection_name: str, model: Model, server: AnyServerType = None
) -> Scoping:
"""Create a :class:`ansys.dpf.core.Scoping` based on a named selection in a model.
Parameters
----------
named_selection_name : str
named_selection_name:
Name of the named selection.
server : DpfServer, optional
Server with the channel connected to the remote or local instance.
The default is ``None``, in which case an attempt is made to use the
global server.
model:
Model where the named selection exists.
Returns
-------
scoping : Scoping
scoping:
A scoping containing the IDs of the entities in the named selection.
The location depends on the type of entities targeted by the named selection.
"""
return model.metadata.named_selection(named_selection_name)
2 changes: 2 additions & 0 deletions src/ansys/dpf/core/operators/averaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from .nodal_fraction_fc import nodal_fraction_fc
from .nodal_to_elemental import nodal_to_elemental
from .nodal_to_elemental_fc import nodal_to_elemental_fc
from .nodal_to_elemental_nodal import nodal_to_elemental_nodal
from .nodal_to_elemental_nodal_fc import nodal_to_elemental_nodal_fc
from .to_elemental_fc import to_elemental_fc
from .to_elemental_nodal_fc import to_elemental_nodal_fc
from .to_nodal import to_nodal
Expand Down
Loading

0 comments on commit 1d73e48

Please sign in to comment.