Skip to content

Commit

Permalink
LS Dyna example with local patch working
Browse files Browse the repository at this point in the history
  • Loading branch information
roosre committed Jan 29, 2025
1 parent e284e68 commit 06bd7ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
35 changes: 31 additions & 4 deletions examples/015_lsdyna.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
from ansys.dpf.composites.composite_model import CompositeModel, CompositeScope
from ansys.dpf.composites.server_helpers import connect_to_or_start_server
from ansys.dpf.composites.data_sources import ContinuousFiberCompositesFiles, CompositeDefinitionFiles
from ansys.dpf.core import unit_systems
from ansys.dpf.core import DataSources, Operator, unit_systems

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

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

import os
import json

server = connect_to_or_start_server()
server = connect_to_or_start_server(ansys_path=r'D:\ANSYSDev\dpf_composites\fake_wb_installation')

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

Expand Down Expand Up @@ -41,10 +42,36 @@

stress_operator = composite_model.core_model.results.stress()
stress_operator.inputs.bool_rotate_to_global(False)
stress_field_material_coord = stress_operator.get_output(

# %%
# Prepare data
# ~~~~~~~~~~~~
# The LS Dyna results have to be pre-processed to support
# filtering and in order make them consistent with the layup
# model.

keyword_parser = Operator("composite::ls_dyna_keyword_parser")
keyword_parser.inputs.data_sources(composite_model.data_sources.solver_input_file)
keyword_parser.inputs.keyword("DATABASE_EXTENT_BINARY")
keyword_options_as_json = json.loads(keyword_parser.outputs[0].get_data())

stress_container = stress_operator.get_output(
pin=0, output_type=dpf.types.fields_container
)
strip_operator = Operator("composite::ls_dyna_strip_results")
strip_operator.inputs.maxint(int(keyword_options_as_json["maxint"]))
strip_operator.inputs.fields_container(stress_container)
strip_operator.inputs.mesh(composite_model.get_mesh())

stripped_stress_field = strip_operator.get_output(
pin=0, output_type=dpf.types.fields_container
)[0]


# stress_field_material_coord = stress_operator.get_output(
# pin=0, output_type=dpf.types.fields_container
# )[0]

# %%
# Filter data by analysis ply
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -57,7 +84,7 @@
for ply_name in all_ply_names:
print(f"Plotting ply {ply_name}")
elemental_values = get_ply_wise_data(
field=stress_field_material_coord,
field=stripped_stress_field,
ply_name=ply_name,
mesh=composite_model.get_mesh(),
component=Sym3x3TensorComponent.TENSOR11,
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/composites/layup_info/_layup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def get_element_info_provider(
-----
Either a data_source or a stream_provider is required
"""
if result_key_is_d3plot:
if result_key_is_d3plot(stream_provider_or_data_source):
if version_older_than(mesh._server, "10.0"): # pylint: disable=protected-access
raise RuntimeError("LSDyna support is only available in DPF 10.0 (2025 R2) and later.")

Expand Down

0 comments on commit 06bd7ea

Please sign in to comment.