Source code for viiapackage.analyses.helper_functions.set_base_node

### ===================================================================================================================
###  Set the base node for the VIIA project
### ===================================================================================================================
# 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.mesh import MeshNode
from rhdhv_fem.fem_shapes import fem_min_max_points

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


### ===================================================================================================================
###   2. Function to get the base node
### ===================================================================================================================

[docs]def viia_set_base_node(project: ViiaProject) -> MeshNode: """ This function looks for the closest node in the mesh to the center point of the foundation elements. The center is determined as the average between minimum and maximum coordinate in x-, y- and z-direction. All nodes are checked with the same z-coordinate as the average. .. warning:: Function may not find correct node if different levels are present. In that case node 0 is set. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. Output: - The base node is updated or set in project.base_point. """ if len(project.collections.fstrips) > 0: coord = fem_min_max_points(project.collections.fstrips) coordinates_goal = [ (coord['x-max'] + coord['x-min']) / 2, (coord['y-max'] + coord['y-min']) / 2, coord['z-min']] project.base_point = viia_find_closest_mesh_node(project=project, target_point=coordinates_goal, direction='Z') else: # This is the case in a soilcolumn calculation coordinates_goal = [ project.project_specific['soilblock']['x min'], project.project_specific['soilblock']['y min'], project.project_specific['soilblock']['bedrock level']] project.base_point = viia_find_closest_mesh_node(project=project, target_point=coordinates_goal, direction='Z') return project.base_point
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================