Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
janvonrickenbach committed Jan 15, 2024
2 parents da258e7 + 945afc9 commit 38f35e6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
18 changes: 9 additions & 9 deletions examples/006_filter_composite_data_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
layered composites. You can filter strains and stresses by material, layer, or
analysis ply. Filtering by analysis ply is implemented on the server side and
exposed with the :func:`.get_ply_wise_data` function. In this case, the data is
filtered (and reduced) on the server side, and only the resulting field is returned
filtered (and reduced) on the server side and only the resulting field is returned
to the client. This is the recommended way to filter data if possible.
For more complex filtering, the data is transferred to the client side and filtered
using NumPy functionality.
using numpy functionality.
The examples show filtering data by layer, spot, and node, as well as material
or analysis ply ID. To learn more about how layered result data is organized,
see :ref:`select_indices`.
Expand Down Expand Up @@ -69,20 +69,20 @@

# %%
# The easiest way to filter data by analysis ply is to use the :func:`.get_ply_wise_data` function.
# This function supports different reduction strategies such as computing the average
# or maximum/minimum over the spot locations.
# This function supports different reduction strategies such as computing the average,
# maximum, or minimum over the spot locations.
# It also supports selecting a specific spot (TOP, MID, BOT) directly.
# This example selects the maximum value over all spots for each node and then requests
# the elemental location that implies averaging over all nodes in an element.
# Using the :func:`.get_ply_wise_data` function has the advantage that all the averaging and
# filtering is done on the server side.
# the elemental location, which implies averaging over all nodes in an element.
# Using the :func:`.get_ply_wise_data` function has the advantage that all the averaging
# and filtering is done on the server side.
if version_equal_or_later(server, "8.0"):
elemental_max = get_ply_wise_data(
field=stress_field,
ply_name="P1L1__ud_patch ns1",
mesh=composite_model.get_mesh(),
component=Sym3x3TensorComponent.TENSOR11,
spot_reduction_strategy=SpotReductionStrategy.MAX,
reduction_strategy=SpotReductionStrategy.MAX,
requested_location=dpf.locations.elemental,
)

Expand All @@ -94,7 +94,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This example shows how to filter data by layer, spot, and node using the generic filtering on
# the client side.
# It plots stress values in the material direction for the first node and top spot.
# This code plots stress values in the material direction for the first node and top spot.

# %%
# Get element information for all elements and show the first one as an example.
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ansys.dpf.core import connect_to_server
from ansys.dpf.core import server as _dpf_server
from ansys.dpf.core import server_context, start_local_server
from ansys.dpf.core import start_local_server

from ansys.dpf.composites.server_helpers._load_plugin import load_composites_plugin

Expand Down Expand Up @@ -77,16 +77,10 @@ def connect_to_or_start_server(
if len(list(connect_kwargs.keys())) > 0:
server = connect_to_server(
**connect_kwargs,
context=_dpf_server.server_context.ServerContext(
server_context.LicensingContextType.premium
),
)
else:
server = start_local_server(
ansys_path=ansys_path,
context=_dpf_server.server_context.ServerContext(
server_context.LicensingContextType.premium
),
)

required_version = "6.0"
Expand Down
10 changes: 2 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,7 @@ def __init__(self, ansys_path: str):
self.ansys_path = ansys_path

def __enter__(self):
context = dpf.server.server_context.ServerContext(
dpf.server_context.LicensingContextType.premium
)

server = dpf.start_local_server(ansys_path=self.ansys_path, context=context)
server = dpf.start_local_server(ansys_path=self.ansys_path)
return ServerContext(port=None, platform=sys.platform, server=server)

def __exit__(self, *args):
Expand Down Expand Up @@ -300,9 +296,7 @@ def start_server():
server = _try_until_timeout(start_server, "Failed to start server.")

_wait_until_server_is_up(server)
server.apply_context(
dpf.server.server_context.ServerContext(dpf.server_context.LicensingContextType.premium)
)

load_composites_plugin(server, ansys_path=installer_path)

yield server
Expand Down

0 comments on commit 38f35e6

Please sign in to comment.