ansys / pydpf-core

Data Processing Framework - Python Core
http://dpf.docs.pyansys.com/
MIT License
70 stars 25 forks source link

Extracting results for only specific mesh elements does not work as expected with LS-DYNA results file #1686

Open aukselis-c1connections opened 3 months ago

aukselis-c1connections commented 3 months ago

Before submitting the issue

Description of the bug

Providing scoped mesh to a results operator on LS-DYNA results does not yield any difference.

Full mesh: afbeelding

Scoped mesh of interest: afbeelding

When displaying results the "other" mesh is still visible: afbeelding

Steps To Reproduce

from ansys.dpf import core
import numpy as np

server = core.start_local_server()
ds = core.DataSources(server=server)
ds.set_result_file_path("d3part","d3plot")
model = core.Model(ds, server=server)

mesh_scoping_selection = np.loadtxt("test.txt").astype(int)

mesh_scoping = core.Scoping(ids=mesh_scoping_selection.tolist(), location="Elemental")
meshed_region = core.operators.mesh.from_scoping(
    scoping=mesh_scoping, inclusive=0, nodes_only=False, mesh=model.metadata.meshed_region
).outputs.mesh()
op = core.operators.result.stress_von_mises(
    data_sources=model,
    bool_rotate_to_global=False,
    mesh=meshed_region,
    time_scoping=[10],
    mesh_scoping=mesh_scoping,
    requested_location="Elemental",
)
field = op.outputs.fields_container()[0]

# Plot model, four regions should be visible
model.metadata.meshed_region.plot()

# Plot new meshed region, only scoped area should be visible
meshed_region.plot()

# In the plot field, the result should only be on the scoped area, and the mesh should also be visible on the scoped area only
field.plot()

The above procedure works without issues for results from rst files. I am aware that I can use field.plot(nan_opacity=0) but this makes the mesh with results also slightly transparent which is undesirable.

Result file: d3part.zip Element numbering file: test.txt

Which Operating System causes the issue?

Windows

Which DPF/Ansys version are you using?

DPF Server 2024.2.pre1

Which Python version causes the issue?

3.9

Installed packages

