Source code for viiapackage.analyses.helper_functions.piles_elements

### ===================================================================================================================
###   Function viia_find_piles_elements
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List, Tuple

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.connections import Spring
from rhdhv_fem.mesh import MeshNode, MeshElement
from rhdhv_fem.fem_math import fem_greater, fem_smaller

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


### ===================================================================================================================
###   2. Function to get the pile elements
### ===================================================================================================================

[docs]def viia_find_piles_elements( project: ViiaProject) \ -> Tuple[List[MeshElement], List[MeshNode], List[MeshElement], List[MeshElement], List[MeshNode]]: """ This function is used to find pile elements for fixed or flexbase. For fixed base, pile elements, bottom nodes of pile are returned. For flexbase, pile spring elements, top nodes of Huan beam and pile reinforcements are returned. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. Output: - Returns tuple with 5 outputs: - List of pile mesh-elements used for the output of the fixed base analysis. - List of pile mesh-nodes (bottom-node of the pile shape) used for the output of the fixed base analysis. - List of pile reinforcement mesh-elements used for the output of the flexbase analysis. - List of pile mesh-elements used for the output of the flexbase analysis. - List of pile mesh-nodes used for the output of the flexbase analysis. """ pile_shapes = [] pile_springs = [] pile_elem = [] pile_spring_elem = [] pile_nod = [] pile_reinforcements = [] for pile in project.collections.piles: pile_shapes.append(pile) # No parent connection in FixedBase support. The code below is only for FlexBase support if pile.parent is not None: pile_springs.extend( connection for connection in pile.parent.connections if isinstance(connection, Spring)) # Collect pile elements for pile in pile_shapes: pile_elem.extend(pile.mesh.mesh_elements) # Collect pile nodes nodes = [] for element in pile.mesh.mesh_elements: nodes.extend(element.mesh_nodes) node_z = nodes[0].coordinates[2] node_select = None if project.viia_settings.support_type == 'FixedBase': # collect bottom node of huan beam for node in nodes: if fem_smaller(node.coordinates[2], node_z): node_z = node.coordinates[2] node_select = node else: # collect top node of huan beam for node in nodes: if fem_greater(node.coordinates[2], node_z): node_z = node.coordinates[2] node_select = node pile_nod.append(node_select) # Collect pile spring elements for spring in pile_springs: if '-FCRITX' in spring.name or '-FCRITY' in spring.name or '-FCRITZ' in spring.name: pile_spring_elem.extend(spring.mesh.mesh_elements) pile_spring_nodes = [] for _pile_spring_elem in pile_spring_elem: pile_spring_nodes.extend(_pile_spring_elem.mesh_nodes) # Collect pile reinforcements for flexbase if project.viia_settings.support_type != 'FixedBase': # The mesh of Reinforcement cannot yet be read from DIANA. # for pile in project.collections.piles: # for shape in pile.get_reinforcements(): # pile_reinf.extend(shape.mesh.get_meshelements()) pass return pile_elem, pile_nod, pile_reinforcements, pile_spring_elem, pile_spring_nodes
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================