### ===================================================================================================================
### FUNCTION: Collect information for the inspection report
### ===================================================================================================================
# Copyright ©VIIA 2025
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List, Optional, Union
# References for functions and classes in the haskoning_structural package
from haskoning_structural.connections import Interface
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
from viiapackage.connections import viia_get_line_interfaces
### ===================================================================================================================
### 2. Function get_l2_measure_results
### ===================================================================================================================
[docs]def get_l2_measure_results(
project: ViiaProject, interfaces: Optional[List[Interface]] = None,
averaging_window: Optional[Union[int, float]] = None) -> dict:
"""
Get the results of L2 measures.
Input:
- project (obj): Project object reference containing collections of fem objects and project variables.
- interfaces (list of obj): List of interfaces objects that needs to be considered. When None all the interfaces
will be considered. Default is None.
- averaging_window (int/float): The window size for the moving average functionality to smear out peaks over a
window. If None, the default value from the viiaSettings is used. Only change this in consultation with the
detail engineer. Default is None.
Output:
- A dict with the result information of the L2 measures
"""
if not averaging_window:
averaging_window = project.viia_settings.line_interface_averaging_window_size
data = {}
if interfaces is None:
interfaces = viia_get_line_interfaces(project=project)
if not interfaces:
return data
use_continuous_line_interfaces = False
continuous_line_interfaces = project.get_continuous_line_interfaces(line_interfaces=interfaces)
for line_interfaces in continuous_line_interfaces:
if len(line_interfaces) > 1:
use_continuous_line_interfaces = True
# The output items that are needed for the shear forces
output_items = [
project.find_output_item(engineering_notation='t_y_tot_intp'),
project.find_output_item(engineering_notation='t_x_tot_intp')]
# Check all the analysis_references
analysis_references = project.collections.analysis_references
# With regard to speed it is better to loop through the connection results because there the interface is already
# known
cr_can_be_checked = set(cr for cr in project.collections.connection_results if cr.connection in interfaces)
int_can_be_checked = set(cr.connection for cr in cr_can_be_checked)
interfaces = set(interfaces)
cr_can_not_be_checked = interfaces.difference(int_can_be_checked)
if cr_can_not_be_checked:
project.write_log(f"WARNING: The following interfaces do not have connection results: {cr_can_not_be_checked}")
if use_continuous_line_interfaces:
# Match / group the connection results
continuous_connection_results = []
for _continuous_line_interfaces in continuous_line_interfaces:
sub_list = []
for interface in _continuous_line_interfaces:
for cr in cr_can_be_checked:
if cr.connection == interface:
sub_list.append(cr)
cr_can_be_checked.remove(cr)
break
if len(sub_list) == len(_continuous_line_interfaces):
continuous_connection_results.append(sub_list)
else:
raise ValueError(
f"ERROR: The continuous line interfaces {_continuous_line_interfaces} does not have all the "
f"connection results. Please check the model and the connection results.")
# Loop through the continuous connection results and retrieve the results
for continuous_connection_result in continuous_connection_results:
_data = project.moving_average_line_interface_results(
connection_result=continuous_connection_result, output_items=output_items,
analysis_references=analysis_references,
window_size=averaging_window, software=project.software)
# tuple the interfaces to use as key in the data dict
data[tuple(_data['interfaces'])] = _data
else:
# Loop through the connection results and retrieve the results
for cr in cr_can_be_checked:
data[cr.connection] = project.moving_average_line_interface_results(
connection_result=cr, output_items=output_items, analysis_references=analysis_references,
window_size=averaging_window, software=project.software)
return data
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================