Source code for viiapackage.supports.pile_foundation.connect_foundation

### ===================================================================================================================
###   Connect the coordinates for the foundation to the foundation strip
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List, Tuple
from warnings import warn
from copy import deepcopy

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.shape_geometries import Node
from rhdhv_fem.connections import Spring
from rhdhv_fem.shapes import Pile, Wall
from rhdhv_fem.fem_math import fem_smaller

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


### ===================================================================================================================
###   2. Functions to find the foundation strip to connect the pile(s) to
### ===================================================================================================================

[docs]def viia_connect_all_piles(project: ViiaProject, coordinates: List[List[float]]) -> List[Node]: """ Function to connect all coordinates for the piles to the foundation strip surface shapes.""" return [viia_connect_fstrip(project=project, coordinate=coordinate) for coordinate in coordinates]
def _get_point_foundation_walls(walls: List[Wall], point: List[float]) -> Tuple[Wall, float]: """ Helper-function to find the lowest point to connect to pile on any wall in the collection of walls.""" lowest_z = None conn_shape = None for shape in walls: # Only considering flat bottom sides of foundation walls z_conn_point = min([p[2] for p in shape.contour.get_points()]) if shape.contour.is_point_on_contour(point=[*point, z_conn_point]): if lowest_z is None or z_conn_point < lowest_z: conn_shape = shape lowest_z = z_conn_point return conn_shape, lowest_z
[docs]def viia_connect_fstrip(project: ViiaProject, coordinate: List[float]) -> Node: """ This function finds the lowest foundation strip present on the x and y coordinates. It selects the lowest one in vertical direction. It converts the point to a shape-geometry Node and adds that node to the foundation strip surface shape. This can be an internal line or a point on the contour. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - coordinate (list of 2 floats): The x- and y-coordinate of the position of the pile. The z-coordinate should not be provided. Output: - Finds the foundation strip located on that position. - Converts the point to a node and adds that as an internal point or contour point of the foundation strip. """ # Check input if len(coordinate) != 2: raise ValueError( "ERROR: Provided coordinate should have 2 values (x- and y-coordinate), z-coordinate should not be " "provided.") # Check if pile is connecting to a foundation strip (present in class Fstrip) z_lowest_strip = 1e4 connecting_shape = None for shape in project.collections.fstrips: if shape.is_point_in_horizontal_projection_of_shape(point=deepcopy(coordinate)): z_connection_point = shape.get_intersection(point=[coordinate[0], coordinate[1], 0], direction=[0, 0, 1])[2] if fem_smaller(z_connection_point, z_lowest_strip): z_lowest_strip = z_connection_point connecting_shape = shape if connecting_shape: node = connecting_shape.add_internal_point(point=[*coordinate, z_lowest_strip]) if any([isinstance(shape, Pile) or (isinstance(shape, Spring) and 'PAAL' in shape.name) for shape in node.get_shapes() + node.get_connections()]): raise ValueError(f"ERROR: There is already a pile located on this position ({coordinate}).") return node # Check if any foundation wall is present (not the default workflow!) # First try to find the foundation walls connecting_shape, z_lowest_strip = _get_point_foundation_walls( walls=[wall for wall in project.collections.walls if 'FUNDERINGSWANDEN' in wall.name], point=coordinate) if connecting_shape is None: connecting_shape, z_lowest_strip = _get_point_foundation_walls( walls=[wall for wall in project.collections.walls if 'FUNDERINGSWANDEN' not in wall.name], point=coordinate) if connecting_shape: node = connecting_shape.add_internal_point(point=[*coordinate, z_lowest_strip]) if any([isinstance(shape, Pile) or (isinstance(shape, Spring) and 'PAAL' in shape.name) for shape in node.get_shapes() + node.get_connections()]): raise ValueError(f"ERROR: There is already a pile located on this position ({coordinate}).") warn( "WARNING: There are piles located underneath wall shapes, this deviates from the default workflow and " "should be discussed with LE and reported in the object specific engineering report.") return node raise ValueError( f"ERROR: There is no foundation strip for point x={coordinate[0]} and y={coordinate[1]}. " f"Please correct the input for the pile locations.")
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================