Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for LSDyna operators #567

Merged
merged 24 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1f23955
Add tests for LSDyna operators
rafacanton Oct 17, 2022
2b5ca3b
added matsum and rcforc tests
rafacanton Oct 24, 2022
a205e44
Added support for glstat
rafacanton Oct 28, 2022
a8a9056
Merge branch 'master' into rcanton/lsdyna_src
rafacanton Oct 31, 2022
7eb1199
Merge branch 'master' into rcanton/lsdyna_src
rafacanton Nov 17, 2022
695eb6e
Merge branch 'master' into rcanton/lsdyna_src
rafacanton Nov 23, 2022
58f3363
LSDyna example
rafacanton Nov 24, 2022
ad0cc59
Merge branch 'master' into rcanton/lsdyna_src
rafacanton Nov 24, 2022
0ae86d2
Remove duplicate files
rafacanton Nov 25, 2022
1db7a9f
examples.py
rafacanton Nov 25, 2022
a0bf428
remove import os
rafacanton Nov 25, 2022
e4f3b2b
remove import pytest
rafacanton Nov 25, 2022
f843cf8
Merge branch 'master' into rcanton/lsdyna_src
rafacanton Nov 28, 2022
cb07b85
glstat ops added
rafacanton Nov 28, 2022
41ae070
add test fixture for server > 0.6
rafacanton Nov 28, 2022
aa79fa1
refactor the test/example files
rafacanton Nov 28, 2022
63ef167
List in d3plot_beam to use only first file
rafacanton Nov 28, 2022
9c6b1e7
take right file in the lsdyna example
rafacanton Nov 29, 2022
59e19a3
Fix double import of mpl
rafacanton Nov 29, 2022
aefe174
re-add plt
rafacanton Nov 29, 2022
6aaf55a
Merge branch 'master' into rcanton/lsdyna_src
rafacanton Nov 29, 2022
7a7762b
Implement reviewer's comments
rafacanton Nov 30, 2022
f198bc4
Include animation in lsdyna example
rafacanton Nov 30, 2022
cc5843a
Improve example
rafacanton Nov 30, 2022
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
118 changes: 118 additions & 0 deletions ansys/dpf/core/examples/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,121 @@ def download_piston_rod(should_upload: bool = True, server=None, return_local_pa

"""
return _download_file("piston_rod", "piston_rod.rst", should_upload, server, return_local_path)


def download_d3plot_beam(should_upload: bool = True, server=None, return_local_path=False) -> list:
"""Download the result file of an example of a d3plot file with beam elements and return the
download paths available on the server side.
If the server is remote (or doesn't share the memory), the file is uploaded or made available
on the server side.

Examples files are downloaded to a persistent cache to avoid
re-downloading the same file twice.

Parameters
----------
should_upload : bool, optional (default True)
Whether the file should be uploaded to the server side when the server is remote.
server : server.DPFServer, optional
Server with channel connected to the remote or local instance. When
rafacanton marked this conversation as resolved.
Show resolved Hide resolved
``None``, attempts to use the global server.
return_local_path: bool, optional
If ``True``, the local path is returned as is, without uploading, nor searching
for mounted volumes.

Returns
-------
str
Path to the example file.

Examples
--------
Download an example result file and return the path of the files.

>>> from ansys.dpf.core import examples
>>> paths = examples.download_d3plot_beam()
>>> paths
['C:/Users/user/AppData/local/temp/d3plot',
'C:/Users/user/AppData/local/temp/d3plot01',
'C:/Users/user/AppData/local/temp/d3plot02']

"""
return [_download_file("d3plot_beam", "d3plot" , should_upload, server, return_local_path),
_download_file("d3plot_beam", "d3plot01", should_upload, server, return_local_path),
_download_file("d3plot_beam", "d3plot02", should_upload, server, return_local_path)]


def download_binout_matsum(should_upload: bool = True, server=None, return_local_path=False) -> str:
"""Download the result file of an example of a binout file with matsum branch and return the
download path available on the server side.
If the server is remote (or doesn't share the memory), the file is uploaded or made available
on the server side.

Examples files are downloaded to a persistent cache to avoid
re-downloading the same file twice.

Parameters
----------
should_upload : bool, optional (default True)
Whether the file should be uploaded to the server side when the server is remote.
server : server.DPFServer, optional
Server with channel connected to the remote or local instance. When
``None``, attempts to use the global server.
return_local_path: bool, optional
If ``True``, the local path is returned as is, without uploading, nor searching
for mounted volumes.

Returns
-------
str
Path to the example file.

Examples
--------
Download an example result file and return the path of the file.

>>> from ansys.dpf.core import examples
>>> path = examples.download_binout_matsum()
>>> path
'C:/Users/user/AppData/local/temp/binout_matsum'

"""
return _download_file("binout", "binout_matsum", should_upload, server, return_local_path)


def download_binout_glstat(should_upload: bool = True, server=None, return_local_path=False) -> str:
"""Download the result file of an example of a binout file with glstat branch and return the
download path available on the server side.
If the server is remote (or doesn't share the memory), the file is uploaded or made available
on the server side.

Examples files are downloaded to a persistent cache to avoid
re-downloading the same file twice.

Parameters
----------
should_upload : bool, optional (default True)
Whether the file should be uploaded to the server side when the server is remote.
server : server.DPFServer, optional
Server with channel connected to the remote or local instance. When
``None``, attempts to use the global server.
return_local_path: bool, optional
If ``True``, the local path is returned as is, without uploading, nor searching
for mounted volumes.

Returns
-------
str
Path to the example file.

Examples
--------
Download an example result file and return the path of the file.

>>> from ansys.dpf.core import examples
>>> path = examples.download_binout_glstat()
>>> path
'C:/Users/user/AppData/local/temp/binout_glstat'

"""
return _download_file("binout", "binout_glstat", should_upload, server, return_local_path)
21 changes: 19 additions & 2 deletions ansys/dpf/core/operators/result/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from .current_density import current_density
from .global_total_mass import global_total_mass
from .beam_axial_stress import beam_axial_stress
from .tangential_contact_force import tangential_contact_force
from .normal_contact_force import normal_contact_force
from .plastic_strain_principal_1 import plastic_strain_principal_1
from .global_eroded_internal_energy import global_eroded_internal_energy
from .initial_coordinates import initial_coordinates
from .num_surface_status_changes import num_surface_status_changes
from .beam_axial_total_strain import beam_axial_total_strain
from .global_sliding_interface_energy import global_sliding_interface_energy
from .joint_relative_angular_velocity import joint_relative_angular_velocity
from .beam_axial_force import beam_axial_force
from .nodal_moment import nodal_moment
Expand Down Expand Up @@ -36,6 +39,7 @@
from .elastic_strain_X import elastic_strain_X
from .elastic_strain_Y import elastic_strain_Y
from .elastic_strain_Z import elastic_strain_Z
from .global_energy_ratio_wo_eroded import global_energy_ratio_wo_eroded
from .elastic_strain_XY import elastic_strain_XY
from .elastic_strain_YZ import elastic_strain_YZ
from .interface_contact_mass import interface_contact_mass
Expand Down Expand Up @@ -66,6 +70,7 @@
from .thermal_strain_principal_1 import thermal_strain_principal_1
from .thermal_strain_principal_2 import thermal_strain_principal_2
from .thermal_strain_principal_3 import thermal_strain_principal_3
from .global_external_work import global_external_work
from .acceleration import acceleration
from .acceleration_X import acceleration_X
from .acceleration_Y import acceleration_Y
Expand Down Expand Up @@ -102,6 +107,7 @@
from .contact_pressure import contact_pressure
from .contact_friction_stress import contact_friction_stress
from .contact_total_stress import contact_total_stress
from .global_joint_internal_energy import global_joint_internal_energy
from .contact_sliding_distance import contact_sliding_distance
from .contact_gap_distance import contact_gap_distance
from .contact_surface_heat_flux import contact_surface_heat_flux
Expand Down Expand Up @@ -134,12 +140,23 @@
from .global_internal_energy import global_internal_energy
from .thermal_strains_eqv import thermal_strains_eqv
from .stress_von_mises import stress_von_mises
from .plastic_strain_eqv import plastic_strain_eqv
from .global_kinetic_energy import global_kinetic_energy
from .global_velocity import global_velocity
from .plastic_strain_eqv import plastic_strain_eqv
from .global_time_step import global_time_step
from .global_rigid_body_stopper_energy import global_rigid_body_stopper_energy
from .global_spring_damper_energy import global_spring_damper_energy
from .beam_t_bending_moment import beam_t_bending_moment
from .global_hourglass_energy import global_hourglass_energy
from .global_system_damping_energy import global_system_damping_energy
from .global_eroded_kinetic_energy import global_eroded_kinetic_energy
from .global_eroded_hourglass_energy import global_eroded_hourglass_energy
from .global_energy_ratio import global_energy_ratio
from .global_added_mass import global_added_mass
from .global_added_mass_pct import global_added_mass_pct
from .global_center_mass import global_center_mass
from .beam_s_shear_force import beam_s_shear_force
from .beam_s_bending_moment import beam_s_bending_moment
from .beam_t_bending_moment import beam_t_bending_moment
from .beam_rs_shear_stress import beam_rs_shear_stress
from .beam_tr_shear_stress import beam_tr_shear_stress
from .beam_axial_plastic_strain import beam_axial_plastic_strain
Expand Down
Loading