Source code for viiapackage.analyses.helper_functions.shallow_foundation_elements

### ===================================================================================================================
###   _viia_find_shallow_foundation_elements
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING
from random import sample as random_sample

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.fem_math import fem_point_on_line

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


### ===================================================================================================================
###   2. Function to get the shallow foundation elements
### ===================================================================================================================

[docs]def viia_find_shallow_foundation_elements(project: ViiaProject): """ This function is used to find the mesh information related to shallow foundation.""" shallow_foundation_elem = { 'support_obj': [], 'boundary_interface_obj': []} shallow_foundation_nod = { 'support_obj': [], 'boundary_interface_obj': [], 'line_support': []} for support_obj in project.collections.surface_supports: support_obj_connecting_shape = support_obj.connecting_shapes[0]['connecting_shape'] shallow_foundation_elem['support_obj'].extend(support_obj_connecting_shape.mesh.mesh_elements) shallow_foundation_nod['support_obj'].extend(support_obj_connecting_shape.mesh.get_meshnodes()) for boundary_interface_obj in project.collections.boundary_interfaces: shallow_foundation_elem['boundary_interface_obj'].extend(boundary_interface_obj.mesh.mesh_elements) shallow_foundation_nod['boundary_interface_obj'].extend(boundary_interface_obj.mesh.get_meshnodes()) for line_support in project.collections.line_supports: for connecting_shape in line_support.connecting_shapes: for shape in project.collections.shapes: if connecting_shape['connecting_shape'] is shape: for node in shape.mesh.get_meshnodes(): if fem_point_on_line(node.coordinates, connecting_shape['shape_geometry'].get_points()): shallow_foundation_nod['line_support'].append(node) all_shallow_foundation_elem = [] all_shallow_foundation_nod = [] for key in shallow_foundation_elem.keys(): shallow_foundation_elem[key] = list(set(shallow_foundation_elem[key])) all_shallow_foundation_elem.extend(shallow_foundation_elem[key]) for key in shallow_foundation_nod.keys(): shallow_foundation_nod[key] = list(set(shallow_foundation_nod[key])) all_shallow_foundation_nod.extend(shallow_foundation_nod[key]) all_shallow_foundation_elem = list(set(all_shallow_foundation_elem)) if len(all_shallow_foundation_elem) < 10: shallow_foundation_ref_elem = all_shallow_foundation_elem else: shallow_foundation_ref_elem = random_sample(all_shallow_foundation_elem, 10) shallow_foundation_ref_nod = [] for element in shallow_foundation_ref_elem: shallow_foundation_ref_nod.extend(element.mesh_nodes) return shallow_foundation_elem, shallow_foundation_nod, shallow_foundation_ref_elem, shallow_foundation_ref_nod
[docs]def viia_find_boundary_interfaces_nodes_elements(project: ViiaProject): """ This function is used to find the mesh information related to shallow foundation.""" eval_elements_base_shear = [] eval_nodes_base_shear = [] # Finding the boundary interface elements for boundary_interface in project.collections.boundary_interfaces: eval_elements_base_shear.extend(boundary_interface.mesh.mesh_elements) # Finding the boundary interface nodes for elem in eval_elements_base_shear: eval_nodes_base_shear.extend(elem.mesh_nodes) # Return as tuple return list(set(eval_nodes_base_shear)), eval_elements_base_shear
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================