Skip to content

Commit

Permalink
Merge pull request #64 from honzatomek/bugfix/element_solid_strain
Browse files Browse the repository at this point in the history
bugfix: element_solid_strain and i_solid_vars
  • Loading branch information
codie3611 authored Sep 25, 2024
2 parents 6335505 + 5b673a6 commit 2c1bfa3
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions lasso/dyna/d3plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4397,7 +4397,7 @@ def _read_states_solids(self, state_data: np.ndarray, var_index: int, array_dict
i_solid_var += n_history_vars

# strain
# they are the last 6 entries of the history vars
# they are the last 6 entries of the history vars (if ISTRN = 1)
if n_strain_vars:
try:
array_dict[ArrayType.element_solid_strain] = array_dict[
Expand All @@ -4416,34 +4416,46 @@ def _read_states_solids(self, state_data: np.ndarray, var_index: int, array_dict
LOGGER.warning(msg, "_read_states_solids, strain", trb_msg)

# plastic strain tensor
# if present, beginning of element_solid_history_variables (if ISTRN = 11)
if self.header.has_solid_shell_plastic_strain_tensor:
try:
array_dict[ArrayType.element_solid_plastic_strain_tensor] = solid_state_data[
:, :, :, i_solid_var : i_solid_var + 6
]
array_dict[ArrayType.element_solid_plastic_strain_tensor] = array_dict[
ArrayType.element_solid_history_variables
][:, :, :, :n_strain_vars]

array_dict[ArrayType.element_solid_history_variables] = array_dict[
ArrayType.element_solid_history_variables
][:, :, :, n_strain_vars:]

if not all(array_dict[ArrayType.element_solid_history_variables].shape):
del array_dict[ArrayType.element_solid_history_variables]
except Exception:
trb_msg = traceback.format_exc()
msg = "A failure in %s was caught:\n%s"
LOGGER.warning(
msg, "_read_states_solids, element_solid_plastic_strain_tensor", trb_msg
)
finally:
i_solid_var += 6

# thermal strain tensor
# if present, beginning of element_solid_history_variables
if self.header.has_solid_shell_thermal_strain_tensor:
try:
array_dict[ArrayType.element_solid_thermal_strain_tensor] = solid_state_data[
:, :, i_solid_var : i_solid_var + 6
]
array_dict[ArrayType.element_solid_thermal_strain_tensor] = array_dict[
ArrayType.element_solid_history_variables
][:, :, :, :n_strain_vars]

array_dict[ArrayType.element_solid_history_variables] = array_dict[
ArrayType.element_solid_history_variables
][:, :, :, n_strain_vars:]

if not all(array_dict[ArrayType.element_solid_history_variables].shape):
del array_dict[ArrayType.element_solid_history_variables]
except Exception:
trb_msg = traceback.format_exc()
msg = "A failure in %s was caught:\n%s"
LOGGER.warning(
msg, "_read_states_solids, element_solid_thermal_strain_tensor", trb_msg
)
finally:
i_solid_var += 6

# catch formatting in solid_state_datra
except Exception:
Expand Down

0 comments on commit 2c1bfa3

Please sign in to comment.