### ===================================================================================================================
### FUNTION: Collect information for the inspection report
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
from viiapackage.reporting.helper_functions.get_l2_measure_results import get_l2_measure_results
### ===================================================================================================================
### 2. Function get_l2_measure_data
### ===================================================================================================================
[docs]def get_l2_measure_data(project: ViiaProject) -> List:
"""
Get the data of L2 measures.
Input:
- project (obj): Project object reference containing collections of fem objects and project variables.
Output:
- A dict with the measure information of the L2 measures
"""
stresses = ['_t_x', '_t_y', '_t_z']
strains = ['_du_x', '_du_y', '_du_z']
total_list = []
l2_measure_forces = get_l2_measure_results(project=project)
for key, value in l2_measure_forces.items():
measure_data = {
'name': key.name,
'source': key.connecting_shapes['source_connecting_shape'].name,
'target': key.connecting_shapes['target_connecting_shape'].name}
for result_name, result_value in value.items():
if isinstance(result_value, list):
result_value = result_value[1]
if any([stress in result_name for stress in stresses]):
measure_data[result_name] = '{:.1f}'.format(result_value/1000) # convert to kN/m from N/m
elif any([strain in result_name for strain in strains]):
measure_data[result_name] = '{:.0f}'.format(result_value*1000) # convert to mm from m
else:
raise ValueError(f"ERROR: Result should be of type {stresses+strains}. Provided was {result_name}.")
total_list.append(measure_data)
return total_list
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================