Source code for viiapackage.reporting.helper_functions.get_connection_info

### ===================================================================================================================
###   FUNCTION: Collect information on the connections
### ===================================================================================================================
# Copyright ©VIIA 2024

### ===================================================================================================================
###   1. Import modules
### ===================================================================================================================

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.connections import Interface

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject


### ===================================================================================================================
###   2. Helper function
### ===================================================================================================================

[docs]def get_connection_info(project: ViiaProject) -> dict: """ This function will generate dictionary keys for connection information that can later be used as jinja tags for templating. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. Output: - Returns dictionary of jinja tags assigned to corresponding info. """ connections_col = [] max_level = 0 connections_layer = { layer.name: layer.get_connections() for layer in project.viia_get_layers()} # Filter for interfaces only for layer, connections in connections_layer.items(): for connection in reversed(connections): if not isinstance(connection, Interface): connections.remove(connection) # Filter connections only in this layer or connecting to lower layer ordered_layers = [layer for layer, connections in connections_layer.items()] for enum, connection_layer in enumerate(connections_layer.items()): for connection in reversed(connection_layer[1]): if enum < len(ordered_layers) - 1: # Check if there are any connection between basement/foundation with the N0 level. if ordered_layers[enum + 1] != 'N0' and connection_layer[0] in ['F', 'B']: if connection.connecting_shapes['source_connecting_shape'].layer.name == 'N0' or \ connection.connecting_shapes['target_connecting_shape'].layer.name == 'N0': connection_layer[1].remove(connection) # Check if the layer of the connecting shapes is at a higher level or not. elif connection.connecting_shapes['source_connecting_shape'].layer.name == ordered_layers[enum + 1] or \ connection.connecting_shapes['target_connecting_shape'].layer.name == ordered_layers[enum + 1]: connection_layer[1].remove(connection) floor_floor_connection = ['D2.12'] wall_floor_connection = ['D1.01A', 'D1.02', 'D2.01', 'D2.04A', 'D2.05A', 'D2.09', 'D2.09A', 'D2.13A', 'D2.14'] wall_roof_connection = ['D5.01B'] wall_wall_connection = ['D3.02', 'D3.04'] for layer,connections in connections_layer.items(): for connection in connections: if layer != 'F': level_no = int([char for char in layer][-1]) max_level = max(max_level, level_no) material_nr = connection.material.name.split('-')[-1] if connection.material.is_linear: material = 'Linear elastic' else: material = 'Nonlinear elastic' if material_nr in floor_floor_connection: connection = 'Floor-floor' elif material_nr in wall_floor_connection: connection = 'Wall-floor' elif material_nr in wall_roof_connection: connection = 'Wall-roof' elif material_nr in wall_wall_connection: connection = 'Wall-wall' elif 'PUNT' in connection.material.name and material == 'Linear elastic': connection = 'Point interfaces restrained' elif 'PUNT' in connection.material.name and material == 'Nonlinear elastic': connection = 'Point interfaces loose' try: connections_col.append( {'connection': connection, 'material': material}) except UnboundLocalError: pass if connections_col: return { 'connections': connections_col, 'connection_level': str(max_level)} else: return {'connection_level': str(max_level)}
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================