Skip to content

Commit 06bd7ea

Browse files
committed
LS Dyna example with local patch working
1 parent e284e68 commit 06bd7ea

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

examples/015_lsdyna.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
from ansys.dpf.composites.composite_model import CompositeModel, CompositeScope
33
from ansys.dpf.composites.server_helpers import connect_to_or_start_server
44
from ansys.dpf.composites.data_sources import ContinuousFiberCompositesFiles, CompositeDefinitionFiles
5-
from ansys.dpf.core import unit_systems
5+
from ansys.dpf.core import DataSources, Operator, unit_systems
66

77
from ansys.dpf.composites.layup_info import AnalysisPlyInfoProvider, get_all_analysis_ply_names
88
from ansys.dpf.composites.ply_wise_data import SpotReductionStrategy, get_ply_wise_data
99

1010
from ansys.dpf.composites.constants import Spot, Sym3x3TensorComponent
1111

1212
import os
13+
import json
1314

14-
server = connect_to_or_start_server()
15+
server = connect_to_or_start_server(ansys_path=r'D:\ANSYSDev\dpf_composites\fake_wb_installation')
1516

1617
solver_dir = r'D:\ANSYSDev\dpf_composites\test_data\lsdyna\shell_model_2'
1718

@@ -41,10 +42,36 @@
4142

4243
stress_operator = composite_model.core_model.results.stress()
4344
stress_operator.inputs.bool_rotate_to_global(False)
44-
stress_field_material_coord = stress_operator.get_output(
45+
46+
# %%
47+
# Prepare data
48+
# ~~~~~~~~~~~~
49+
# The LS Dyna results have to be pre-processed to support
50+
# filtering and in order make them consistent with the layup
51+
# model.
52+
53+
keyword_parser = Operator("composite::ls_dyna_keyword_parser")
54+
keyword_parser.inputs.data_sources(composite_model.data_sources.solver_input_file)
55+
keyword_parser.inputs.keyword("DATABASE_EXTENT_BINARY")
56+
keyword_options_as_json = json.loads(keyword_parser.outputs[0].get_data())
57+
58+
stress_container = stress_operator.get_output(
59+
pin=0, output_type=dpf.types.fields_container
60+
)
61+
strip_operator = Operator("composite::ls_dyna_strip_results")
62+
strip_operator.inputs.maxint(int(keyword_options_as_json["maxint"]))
63+
strip_operator.inputs.fields_container(stress_container)
64+
strip_operator.inputs.mesh(composite_model.get_mesh())
65+
66+
stripped_stress_field = strip_operator.get_output(
4567
pin=0, output_type=dpf.types.fields_container
4668
)[0]
4769

70+
71+
# stress_field_material_coord = stress_operator.get_output(
72+
# pin=0, output_type=dpf.types.fields_container
73+
# )[0]
74+
4875
# %%
4976
# Filter data by analysis ply
5077
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -57,7 +84,7 @@
5784
for ply_name in all_ply_names:
5885
print(f"Plotting ply {ply_name}")
5986
elemental_values = get_ply_wise_data(
60-
field=stress_field_material_coord,
87+
field=stripped_stress_field,
6188
ply_name=ply_name,
6289
mesh=composite_model.get_mesh(),
6390
component=Sym3x3TensorComponent.TENSOR11,

src/ansys/dpf/composites/layup_info/_layup_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def get_element_info_provider(
284284
-----
285285
Either a data_source or a stream_provider is required
286286
"""
287-
if result_key_is_d3plot:
287+
if result_key_is_d3plot(stream_provider_or_data_source):
288288
if version_older_than(mesh._server, "10.0"): # pylint: disable=protected-access
289289
raise RuntimeError("LSDyna support is only available in DPF 10.0 (2025 R2) and later.")
290290

0 commit comments

Comments
 (0)