### ===================================================================================================================
### 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, Optional
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, Surfaces
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 _viia_connect_pile(surface_shapes: List[Surfaces], coordinate: List[float]) -> Optional[Node]:
""" Function to find the lowest horizontal surface shape from the list that intersects with a vertical line through
the provided coordinate. This intersection is added as node to the surface-shape. Node is returned when an
intersection is present. It is checked whether there is already a pile present."""
z_lowest_strip = 1e4
connecting_shape = None
for shape in surface_shapes:
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
return None
[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)
node = _viia_connect_pile(surface_shapes=project.collections.fstrips, coordinate=coordinate)
if node:
return node
# Check if pile is connecting to a floor
node = _viia_connect_pile(surface_shapes=project.collections.floors, coordinate=coordinate)
if node:
warn(
"WARNING: There are piles located underneath floor elements instead of foundation strips. 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
### ===================================================================================================================