aiohttp==3.9.3 aiosignal==1.3.1 amqp==5.1.1 ansys-api-mapdl==0.5.1 ansys-api-platform-instancemanagement==1.0.0b3 ansys-dpf-core==0.13.0 ansys-dpf-post==0.5.0 ansys-mapdl-core==0.68.1 ansys-mapdl-reader==0.52.16 ansys-math-core==0.1.5 ansys-platform-instancemanagement==1.1.1 ansys-tools-path==0.5.2 anyio==4.3.0 appdirs==1.4.4 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 asgiref==3.7.2 asttokens==2.2.1 async-lru==2.0.4 async-timeout==4.0.3 attrs==23.2.0 Babel==2.14.0 backcall==0.2.0 beautifulsoup4==4.12.3 billiard==4.1.0 black==23.3.0 bleach==6.1.0 build==1.1.1 cachetools==5.3.1 cad-to-shapely==0.3.1 celery==5.3.4 certifi==2023.5.7 cffi==1.16.0 charset-normalizer==3.1.0 click==8.1.7 click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.3.0 codecov==2.1.13 colorama==0.4.6 colorcet==3.0.1 comm==0.1.3 contourpy==1.2.0 coverage==7.2.7 cssbeautifier==1.14.9 cycler==0.12.1 databind.core==4.4.0 databind.json==4.4.0 debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 Deprecated==1.2.14 Django==4.2.13 django-advanced-filters==2.0.0 django-debug-toolbar==4.2.0 django-json-widget==1.1.1 django-ratelimit-backend==2.0 django-turnstile==0.1.0 djlint==1.34.0 dnspython==2.4.2 docopt==0.6.2 docspec==2.2.1 docspec-python==2.2.1 docstring-parser==0.11 EditorConfig==0.12.3 et-xmlfile==1.1.0 eventlet==0.33.3 exceptiongroup==1.1.1 executing==1.2.0 ezdxf==1.1.3 fastjsonschema==2.19.0 fonttools==4.50.0 fqdn==1.5.1 frozenlist==1.4.1 future==0.18.3 geomdl==5.3.1 google-api-core==2.11.1 google-api-python-client==2.91.0 google-auth==2.21.0 google-auth-httplib2==0.1.0 googleapis-common-protos==1.59.1 greenlet==3.0.1 grpcio==1.65.4 h11==0.14.0 html-tag-names==0.1.2 html-void-elements==0.1.0 httpcore==1.0.5 httplib2==0.22.0 httpx==0.27.0 idna==3.6 imageio==2.28.0 imageio-ffmpeg==0.4.9 importlib-metadata==6.7.0 importlib_resources==6.3.1 iniconfig==2.0.0 ipykernel==6.23.3 ipython==8.14.0 ipython-genutils==0.2.0 ipywidgets==8.1.0 isoduration==20.11.0 jedi==0.18.2 Jinja2==3.1.2 joblib==1.3.1 jsbeautifier==1.14.9 json5==0.9.14 jsonpointer==2.4 jsonschema==4.20.0 jsonschema-specifications==2023.11.2 jupyter-events==0.10.0 jupyter-highlight-selected-word==0.2.0 jupyter-lsp==2.2.5 jupyter-nbextensions-configurator==0.6.3 jupyter_client==8.3.0 jupyter_contrib_core==0.4.2 jupyter_contrib_nbextensions==0.7.0 jupyter_core==5.3.1 jupyter_server==2.14.0 jupyter_server_terminals==0.5.3 jupyterlab==4.1.6 jupyterlab-widgets==3.0.8 jupyterlab_pygments==0.3.0 jupyterlab_server==2.26.0 kiwisolver==1.4.5 kombu==5.3.2 latex2mathml==3.76.0 llvmlite==0.41.1 lxml==4.9.3 Markdown==3.4.4 markdown-alerts==0.1 markdown-it-py==3.0.0 MarkupSafe==2.1.3 matplotlib==3.8.3 matplotlib-inline==0.1.6 mdurl==0.1.2 meshio==5.3.4 Metatools==0.1.1 mistune==3.0.2 more-itertools==10.2.0 mpmath==1.3.0 msgpack-python==0.5.6 multidict==6.0.5 mypy-extensions==1.0.0 nbclient==0.10.0 nbconvert==7.16.3 nbformat==5.9.2 nest-asyncio==1.5.6 notebook==6.4.12 notebook_shim==0.2.4 nr-date==2.0.0 nr-stream==1.1.5 nr.util==0.8.12 numba==0.58.1 numpy==1.26.4 opencv-python==4.9.0.80 openpyxl==3.1.2 overrides==7.7.0 packaging==24.0 pandas==2.0.3 pandocfilters==1.5.1 param==1.13.0 parso==0.8.3 pathspec==0.11.1 pickleshare==0.7.5 pillow==10.2.0 Pint==0.23 Pint-Pandas==0.5 pipreqs==0.4.13 platformdirs==3.8.0 plotext==5.2.8 plotly==5.18.0 pluggy==1.2.0 pooch==1.7.0 prometheus_client==0.20.0 prompt-toolkit==3.0.38 protobuf==3.20.3 protoc-gen-swagger==0.1.0 psutil==5.9.8 psycopg2==2.9.7 pure-eval==0.2.2 pyansys-tools-versioning==0.4.0 pyasn1==0.5.1 pyasn1-modules==0.3.0 pycparser==2.22 pyct==0.5.0 pydoc-markdown==4.8.2 Pygments==2.15.1 pyiges==0.3.1 pyparsing==3.1.2 pyproject_hooks==1.0.0 pytest==7.4.0 pytest-cov==4.1.0 python-dateutil==2.9.0.post0 python-decouple==3.8 python-json-logger==2.0.7 pytz==2023.3 pyvista==0.44.1 pywin32==306 pywinpty==2.0.13 PyYAML==6.0 pyzmq==25.1.0 redis==5.0.1 referencing==0.31.1 regex==2023.8.8 repoze.lru==0.7 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rhino-shapley-interop==0.0.4 rhino3dm==8.0.0b3 rich==13.7.0 Routes==2.5.1 rpds-py==0.13.2 rsa==4.9 scikit-learn==1.3.0 scipy==1.10.1 scooby==0.9.2 sectionproperties==3.1.2 semantic-version==2.10.0 Send2Trash==1.8.3 setuptools-rust==1.9.0 setuptools-scm==8.0.4 shapely==2.0.2 simplejson==3.19.2 six==1.16.0 sniffio==1.3.1 soupsieve==2.5 sqlparse==0.4.4 stack-data==0.6.2 sympy==1.12 tabulate==0.9.0 tenacity==8.2.3 terminado==0.18.1 threadpoolctl==3.1.0 tinycss2==1.2.1 tomli==2.0.1 tomli_w==1.0.0 tornado==6.3.2 tqdm==4.65.0 traitlets==5.9.0 trame==3.5.2 trame-client==2.16.1 trame-plotly==3.0.1 trame-server==2.17.2 trame-vtk==2.5.8 trame-vuetify==2.3.1 triangle==20230923 typeapi==2.1.1 types-python-dateutil==2.9.0.20240316 typing_extensions==4.7.0 tzdata==2023.3 uri-template==1.3.0 uritemplate==4.1.1 urllib3==1.26.18 vine==5.0.0 vtk==9.3.0 watchdog==3.0.0 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 websocket-client==1.7.0 widgetsnbextension==4.0.8 wrapt==1.15.0 wslink==1.12.4 XlsxWriter==3.1.4 xlwings==0.30.11 yapf==0.40.1 yarg==0.1.9 yarl==1.9.4

PProfizi commented 1 month ago

Hello @aukselis-c1connections, Thank you for raising this issue. I confirm I can reproduce with all the latest versions. I am raising the issue internally so the behavior is fixed. In the meantime, a quick workaround is to use: meshed_region.plot(field)